Ubuntu – Moving Grub to a new drive to get rid of Windows

bootdual-bootgrub2hard drivessd

A while back I installed Linux on my SSD, sdb1. I also have a 1 terabyte drive for my home directory, sdc1. I have Windows on another hard drive, sda1, which I haven’t booted into in over 2 years. It is a terabyte in size. I would like to get rid of Windows and utilize that extra space without reinstalling Linux, but Grub is on the Windows hard drive, sda1. What I would like to do is put Grub onto my SSD, sdb1, if possible in order to format the Windows drive, sda1, and have extra space. It is Legacy BIOS on the computer.

Best Answer

I have done a trail with my dummy practical computer with one hdd and one ssd.

I assume, you have installed windows in UEFI boot mode with gpt partitioning type on your hdd. sda.

Since mine is a dummy practical computer, I don't need to worry about backup. I do recommend you to take backup.

I have not considered sdc for separate home partition as I don't have other drive free.

Procedure:
Log on with live session of Ubuntu.

Here are my sda-1tb hdd and sdb-120gb ssd.
I have windows10 on sda and Ubuntu18.04.1 on sdb. Grub is on sda.

enter image description here

enter image description here

enter image description here

You can see windows10 is installed in device sda with EFI partition on sda2. This is what controlling the grub now.

Important: this partition sda2 has UUID matched with the text in the file /etc/fstab on device sdb.

As we are going to format sda. We need to create EFI System Partition on sdb. sdb has only one partition sdb1. We have to create a EFI partition at start of the disk.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Now we got unallocated space of 100mb at start of disk sdb. In order to install grub on this we need it in FAT32 format with boot and esp flags.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Here if you observe, we have created 100mb EFI partition at the start of the disk. which should be named as sdb1. but gparted still shows it as sdb2. to sort out this
run sudo sgdisk -s /dev/sdb

enter image description here

Now delete the EFI partition (sda2) on sda or you can format entire device sda.

enter image description here

Now we need to install grub on /dev/sdb.

Procedure:

  1. sudo mount /dev/sdb2 /mnt # mounting root partition. (sdb2 is the ext4 /)
  2. for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
    (binding the required folders).
  3. sudo mount /dev/sdb1 /mnt/boot/efi # sdb1 is the EFI partition on sdb.
  4. sudo chroot /mnt
  5. update-grub
  6. grub-install /dev/sdb
  7. update-grub
  8. exit

Now we need to know the UUID of freshly created EFI Partition (sdb1) on device sdb.

Open "Disks" app.
Copy the UUID of sdb1.
Open the fstab file.
sudo nano /mnt/etc/fstab. (note: i have used gedit, attached pics are gedit in the below).
paste the UUID at the rite place.

Save and Close.

enter image description here

enter image description here

enter image description here

Now reboot.

enter image description here

Related Question