I'm installing ubuntu on my computer at the office. Since I never installed ubuntu alongside with an existing windows on a UEFI system, I want to avoid all possible problems. I already read all the available documentation but still have a short question. In my computer I have two SSDs, one for windows 7, the other will be entirely dedicated to ubuntu. If I want to be sure to be able to get back to the initial state, can I just create a new EFI partition on the second disk and set this disk as boot priority? Will then be windows 7 automatically found by GRUB? And, if I'm running into problems, can I just switch boot priority in my setup and I will boot windows?
1 Answer
The last I heard, there was a bug in the Ubuntu installer that caused it to always place GRUB on the EFI System Partition (ESP) on the first disk (usually /dev/sda
), even if you tried to force it onto another ESP (say, one on /dev/sdb
). This fact can make separating your Windows and Ubuntu installations a little trickier than you might like. Also, the way Ubuntu configures GRUB, it's reliant on both files on the ESP and a grub.cfg
configuration file in the Ubuntu /boot/grub
directory, which is not on the ESP. Thus, if you install Ubuntu and then delete it by deleting the Ubuntu partition(s), GRUB will remain behind, but with its grub.cfg
file gone, the computer will hang at a grub>
prompt when you boot. This problem can be overcome by manually deleting the GRUB files from the ESP or by tweaking the boot order using efibootmgr
in Ubuntu or EasyUEFI in Windows before deleting the Ubuntu partitions.
Alternatively, you could follow this procedure to install Ubuntu:
- Download the USB flash drive or CD-R version of my rEFInd boot manager.
- Write the rEFInd image to a USB flash drive or CD-R, as appropriate.
- Boot the Ubuntu installer in its "try before installing" mode. This results in a normal Ubuntu desktop.
- Open a Terminal window.
- Type
ubiquity -b
. This launches the installer, but the-b
option tells it to not install GRUB. - In the installer (or before you run the installer, if you prefer), set up your partitions, and be sure to include an ESP on the second disk (the one to which you're installing Ubuntu).
- When you're done with the installation, reboot using the rEFInd disk. You should see the rEFInd menu appear. (A caveat: The rEFInd disk images I distribute do not support Secure Boot. Thus, if Secure Boot is active, you'll need to either disable it or modify the rEFInd image to include Shim. You can re-enable Secure Boot later, but you may need to jump through some extra hoops at that time. Windows 7 does not support Secure Boot, so you shouldn't run into this problem. I mention it in case somebody wants to do something similar with a Windows 8 or later installation.)
- Using the rEFInd menu, boot Ubuntu. (A caveat: If you use a separate
/boot
partition, you'll need to hit F2 or Insert twice and add aro root={rootfs}
option, where{rootfs}
is a pointer to the root (/
) filesystem, such as/dev/mapper/lvm-root
. This is normally only necessary if you use LVM or software RAID.) - In Ubuntu, check and, if necessary, alter
/etc/fstab
so that it mounts the ESP in Ubuntu's directory tree at/boot/efi
. If you need to change this detail, be sure to unmount anything that's already mounted there and mount the Ubuntu disk's ESP at/boot/efi
before proceeding. - Install your preferred boot loader.
- If you want to use GRUB 2, install the
grub-efi
package. You may also need to runsudo grub-install
and/orsudo update-grub
. - If you want to use rEFInd, install the rEFInd Debian package or PPA. If you're asked if you want to copy rEFInd to the ESP, be sure to respond affirmatively.
- If you want to use GRUB 2, install the
At this point, when you reboot you should see GRUB or rEFInd appear and you should be able to boot either Windows or Ubuntu. If you want to go back to a stock factory installation, you can wipe all the partitions from the Ubuntu disk, including the ESP, and the computer should skip over the now-invalid entry for GRUB or rEFInd and go straight to booting Windows. (If you use rEFInd, it should continue booting Windows even if you delete all the Ubuntu partitions but leave the ESP on which rEFInd resides intact.)
sudo update-grub
.