I have a laptop hard drive in an external enclosure which I use as a large pendrive. For an added twist, I have installed Linux on it, so I can boot any machine with my distribution of choice (e.g. for data recovery or repairing a b0rked system or just using a borrowed laptop without destroying the preinstalled Windows). The problem is that, depending on the hardware configuration, the USB hard drive may be visible under different paths. For grub configuration I just use
(hda0,0) as it is relative to the device the grub was launched from. I have UUID entries in
/etc/fstab. I also specify
rootwait in the kernel parameters so that it waits for the USB subsystem to settle down before trying to mount the device.
What should I pass to the kernel as
root= ? Currently boot from the pendrive once, check the debug messages to see what
/dev/sdX device has been assigned to the USB drive by the kernel, then reboot and edit the grub configuration. I can't change anything on the PC besides enabling
Boot from USB hard drive in BIOS and setting it to higher priority than internal hard drives.
There are various initrd generating scripts which include support for UUID in root device path, unfortunately the Gentoo native one (genkernel) does not support
rootwait and I had no luck trying to use others.
The boot process goes like this (it is quite similar in Windows):
- The BIOS chooses the boot device and loads whatever is its MBR (which happens to be grub stage-1).
- Grub loads it's configuration and stage-2 files from device it has set as
(hd0)for the device it was loaded from by BIOS.
- Grub loads and starts a kernel (still the same numbering, so I can use
- Kernel initializes all built-in devices (
rootwaitdoes it's magic now).
- Kernel mounts the partition it was passed as
root(this is a kernel parameter, not grub parameter).
init.dstarts the userland booting process, including mounting things from
Part 5 is the one giving me problems.