I recently needed to configure a machine with multiple installations of Ubuntu Server 12.10. One way to go about doing this is to create a separate, small boot partition to store the configuration for an initial Grub boot menu. Each installed OS gets its own partition with its own bootloader configuration. The initial menu stored on the boot partition is used to chainload the bootloader files for whichever OS is selected.
This technique involves using Grub Legacy on the small boot partition to chainload to the Grub2 configuration on each of the OS partitions. I chose to go the route of installing Ubuntu (12.10 in my case) like normal, then removing Grub2, installing Grub Legacy temporarily, and finally reinstalling Grub2 again once the boot partition had been configured.
I ran into a couple of snags after getting to the Remove Grub 2 and install Grub Legacy part of the instructions, so I am going to duplicate the steps here and insert the couple of additional steps I ended up needing.
I used a different partition table, so the partitions in this version of the instructions will differ from the original. For reference:
Partition Size Type File system Flags /dev/sda1 100 MB primary ext3 boot /dev/sda2 4 GB primary ext4 /dev/sda3 4 GB primary ext4
1. Install Ubuntu on the First Application Partition
I used an Ubuntu Server 12.10 32-bit installer USB drive to boot the machine and followed the installation instructions to install Ubuntu Server on the
2. Backup the Grub2 Files, Uninstall Grub2, and Install Grub Legacy
sudo mv /boot/grub /boot/grub2backup sudo mkdir /boot/grub sudo apt-get remove --purge grub-pc grub-common sudo apt-get install grub sudo update-grub
When asked if you would like
/boot/grub/menu.lst generated for you, answer “y”.
The next step is something that I ended up needing to do, but it wasn’t in the documented steps.
sudo grub-install /dev/sda
Without this step there are no stage files for the
grub utility to find (needed in an upcoming step).
3. Copy Boot Files to the Small Grub Partition
sudo mkdir /media/GRUBpartition sudo mount /dev/sda1 -t ext3 /media/GRUBpartition sudo mkdir /media/GRUBpartition/boot sudo mkdir /media/GRUBpartition/boot/grub sudo chmod 777 /media/GRUBpartition/boot/grub sudo cp -r /boot/grub/* /media/GRUBpartition/boot/grub
Next edit the
menu.lst and add an entry for each partition that holds (or will hold) an OS.
sudo vim /media/GRUBpartition/boot/grub/menu.lst
## ## End Default Options ## title First Ubuntu OS (chainloader) rootnoverify (hd0,1) chainloader +1 title Second Ubuntu OS (chainloader) rootnoverify (hd0,2) chainloader +1
Be sure to note (as explained in the referenced instructions) that
(hd0,1) maps to
(hd0,2) maps to
Finally fix the permissions on the Grub partition.
sudo chmod 744 /media/GRUBpartition/boot/grub sudo chmod 744 /media/GRUBpartition/boot/grub/*
4. Reinstall Grub to MBR
Now that the Grub configuration files have been copied to the boot partition, you need to tell the Master Boot Record to look for the files there.
sudo grub grub> find /boot/grub/stage1 (hd0,0) (hd0,1) grub> root (hd0,0) grub> setup (hd0) grub> quit
Reinstall Grub2 in the OS Partition.
sudo mv /boot/grub /boot/grublegacybackup sudo apt-get remove --purge grub grub-common sudo apt-get install grub-pc
Be sure to check the box for the specific partition only, not for the entire drive. In my case this was
5. Display Grub2 Menu
At this point, you can reboot the machine, and you should see the Grub Legacy menu with the two options put in the
menu.lst file above. If you select the first option, the OS will boot straight away.
I had expected to see the Grub2 menu after making the selection on the Grub Legacy menu. Some searching showed that my expectation was not unwarranted (see the Chainloading GRUB2 from GRUB Legacy to test the setup section of this GRUB2 migration from GRUB Legacy page).
I eventually realized that the default Grub2 menu was configured to be hidden by default, and this applied even when the menu was chainloaded from a Grub Legacy menu. To change this, edit the
/etc/default/grub file and comment out the following line:
After saving the file, update the configuration: