Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a working setup of Ubuntu Server 12.04 LTS (precise) installed on a LVM Volume (/dev/vg0/root). /boot is on the same LV, and Grub2 boots nicely from it using its own raid/lvm/xfs modules. Great thing!

Now I would like to test Ubuntu Server 14.04 LTS (trusty) to evaluate if the more recent packages improve things in my setting. So what I do is simply create another LV, say /dev/vg0/root-trusty, and prepare it just the way I normally do when I do bare metal setups using debootstrap and chroot, installing kernel, grub-pc, etc.

Now I have two full-fledged root filesystems on my LVM, including two /boot directories and two differing /boot/grub/grub.cfg files. Please help me think: How does Grub know now which grub.cfg to use?

The only way that would make sense to me is that grub-install saves information about what the systemfrom which grub-install is run thinks is the correct root-fs. So switching between the two root-LVs for boot could be done by issuing grub-install from the respective (chrooted) filesystem and then reboot.

Is that so? If not, what else does Grub2 do when it "finds" multiple filesystems it could use to stage-2-boot from? I could not seem to find any hard information about that so far. So I thought I'd just ask before I invest the late evening hours in trial-and-error.

Thanks for any light shed on this!

PS: for clarity - I do NOT mean typical dual-booting using multiple OS entries in a single grub.cfg on a separate /boot partition. I know that, but here I sort of WANT to use concurrent Grub2-installations on separate partitions.

share|improve this question

2 Answers 2

I don't know if you can because even if you install grub to different HDs I think it still needs to be pointed to with the MBR. Though you could try installing grub A to sda and grub B to sdb and then just choosing which to boot from in the bios every time.

share|improve this answer

If you're looking at your grub2 configuration (use bootinfoscript for a quick summary), you'll notice that the first step in the boot process is to look at the MBR, and find an entry point from where to load the code needed to access all those mysterious filesystems a PC BIOS never dreamt of hearing about.

If you lack bootinfoscript, you probably want to fetch it ...

sudo apt-get install boot-info-script cl-awk 

Example output:

============================= Boot Info Summary: ===============================

 => Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector 1 of 
    the same hard drive for core.img. core.img is at this location and looks 
    for (tetrad-12.04)/boot/grub on this drive.
 [detailled per-partition output omitted]

There's a good article at the German wiki describing how to analyze a grub configuration.

For the first tests of your newly installed second boot partition, I'd suggest to leave your MBR unaltered (you did make a backup, in case the install botched it, didn't you?), boot into the old 12.04 partition after the install, run update-grub to include the new and shiny installation on the 14.04 partition into the menu, check /boot/grub/grub.cfg (the entry to 14.04 should point at the correct partition, not the 12.04 one, and probably use nomdmonddf nomdmonisw while you're still using 12.04 in parallel.

If you're able to reboot into 14.04 using this configuration, you can go ahead and run grub-install from your 14.04 partition to have it boot into 14.04 without the detour through 12.04.

Both root partitions will detect the other root partition during update-grub, and both are able to boot into the other partition through the menu generated, but it's the grub-install that determines which partition serves the /boot/grub/grub.cnf.

PS: I happened to just set up an environment like that to safely experiment with the release-upgrade from 12.04 to 14.04. (One lv each for 10.04, 12.04 and 14.04)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.