2008-07-24

grub, xfs, debian

Running grub-install with a XFS partition will likely fail - there is a reason lilo is used when XFS is root! The issue is grub-install creates the stage files in /boot/grub, which grub then expects to find when it accesses the disk directly using its own file system drivers. For most file systems sync is sufficient to force this to be true, but not with XFS - unless grubs's XFS drivers replays the journal, grub won't find the files. The detailed why of this is covered in this thread. To get around this, one needs to effectively replace sync with mount -r -o remount /; mount -w -o remount /. A quick a nasty way to get grub going with XFS partition is as follows:




  • init 1 # need single user mode to be able to remount root

  • cp /usr/sbin/grub-install /tmp # make a copy of grub-install to butcher

  • vim /tmp/grub-install

  • # now butcher grub-install as follows:

  • # 1. find the line that says "Sync to prevent GRUB from not finding stage files

  • # 2. deleted everything after sync

  • # 3. add exit 0 after sync for good measures

  • /tmp/grub-install # invoke our amputated grub-install to just produce the stage files

  • mount -r -o remount / # flush everything by mount as read only

  • mount -w -o remount / # remount since grub needs it to be rw

  • grub # invoke the grub shell

  • root (hdx,y) # manually specify the disk x partition y where /boot/grub/* is located

  • setup (hdx) # install grub into the disk x's MBR. DO NOT specify a partition number, XFS's sector 0 is NOT reserved for boot loaders!!

  • quit # exit grub

  • reboot # should work now




Cheers,

Steve