Installing from USB Pendrive causes grub badness

Worth, Kevin kevin.worth at
Tue Nov 13 02:56:43 GMT 2007

I had a preseeded mini.iso set up and working just the way I wanted to. Then I found that I wanted to also make a version that could be installed from a USB pendrive using boot.img.gz (for systems without cd drives). I copied the necessary config lines from isolinux to syslinux, extracted the boot files, made my usb key bootable, etc.

When I boot the computer from the USB drive, the pendrive gets labeled /dev/sda (hard disk is /dev/sdb), but when I remove the usb pendrive and reboot, the hard disk is labeled /dev/sda!

This caused me a few problems:

1. I seem to need separate preseeds for CD and USB installation. The CD version installs Ubuntu to /dev/sda, and the USB version needs to install to /dev/sdb and has to do the two following workarounds:

2. By default Ubuntu appears to install GRUB onto the MBR of /dev/sda if left unspecified in the preseed. Going through it manually, it didn't seem to give me the option of where to install grub (other than "in the MBR", or "specify a partition"- maybe I needed to specify the MBR of sdb?). It was easy enough to change the preseed line to install grub to /dev/sdb for usb, given that I already seem to need two preseed files.

3. (the bigger problem, it seems) Although /etc/fstab and the kernel lines in /boot/grub/menu.lst's use the disk's UUID (thankfully), /boot/grub/menu.lst contains the line "root (hd1,0)" for each kernel entry. When we remove the USB disk and boot from the hard drive, the hd becomes (hd0,0) and grub will give me an "Error 21: file not found (or something lke that)". The only way I have been able to work around this is to add the following to my preseed
d-i preseed/late_command in-target cat /boot/grub/menu.lst | sed -e "s/hd1/hd0/" > /boot/grub/; mv /boot/grub/ /boot/grub/menu.lst

Doing the above seems to make it work, but if anyone can think of a better/smarter way to avoid any of the above issues, I would greatly appreciate it. My ideal situation is to have one preseed that works regardless of installation media type, but I am willing to maintain two preseed files if necessary. The sed command seems unclean and hopefully there is some better way to deal with this.

On a similar note, I went through the installation without a preseed, and I ended up with the system installed to the hard disk, but grub was installed to the MBR of my usb drive! Not a good thing for people who are new to this- then again, they might not be using a usb image to install ;)


-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Ubuntu-installer mailing list