Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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):

  1. The BIOS chooses the boot device and loads whatever is its MBR (which happens to be grub stage-1).
  2. Grub loads it's configuration and stage-2 files from device it has set as root, using (hd0) for the device it was loaded from by BIOS.
  3. Grub loads and starts a kernel (still the same numbering, so I can use (hd0,0) again ).
  4. Kernel initializes all built-in devices (rootwait does it's magic now).
  5. Kernel mounts the partition it was passed as root (this is a kernel parameter, not grub parameter).
  6. init.d starts the userland booting process, including mounting things from /etc/fstab.

Part 5 is the one giving me problems.

share|improve this question
add comment

migrated from stackoverflow.com Nov 25 '11 at 11:37

This question came from our site for professional and enthusiast programmers.

3 Answers

I think the answer should be to use either root=LABEL=... or root=UUID=...

But you indicate that this doesn't work for you. I would suggest looking into if there is some problem with the actions of your initrd.

share|improve this answer
    
I don't have an initrd, that's the whole problem. genkernel does not support "rootwait" option, and other do not work with Gentoo. –  skolima Oct 6 '08 at 13:29
add comment

I could be mistaken or possibly just misunderstanding you, but isn't choice of boot device something that would be configured from the BIOS of the machine you're booting?

I would think it would be a matter of choosing the USB drive, which would have GRUB installed as its bootloader, and then choosing which distro you want to boot from the GRUB menu.

share|improve this answer
add comment

You can use:

set root='(hd0,msdos5)'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.