<p>I recommend that you write it up as a blog post and additionally send a patch for the grub man page to your distro or upstream.</p>
<p>Onno Benschop, ITmaze</p>
<div class="gmail_quote">On 16/03/2012 7:41 PM, "Brad Campbell" <<a href="mailto:brad@fnarfbargle.com">brad@fnarfbargle.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
G'day all,<br>
<br>
I'm in the process of building a new server. It has 24 drive bays and a peculiarity of the system firmware appears to be when I add or remove drives, the boot drive moves around in the BIOS order. This means that grub2 can rarely (if ever) find the drive its modules are stored on as its root directory is hardcoded at install time. Why it can't find it is a mystery to me given its stage 1 just loaded stage 1.5 from the boot track, but never mind.<br>

<br>
After spending days fighting with this rotten thing booting of USB rescue disks to re-install grub, I stumbled across this little trick.<br>
<br>
grub2 can have a config file embedded in its core image. Now, as is typical, how you get it in there is not particularly obvious.<br>
<br>
Frustratingly grub-install has no way of letting you pass a config file to embed, however grub-mkimage does. grub-install has a way of letting you override which grub-mkimage it uses.<br>
<br>
I created 2 files.<br>
<br>
root@test:/root/grub2# cat grub.core.config<br>
search.fs_uuid root 29f53f33-f452-4382-b598-<u></u>ee307a65f360<br>
set prefix=($root)/grub<br>
<br>
root@test:/root/grub2# cat test<br>
#!/bin/sh<br>
<br>
grub-mkimage -c grub.core.config $@<br>
<br>
Then installed with<br>
grub-install --grub-mkimage=./test /dev/sde<br>
<br>
Bingo. Grub now has its uuid search algorithm embedded along with the config file and the first thing it does is search all accessible partitions for the uuid and uses that to access its files. I can happily rearrange disks with gay abandon and the system boots every time.<br>

<br>
Note I'm using a separate /boot partition that is plain ext2 and therefore the grub files are at /grub rather than /boot/grub.<br>
<br>
I wish this was documented somewhere obvious.<br>
<br>
Regards,<br>
Brad<br>
______________________________<u></u>_________________<br>
PLUG discussion list: <a href="mailto:plug@plug.org.au" target="_blank">plug@plug.org.au</a><br>
<a href="http://lists.plug.org.au/mailman/listinfo/plug" target="_blank">http://lists.plug.org.au/<u></u>mailman/listinfo/plug</a><br>
Committee e-mail: <a href="mailto:committee@plug.org.au" target="_blank">committee@plug.org.au</a><br>
PLUG Membership: <a href="http://www.plug.org.au/membership" target="_blank">http://www.plug.org.au/<u></u>membership</a><br>
</blockquote></div>