initrd to boot Linux from USB flash drives

AmigaOne X1000 platform specific issues related to Linux only.
Post Reply
User avatar
xeno74
Posts: 9348
Joined: Fri Mar 23, 2012 7:58 am

initrd to boot Linux from USB flash drives

Post 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
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.
User avatar
zappa2009
Posts: 230
Joined: Tue Jun 21, 2011 12:17 pm

Re: initrd to boot Linux from USB flash drives

Post 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"
 
X1000 RadeonHD5450 4GB (2x2GB) DDR2-PC2-8500 Kingston HyperX 5-5-5-5-15 OS4.1.6 & Lubuntu13.04/mintppc11 with Kernel 3.8.7/3.9
User avatar
xeno74
Posts: 9348
Joined: Fri Mar 23, 2012 7:58 am

Re: initrd to boot Linux from USB flash drives

Post by xeno74 »

Thanks a lot!
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.
User avatar
zappa2009
Posts: 230
Joined: Tue Jun 21, 2011 12:17 pm

Re: initrd to boot Linux from USB flash drives

Post 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.
X1000 RadeonHD5450 4GB (2x2GB) DDR2-PC2-8500 Kingston HyperX 5-5-5-5-15 OS4.1.6 & Lubuntu13.04/mintppc11 with Kernel 3.8.7/3.9
User avatar
xeno74
Posts: 9348
Joined: Fri Mar 23, 2012 7:58 am

Re: initrd to boot Linux from USB flash drives

Post 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! :-)
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.
Post Reply