Page 1 of 1

initrd to boot Linux from USB flash drives

Posted: Thu Oct 29, 2015 10:56 pm
by xeno74
Hi All,

Stanglnator posted in the os4welt forum, that it is possible to boot a Linux distribution from a USB flash drive independent of the Linux device names like sdf1, sdg1 etc.

The problem is, that Linux doesn't always give the partitions on the USB flash drives the same device names. Sometimes the partition's name is sdf1 or sdg1 etc. Thereby it isn't possible to set up a CFE entry for a Linux distribution on a USB stick because of the changing partition names.

The solution is to use UUID (universally unique identifier). It can be used to identify a file system (partition) in a clearly independent form.

With cat /etc/fstab and ls -l /dev/disk/by-uuid you can figure out the UUID of the Linux partition.

You need an initial ramdisk (initrd) to boot a Linux system from a partition identify by UUID.

I created an initrd for the longterm kernel 4.1.12 yesterday.

Download: initrd.img-4.1.12

I will add an initrd to every new kernel. :-)

With the following commands you can boot the Linux system from a partition identify by UUID:
  1. Code: Select all

    CFE> ramdisk -z -addr=0x24000000 -fatfs cf0:initrd.img-4.1.12
  2. Code: Select all

    CFE> setenv bootargs "root=UUID=<a-very-large-number>"
    For example:

    Code: Select all

    CFE> setenv bootargs "root=UUID=2d781b26-0285-421a-b9d0-d4a0d3b55680"
  3. Code: Select all

    CFE> boot -elf -noints -fatfs cf0:vmlinux-4.1
Thanks to Stanglnator for this really interesting solution!

Cheers,

Christian

Re: initrd to boot Linux from USB flash drives

Posted: Fri Oct 30, 2015 1:10 am
by zappa2009
Nice.

An other Method is

Code: Select all

sudo blkid
It lists all Devices with an UUID and PARTUUID and FS-Type that will be found.

Code: Select all

e@e:~$ sudo blkid
/dev/sda1: UUID="9CEEA6B7EEA6895A" TYPE="ntfs" PARTUUID="000436df-01"
/dev/sda2: UUID="95a0507f-bcbe-4eaf-901f-5a687e97d5e6" TYPE="ext4" PARTUUID="000436df-02"
/dev/sda3: UUID="91ff2d24-d277-4ef0-b3e1-717f322386bc" TYPE="swap" PARTUUID="000436df-03"
/dev/sdb1: UUID="d5dffc46-e96f-43cf-8957-13d95873c49f" TYPE="ext4" PARTUUID="000d379a-01"
 

Re: initrd to boot Linux from USB flash drives

Posted: Fri Oct 30, 2015 7:19 am
by xeno74
Thanks a lot!

Re: initrd to boot Linux from USB flash drives

Posted: Fri Oct 30, 2015 11:38 pm
by zappa2009
Hi again.

with the initrd.img-4.1.12 you can use LABEL instead of UUID as bootargs for the Kernel.

Code: Select all

setenv bootargs "root=LABEL=fedora17"
In my case is this the LABEL of my fedora17 installation on a USB stick.
And I rename the /etc/fstab on the Linux from UUID to LABEL. On my Stick i do this

Code: Select all

LABEL=fedora17 /  ext4 defaults 1 1
You can set this with Gparted , just make sure the partition is umount. Can be done with a RMB on the Partition and select umount.

Re: initrd to boot Linux from USB flash drives

Posted: Sat Oct 31, 2015 6:27 am
by xeno74
zappa2009 wrote:Hi again.

with the initrd.img-4.1.12 you can use LABEL instead of UUID as bootargs for the Kernel.

Code: Select all

setenv bootargs "root=LABEL=fedora17"
In my case is this the LABEL of my fedora17 installation on a USB stick.
And I rename the /etc/fstab on the Linux from UUID to LABEL. On my Stick i do this

Code: Select all

LABEL=fedora17 /  ext4 defaults 1 1
You can set this with Gparted , just make sure the partition is umount. Can be done with a RMB on the Partition and select umount.
Fantastic! Thank you for the hint! :-)