Creating by hand EFI multiboot live USB key

Motivations

During the project "Tremplin des sciences" we deployed RaspberryPi nano computers and weatherstations in lower secondary schools of Lyon area we faced many problems due to low compentencies and knowledge of the linux ecosystem. We needed an easy way to boot a linux OS on any computer to interact easily with the RaspberryPi or check their microSD condition. In another side of my life I am contributing to install parties with colleagues and it is usefull and efficient to be able to demonstrate the differences between various linux distributions, display managers and window managers.

In both cases we need an USB EFI multiboot linux live key, here is the way to produce "by hand" such a key. I have choosen to produce this key step by step and not relying on various "automatic tools" because I feel that they often do what they believe is good for me instead of what I want to get, you will find many user friendly tutorials with such tools on the web but if you want o master the process keep on reading !


Table of contents

  1. What we have obtained
  2. Setting up the USB key
  3. Making USB key bootable with rEFInd
  4. Adding live images in Partitions

Downloads

  1. rEFInd binaries
  2. rEFInd bootable image
  3. Debian buster
  4. Debian bullseye
  5. ubuntu
  6. linux Mint
  7. Manjaro

1. What we have obtained

The following image is a picture of the laptop screen when booted on the external USB key. The following images and tools are available :

  • debian-gnome stable (buster) live
  • debian-gnome testing (bullseye) live
  • linuxMint 19.3-cinnamon live
  • ubuntu-19.10-desktop live
  • manjaro-gnome-19.0.2 live
  • information on rEFInd
  • EFI shell
  • rEFInd boot menu order
  • rEFInd installer
  • shutdown
  • reboot
  • setup

Écran de boot

2. Setting up the USB key

We need a bootable USB key, we will prepare an UEFI 64bit only key that will be used with EFI capable computers only ; if you need legacy boot with BIOS see this tutorial.

2.1 Creating partitions

The number of operating systems that can be installed depends on the size of the key. Live images are around 3 Gb each, to be prepared to any possible evolution we decided to build partitions of 5Gb plus an EFI partition of 100Mb. We built 5 partitions for distributions, one EFI partition and a partition to have persistence for some of the linuxes.

To create partitions we used gdisk on a clean USB key. Everything is erased on the key during this operation, be sure to make copies of the files you want to keep before starting the procedure. On our computer the USB key got mounted on /dev/sdg it might be on any value /dev/sdb, /dev/sdc, /dev/sdd, depending on your computer configuration. In the following lines we will use sdX to avoid any mistake by copy/paste operation. The partition number will be added after the X

sudo gdisk /dev/sdX
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present

# Create GPT partition table
Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y

# Create EFI partition
Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-30277598, default = 4096) or {+-}size{KMGTP}:     
Last sector (4096-30277598, default = 30277598) or {+-}size{KMGTP}: +100M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef00
Changed type of partition to 'EFI System'

# Create microsoft partition (one for each distribution according to the room on the key)
Command (? for help): n
Partition number (2-128, default 2): 
First sector (34-30277598, default = 106496) or {+-}size{KMGTP}: 
Last sector (106496-30277598, default = 30277598) or {+-}size{KMGTP}: +5Gb
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 0700 
Changed type of partition to 'Microsoft basic data'

# Create ext4 partition for persistence
Command (? for help): n
Partition number (7-128, default 7): 
First sector (34-30277598, default = 8495104) or {+-}size{KMGTP}: 
Last sector (8495104-30277598, default = 30277598) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Écriture de la table de partitions
Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdX.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

2. Checking and formatting partitons

To check the structure and format the partitions use gparted

sudo gparted

Format the 6 first partitions in FAT32 and the last one in EXT4, provide labels for the 5 partitions that will receive live images, in our example we have choosen :

* Buster
* BullsEye
* Linux Mint
* Ubuntu
* MANJARO_GNOME_1902

We have now the necessary structure for our multiboot key.

lsblk --output PARTUUID,PARTLABEL,UUID,LABEL 
PARTUUID                             PARTLABEL            UUID                                 LABEL
83da42b5-2c6c-4c9d-b3a4-xxxxxxxxxxxx EFI system partition B457-####                            
bfb2657a-1896-4783-a8fe-xxxxxxxxxxxx Buster               B475-####                            
e9bf2b1c-3f61-4782-b3b7-xxxxxxxxxxxx BullsEye             B150-####                            
1cea8369-cfb4-4037-aafd-xxxxxxxxxxxx Linux Mint           B19E-####                            
b2d19cbb-0a61-4ca3-8f36-xxxxxxxxxxxx Ubuntu               B1FF-####                            
defd3564-5dfa-4815-8225-xxxxxxxxxxxx MANJARO_GNOME_1902   9A8A-####                            
43c9e2f0-8e61-4e14-8b23-xxxxxxxxxxxx Linux ext4           6e02ec56-6026-4328-8756-############ 

3. Making USB key bootable with rEFInd

To get all the capabilities we need on our key we will download two files from rEFInd website :

sudo mkdir Refind
cd Refind
http://sourceforge.net/projects/refind/files/0.12.0/refind-bin-0.12.0.zip/download
http://sourceforge.net/projects/refind/files/0.12.0/refind-flashdrive-0.12.0.zip/download
unzip refind-flashdrive-0.12.0.zip
unzip refind-bin-0.12.0.zip
sudo gparted

We are going to use files from refind-bin-0.12.0/refind/drivers_x64/ which provide the necessary drivers

ls -1 refind-bin-0.12.0/refind/drivers_x64/
btrfs_x64.efi
ext2_x64.efi
ext4_x64.efi
hfs_x64.efi
iso9660_x64.efi
LICENSE_GPL.txt
LICENSE.txt
reiserfs_x64.efi

and files from the image from inside refind-flashdrive-0.12.0 :

 7z l refind-flashdrive-0.12.0/refind-flashdrive-0.12.0.img

.../...
   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2020-03-13 09:34:44 D....                            EFI
2020-03-13 09:34:44 D....                            EFI/boot
2020-03-13 09:34:44 D....                            EFI/tools
2020-03-13 09:34:44 ....A        32056        32768  EFI/boot/refind.conf
2020-03-13 09:34:44 D....                            EFI/boot/drivers_x64
2020-03-13 09:34:44 D....                            EFI/boot/drivers_aa64
2020-03-13 09:34:44 D....                            EFI/boot/icons
2020-03-13 09:34:44 ....A        31891        32768  EFI/boot/refind.conf-sample
2020-03-13 09:34:44 D....                            EFI/boot/drivers_ia32
2020-03-13 09:34:44 ....A       212736       212992  EFI/boot/bootaa64.efi
2020-03-13 09:34:44 ....A       211776       212992  EFI/boot/bootia32.efi
2020-03-13 09:34:44 ....A       219720       221184  EFI/boot/bootx64.efi
2020-03-13 09:34:44 ....A        63304        63488  EFI/boot/drivers_x64/btrfs_x64.efi
2020-03-13 09:34:44 ....A        24072        24576  EFI/boot/drivers_x64/hfs_x64.efi
2020-03-13 09:34:44 ....A        22280        22528  EFI/boot/drivers_x64/ext2_x64.efi
2020-03-13 09:34:44 ....A        21832        22528  EFI/boot/drivers_x64/iso9660_x64.efi
2020-03-13 09:34:44 ....A        24904        26624  EFI/boot/drivers_x64/reiserfs_x64.efi
2020-03-13 09:34:44 ....A        17992        18432  EFI/boot/drivers_x64/LICENSE_GPL.txt
2020-03-13 09:34:44 ....A         2094         4096  EFI/boot/drivers_x64/LICENSE.txt
2020-03-13 09:34:44 ....A        22792        24576  EFI/boot/drivers_x64/ext4_x64.efi
2020-03-13 09:34:44 ....A        23136        24576  EFI/boot/drivers_aa64/hfs_aa64.efi
2020-03-13 09:34:44 ....A        60800        61440  EFI/boot/drivers_aa64/btrfs_aa64.efi
2020-03-13 09:34:44 ....A        21696        22528  EFI/boot/drivers_aa64/ext2_aa64.efi
2020-03-13 09:34:44 ....A        24064        24576  EFI/boot/drivers_aa64/reiserfs_aa64.efi
2020-03-13 09:34:44 ....A        17992        18432  EFI/boot/drivers_aa64/LICENSE_GPL.txt
2020-03-13 09:34:44 ....A         2094         4096  EFI/boot/drivers_aa64/LICENSE.txt
2020-03-13 09:34:44 ....A        22240        22528  EFI/boot/drivers_aa64/ext4_aa64.efi
2020-03-13 09:34:44 ....A        20928        22528  EFI/boot/drivers_aa64/iso9660_aa64.efi
2020-03-13 09:34:44 ....A        11658        12288  EFI/boot/icons/os_frugalware.png
2020-03-13 09:34:44 ....A         6192         8192  EFI/boot/icons/os_artful.png
2020-03-13 09:34:44 ....A         1418         2048  EFI/boot/icons/vol_internal.png
2020-03-13 09:34:44 ....A         2479         4096  EFI/boot/icons/func_about.png
2020-03-13 09:34:44 ....A        13776        14336  EFI/boot/icons/os_chakra.png
2020-03-13 09:34:44 ....A         9754        10240  EFI/boot/icons/os_void.png
2020-03-13 09:34:44 ....A        15008        16384  EFI/boot/icons/os_centos.png
2020-03-13 09:34:44 ....A         3446         4096  EFI/boot/icons/tool_part.png
2020-03-13 09:34:44 ....A         3018         4096  EFI/boot/icons/tool_memtest.png
2020-03-13 09:34:44 ....A         3872         4096  EFI/boot/icons/os_win8.png
2020-03-13 09:34:44 ....A        10391        12288  EFI/boot/icons/os_chrome.png
2020-03-13 09:34:44 ....A        12854        14336  EFI/boot/icons/os_mandriva.png
2020-03-13 09:34:44 ....A         5555         6144  EFI/boot/icons/os_arch.png
2020-03-13 09:34:44 ....A        10097        10240  EFI/boot/icons/os_linux.png
2020-03-13 09:34:44 ....A         5980         6144  EFI/boot/icons/os_freebsd.png
2020-03-13 09:34:44 ....A         7229         8192  EFI/boot/icons/os_clover.png
2020-03-13 09:34:44 ....A        10574        12288  EFI/boot/icons/os_mac.png
2020-03-13 09:34:44 ....A         3772         4096  EFI/boot/icons/func_firmware.png
2020-03-13 09:34:44 ....A         1761         2048  EFI/boot/icons/func_csr_rotate.png
2020-03-13 09:34:44 ....A         8480        10240  EFI/boot/icons/os_crunchbang.png
2020-03-13 09:34:44 ....A         8763        10240  EFI/boot/icons/os_fedora.png
2020-03-13 09:34:44 ....A        11686        12288  EFI/boot/icons/os_unknown.png
2020-03-13 09:34:44 ....A         5072         6144  EFI/boot/icons/os_devuan.png
2020-03-13 09:34:44 ....A        12270        12288  EFI/boot/icons/os_ubuntu.png
2020-03-13 09:34:44 ....A         2208         4096  EFI/boot/icons/func_exit.png
2020-03-13 09:34:44 ....A         1346         2048  EFI/boot/icons/arrow_right.png
2020-03-13 09:34:44 ....A         3785         4096  EFI/boot/icons/tool_netboot.png
2020-03-13 09:34:44 ....A        13817        14336  EFI/boot/icons/tool_rescue.png
2020-03-13 09:34:44 ....A        10041        10240  EFI/boot/icons/os_redhat.png
2020-03-13 09:34:44 ....A         4313         6144  EFI/boot/icons/tool_windows_rescue.png
2020-03-13 09:34:44 ....A         9202        10240  EFI/boot/icons/os_slackware.png
2020-03-13 09:34:44 ....A        14836        16384  EFI/boot/icons/os_network.png
2020-03-13 09:34:44 ....A         9025        10240  EFI/boot/icons/os_xenial.png
2020-03-13 09:34:44 ....A        14608        16384  EFI/boot/icons/os_trusty.png
2020-03-13 09:34:44 ....A         7231         8192  EFI/boot/icons/os_refind.png
2020-03-13 09:34:44 ....A         7668         8192  EFI/boot/icons/os_systemd.png
2020-03-13 09:34:44 ....A         5620         6144  EFI/boot/icons/os_legacy.png
2020-03-13 09:34:44 ....A        14399        16384  EFI/boot/icons/os_hwtest.png
2020-03-13 09:34:44 ....A         2423         4096  EFI/boot/icons/vol_optical.png
2020-03-13 09:34:44 ....A         4507         6144  EFI/boot/icons/tool_apple_rescue.png
2020-03-13 09:34:44 ....A         2010         2048  EFI/boot/icons/tool_shell.png
2020-03-13 09:34:44 ....A         4398         6144  EFI/boot/icons/func_install.png
2020-03-13 09:34:44 ....A         5177         6144  EFI/boot/icons/tool_fwupdate.png
2020-03-13 09:34:44 ....A         4846         6144  EFI/boot/icons/mouse.png
2020-03-13 09:34:44 ....A        10547        12288  EFI/boot/icons/os_xubuntu.png
2020-03-13 09:34:44 ....A         9377        10240  EFI/boot/icons/os_debian.png
2020-03-13 09:34:44 ....A         6246         8192  EFI/boot/icons/os_linuxmint.png
2020-03-13 09:34:44 ....A        12873        14336  EFI/boot/icons/os_kubuntu.png
2020-03-13 09:34:44 ....A         1974         2048  EFI/boot/icons/tool_mok_tool.png
2020-03-13 09:34:44 ....A        12379        14336  EFI/boot/icons/os_netbsd.png
2020-03-13 09:34:44 ....A         1892         2048  EFI/boot/icons/vol_net.png
2020-03-13 09:34:44 ....A         5830         6144  EFI/boot/icons/os_haiku.png
2020-03-13 09:34:44 ....A         8484        10240  EFI/boot/icons/os_refit.png
2020-03-13 09:34:44 ....A         1344         2048  EFI/boot/icons/vol_external.png
2020-03-13 09:34:44 ....A         2760         4096  EFI/boot/icons/func_shutdown.png
2020-03-13 09:34:44 ....A         6096         6144  EFI/boot/icons/README
2020-03-13 09:34:44 ....A         6572         8192  EFI/boot/icons/os_opensuse.png
2020-03-13 09:34:44 ....A         6565         8192  EFI/boot/icons/os_win.png
2020-03-13 09:34:44 ....A         2602         4096  EFI/boot/icons/func_reset.png
2020-03-13 09:34:44 ....A         1392         2048  EFI/boot/icons/arrow_left.png
2020-03-13 09:34:44 ....A         7549         8192  EFI/boot/icons/os_gentoo.png
2020-03-13 09:34:44 ....A         5371         6144  EFI/boot/icons/os_zesty.png
2020-03-13 09:34:44 ....A        16482        18432  EFI/boot/icons/os_elementary.png
2020-03-13 09:34:44 ....A         6572         8192  EFI/boot/icons/os_suse.png
2020-03-13 09:34:44 ....A         6958         8192  EFI/boot/icons/os_bionic.png
2020-03-13 09:34:44 ....A         7783         8192  EFI/boot/icons/os_mageia.png
2020-03-13 09:34:44 ....A        11232        12288  EFI/boot/icons/os_lubuntu.png
2020-03-13 09:34:44 ....A         3766         4096  EFI/boot/icons/boot_win.png
2020-03-13 09:34:44 ....A         9077        10240  EFI/boot/icons/boot_linux.png
2020-03-13 09:34:44 ....A         6930         8192  EFI/boot/icons/func_bootorder.png
2020-03-13 09:34:44 ....A          213         2048  EFI/boot/icons/transparent.png
2020-03-13 09:34:44 ....A         7161         8192  EFI/boot/icons/func_hidden.png
2020-03-13 09:34:44 ....A         7668         8192  EFI/boot/icons/os_gummiboot.png
2020-03-13 09:34:44 ....A        58112        59392  EFI/boot/drivers_ia32/btrfs_ia32.efi
2020-03-13 09:34:44 ....A        21760        22528  EFI/boot/drivers_ia32/reiserfs_ia32.efi
2020-03-13 09:34:44 ....A        21312        22528  EFI/boot/drivers_ia32/hfs_ia32.efi
2020-03-13 09:34:44 ....A        17992        18432  EFI/boot/drivers_ia32/LICENSE_GPL.txt
2020-03-13 09:34:44 ....A         2094         4096  EFI/boot/drivers_ia32/LICENSE.txt
2020-03-13 09:34:44 ....A        19520        20480  EFI/boot/drivers_ia32/ext4_ia32.efi
2020-03-13 09:34:44 ....A        19008        20480  EFI/boot/drivers_ia32/ext2_ia32.efi
2020-03-13 09:34:44 ....A        18560        20480  EFI/boot/drivers_ia32/iso9660_ia32.efi
2020-03-13 09:34:44 ....A       792064       792576  EFI/tools/gdisk_x64.efi
2020-03-13 09:34:44 ....A        29120        30720  EFI/tools/gptsync_ia32.efi
2020-03-13 09:34:44 ....A       922272       923648  EFI/tools/shellx64.efi
2020-03-13 09:34:44 ....A       810496       811008  EFI/tools/shellia32.efi
2020-03-13 09:34:44 ....A        31688        32768  EFI/tools/gptsync_x64.efi
 7z x refind-flashdrive-0.12.0/refind-flashdrive-0.12.0.img

Create temporary folders to mount the partitions of the USB key

for i in 2 3 4 5 6 7; do sudo mkdir /mnt/disk$i; done

3.1 Creating and filling folders in EFI partition

mount EFI partition on /mnt/disk1 then create folders to host rEFInd

sudo mount /dev/sdX1 /mnt/disk1
cd /mnt/disk1
sudo mkdir -p EFI/BOOT EFI/TOOLS

We use upper case to keep in mind that EFI is a DOS like environment folder names do not make difference between lower and upper case

Fill the folders with the appropriate data

cd Refind 
cp refind-flashdrive-0.12.0/EFI/tools/*x64.efi /mnt/disk1/EFI/TOOLS
cp -r refind-bin-0.12.0/refind/drivers_x64 /mnt/disk1/EFI/BOOT
cp -r refind-bin-0.12.0/refind/icons  /mnt/disk1/EFI/BOOT
cp refind-bin-0.12.0/refind/refind.conf-sample  /mnt/disk1/EFI/BOOT
cp refind-bin-0.12.0/refind/refind.conf-sample  /mnt/disk1/EFI/BOOT/refind.conf
cp refind-bin-0.12.0/refind/refind_x64.efi /mnt/disk1/EFI/BOOT/bootx64.efi

The USB keyis now ready to boot but to get a multiboot key we have to configure rEFInd and provide live linux images.

3.2 Configuring rEFInd

To configure rEFInd we need to provide Ad-Hoc parameters in refind.conf configuration file to enable bootx64.efi find all the linux loaders we want to use. The following configuration file is an example corresponding to our situation; you will have to change the configuration according to the number and names of distributions. We have been able to install : * debian buster * debian bullseye * ubuntu * linuxMint * Manjaro (with a trick)

We could not install mageia.

We keep a timeout that enable an automatic boot with the first bootloader debian buster in thiscase, we enable the mouse driver but it may not work in some computers in that case use the arrows to navigate between the possible choices the tabkey displays the possible option if some exists.Scanning "manual" enables to choose only the bootloaders choosen and not scan automatically all disks for bootloaders. The following option extra_kernel_version_strings linux-lts,linux enables to use distributions that do not use standard names for loader and initrd.

There is a menuentry for each linux distribution, we have choosen here to use the PARTUUID value to identify the partitions except for Manjaro (we will explain later why). There are many possible ways to load linux with rEFInd we ha choosen here to call the ordinary execution of grub loader for all the distributions of the debian family. To get a successfull boot we need to identify : * the parition on which the destribution has been copied * the path to the grubx64.efi executable delivered with the live distribution

The other parameters are just for decoration and comfort. The icon displayed on the rEFInd homepage is copied from the EFI partition on the linux live partition

Here is the refind.conf file which has been tested :

#
timeout 20
#
enable_mouse
#showtools shell, bootorder, gdisk, memtest, mok_tool, apple_recovery, windows_recovery, about, hidden_tags, reboot, exit,$
showtools install,bootorder,shell,memtest,gdisk,csr_rotate,mok_tool,about,shutdown,reboot,firmware
#scanfor internal,external,optical,manual
scanfor manual
#
extra_kernel_version_strings linux-lts,linux

menuentry Buster {
  icon EFI/BOOT/ICONS/os_debian.png
  volume 71d20d83-e01f-4f37-959f-b1b8b2bc26fa
  loader live/vmlinuz-4.19.0-8-amd64
  initrd live/initrd.img-4.19.0-8-amd64
  options "boot=live components splash quiet root=UUID=26FD-DD07 "
  submenuentry "Debian Live with French (fr) Support" {
    add_options "locales=fr_FR.UTF-8"
  }
  submenuentry "Installeur graphique debian" {
    linux  d-i/gtk/vmlinuz
    options "append video=vesa:ywrap,mtrr vga=788 root=UUID=26FD-DD07"
    initrd d-i/gtk/initrd.gz
  }
}

menuentry BullsEye {
  icon EFI/BOOT/ICONS/os_linux.png
  volume d22826a0-e155-4be2-b5d0-61967f4f981a
  loader live/vmlinuz-5.4.0-4-amd64
  initrd live/initrd.img-5.4.0-4-amd64
  options "boot=live components splash quiet root=UUID=2791-4B99 "
  submenuentry "Debian Live with French (fr) Support" {
    add_options "locales=fr_FR.UTF-8"
  }
  submenuentry "Installeur graphique debian" {
    linux  d-i/gtk/vmlinuz
    options "append video=vesa:ywrap,mtrr vga=788 root=UUID=2791-4B99"
    initrd d-i/gtk/initrd.gz
  }
}

menuentry "Linux Mint" {
  icon EFI/BOOT/ICONS/os_linuxmint.png
    loader casper/vmlinuz
  initrd casper/initrd.lz
  options "file=/preseed/linuxmint.seed boot=casper root=UUID=2818-92F0 quiet splash --"
}

menuentry ubuntu {
  icon EFI/BOOT/ICONS/os_ubuntu.png
  volume d23ca824-656e-4fcd-bc99-8ca2a0e83e33
  loader EFI/BOOT/ubuntu-grubx64.efi
}

menuentry manjaro {
  icon EFI/BOOT/ICONS/os_arch.png
  volume befa90d8-cce5-476a-8bc1-8c825d57d6e2
  loader boot/vmlinuz-x86_64
  initrd boot/initramfs-x86_64.img
    options "misobasedir=manjaro misolabel=../by-partlabel/MANJARO_GNOME_1902 root=MANJARO_GNOME_1902  rw"
}

4. Adding live images in Partitions

Last step is to copy on the USB key the live distributions we have choosen and prepared in the refind.conffile. We suppose al the live distributions you want to use have been dowloaded; for us we have the following images located at /date/IsoImages :

vidal[~] Cerf-Volant.€ : ls -1 /data/IsoImages/
debian-live-10.3.0-amd64-gnome+nonfree.iso
debian-live-testing-amd64-gnome+nonfree.iso
linuxmint-19.3-cinnamon-64bit.iso
manjaro-gnome-19.0.2-200312-linux54.iso
ubuntu-19.10-desktop-amd64.iso

Each of these images will be copied on the USB key partitions /dev/sdX2, /dev/sdX3, /dev/sdX4, /dev/sdX5, /dev/sdX6. The situation is different for distributions of the debian family and others. We did not succed to add a Mageia distribution and used a dirty trick to force Manjaro in.

4.1 Dealing with the debian family

As we have seen previously in the configuration file we use the default grub loader for all the debian family images, we just have to copy the iso image contents on the choosen partition. For Buster image we have created the partition with the following parameters :

PARTUUID                             PARTLABEL            UUID
bfb2657a-1896-4783-a8fe-xxxxxxxxxxxx Buster               B475-####

By default on a debian system it is mounted on /media/user/B475-#### you may use this value or mount it on the hook you prepared at the beginning

sudo umount /dev/sdx2 
sudo mount /dev/sdx2  /mnt/disk2

It is possible to mount all the 5 partitions at once :

for i in 2 3 4 5 6 ; do sudo umount /dev/sdg$i; sudo mount /dev/sdg$i /mnt/disk$i; done
sudo 7z x /data/IsoImages/debian-live-10.3.0-amd64-gnome+nonfree.iso -o/mnt/disk2
sudo 7z x /data/IsoImages/debian-live-testing-amd64-gnome+nonfree.iso -o/mnt/disk3
sudo 7z x /data/IsoImages/linuxmint-19.3-cinnamon-64bit.iso -o/mnt/disk4
sudo 7z x /data/IsoImages/ubuntu-19.10-desktop-amd64.iso -o/mnt/disk5

Check that after uncompressing and copying the images the efi grub executables are in the correct folder : * debian buster -> /mnt/disk2/EFI/boot/grubx64.efi * debian bullseye -> /mnt/disk3/EFI/boot/grubx64.efi * ubuntu -> /mnt/disk4/EFI/BOOT/grubx64.efi * linuxMint -> /mnt/disk5/EFI/BOOT/grubx64.efi

The four images belonging to the debian family are ready to boot from rEFInd

4.2 Handling Manjaro case

"Manjaro" is said to be an "easy to use" linux Arch version, the boot process differs from debian; we load directly the vmlinuz and use the initramfsfrom the distribution. The name of the rootfs is retrieved from options and by default the loader looks for it using by-labelmethod that is not applicable in our situation because we have partlabelvalue and not labelvalue. To work around this problem we used a trick in the refind.conf file passing the partlabelin the options with its relative path to the label folder :

options "misobasedir=manjaro misolabel=../by-partlabel/MANJARO_GNOME_1902 root=MANJARO_GNOME_1902  rw"

Given that trick the iso image can be uncompressed and copied in the same way than in the debian case :

sudo 7z x /data/IsoImages/manjaro-gnome-19.0.2-200312-linux54.iso -o/mnt/disk6

This time we check that vmlinuz and initramfs are in the right folders :

* Manjaro loader /mnt/disk6/boot/vmlinuz-x86_64
* Manjaro initrd /mnt/disk6/boot/initramfs-x86_64.img

It is interesting to point out here that as long as the grub files (debian family) or initramfs and vmlinuz (Arch family) are provided in their default place, it is possible to reinstall or change the version of the distribution without changing anything else except the ̀vmlinuz and initrd versions in the refind.conf file. There is no need to change the structure or the contents of the EFI partition and rEFInd configuration to change the version of any linux live distribution on the USB multiboot key.


Commentaires