# [SOLVED]Booting from USB without initramfs

## tert

I tried to setup gentoo to boot from a usb flash-drive and resulting with semi-success. This might be helpful for people trying to do similar setup without initramfs. 

Usually if gentoo is setup with a usb drive as with a hdd drive, there is a kernel panic because the kernel naively assumes that the root partition is readily usable when it is initiated which is not the case for usb drives. This can be solved by passing "rootwait" parameter to the kernel. As the name suggests, the kernel would then wait (indefinitely) for the root partition to be ready. Alternatively there is "rootdelay" but it requires some tweaking with the delay time and is therefore less applicable. 

For information about these parameters: https://www.kernel.org/doc/Documentation/kernel-parameters.txt

So pretty straightforward. Just pass the parameter through GRUB or any bootloader and as usual set the boot partition to sda* and it boots. 

Unless the usb drive got its name wrong... 

This happens if there is any other scsi device attached, usually a regular hard drive. It is likely to take over sda and the usb drive would be assigned to another name and kernel panic again. 

One simple solution is to not attach any other scsi device, which works well given the fact that any one booting from usb probably prefer to work with the usb for its flexibility or price advantage and so on. But avoiding the problem sounds little sub-optimal for a general setup, therefore the question: 

How to map a usb device to a specific device name? 

I had some preliminary clues for this one which involves udev rules, but just would like to check with the more knowledgeable before I tweak with my boot setup because when it fails, it's real pain.Last edited by tert on Sat Oct 10, 2020 5:45 am; edited 3 times in total

----------

## frostschutz

with GPT partition table, the kernel supports PARTUUID without initramfs...

----------

## mv

 *frostschutz wrote:*   

> with GPT partition table, the kernel supports PARTUUID without initramfs...

 

Even with MSDOS partition table, the kernel supports PARTUUID by some magic.

----------

## NeddySeagoon

tert,

Welcome to Gentoo.

In your opening post, you really mean root partition when you say  *Quote:*   

> Usually if gentoo is setup as with a hdd drive, there is a kernel panic because the kernel naively assumes that the boot partition is readily usable when it is initiated which is not the case for usb drives. 

 

You use the term root correctly elsewhere.

As others have said, root=PARTUUID= is the way to go on the kernel command line.

----------

## tert

Thanks for the replies!

Sorry for the typo, it's correct now. 

I will try the PARTUUID method and report back. I thought it was GPT only, but the kernel is evolving.

----------

## NeddySeagoon

tert,

With MSDOS disk lables PARTUUID has worked for some time

It uses the 32 bit Volume ID followed by a two digit partition number to form the PARTUUID.

For primary partitions -01 ... -04, this is stable enough.

For logical partitions, be very careful if you delete a partition with a lower number than your root partition.

Your root partition will get renumbered and your box won't boot.

Of course, this makes a mess of fstab too.  Its just one more thing to remember to fix.

----------

## tert

Works like magic!

There are instructions on: https://wiki.gentoo.org/wiki/GRUB

Need to improve my google skill. 

No recompiling the kernel, no woofy GPT, it just works. Now root simply shows up as /dev/root by kernel magic.

My only complain would be that grub2-mkconfig would insist on /dev/sd* scheme, so grub.cfg needs some tweaking. But I suppose that's expected.

----------

