[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how does update-grub choose the root filesystem



On Fri, Jul 6, 2012 at 2:24 AM, Alan Chandler <alan@chandlerfamily.org.uk>
wrote:
> On 05/07/12 23:10, Tom H wrote:
>> On Wed, Jul 4, 2012 at 7:22 PM, Alan Chandler
>> <alan@chandlerfamily.org.uk> wrote:
>>>
>>> I am trying to figure out how to move my current rootfs to raid1 (its
>>> just a partition at the moment).
>>>
>>> The plan is to make a a raid device, copy the current root fs in to it -
>>> but I then need to tell grub to set up this up as the root for the boot.
>>
>> grub-install /dev/sdX
>
> Reading the man page for this doesn't say how it finds out where the root
> filesystem is. Thats the bit that is confusing me.
>
> I currently have a root filesystem on /dev/sdb1. I am not sure which disk
> contains the mbr - but it boots and then loads the root from there.
>
> I have created a partially degraded mdadm raid array /dev/md0 comprising
> /dev/sda1 and an empty slot. My desire is to install grub on both /dev/sda
> and /dev/sdb to boot up from /dev/md0. When that is working I will retire
> /dev/sdb1 and add it as the second component of /dev/md0.
>
> The magic appears to be in grub-mkconfig (wrapped with update-grub). But I
> am also confused as to whether I need to do anything about an initramfs.

"grub-install /dev/sdX" uses grub-probe to find "/" and "/boot".

"grub-install /dev/sdX" installs grub in the MBR of sdX and
"grub-install -f /dev/sdXY" installs grub in the PBR of of sdXY. The
latter's not recommended in general and isn't necessarily possible
when using mdraid.

You have to install grub in the MBR of both drives in order to be able
to boot from a degraded array.

>From a system of mine:

 => Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector 34
    of the same hard drive for core.img. core.img is at this location and
    looks for (mduuid/801256bc800752eab5118583d15c4689)/boot/grub on this
    drive.
 => Grub2 (v1.99) is installed in the MBR of /dev/sdb and looks at sector 34
    of the same hard drive for core.img. core.img is at this location and
    looks for (mduuid/801256bc800752eab5118583d15c4689)/boot/grub on this
    drive.

update-grub calls "grub-mkconfig -o /boot/grub/grub.cfg" and creates
the grub menu configuration. It doesn't install grub on a disk.

You shouldn't have to worry about the initramfs. It's built with md
scripts and hooks in "/usr/share/initramfs-tools". You can check that
it's been done with "lsinitramfs /boot/<INITRAMFS> | grep md | grep -v
modules".


Reply to: