1

Right now, I have created a drive using Yumi's UEFI program to create a multi-boot USB for UEFI, but as of late, I need a BIOS one as well. Is there a way to combine those two into one drive? Basically supporting UEFI AND BIos? Or will I need two different USB's? Thanks!

4
  • Welcome! No, you don't need two different usbs, you have to install GRUB both BIOS and EFI. Which OS you need to install? Or is it any? Mar 29, 2020 at 22:16
  • Eh, just trying to do a Kali-Ubuntu-Debian USB. How would I do that and what program would I use exactly?
    – Joshua G.
    Mar 29, 2020 at 23:27
  • Let me see with kali, I haven't tried yet. Mar 30, 2020 at 0:13
  • Alrighty, let me know when you are done. Thanks.
    – Joshua G.
    Mar 30, 2020 at 0:47

2 Answers 2

2

MultiBoot USB Stick from Scratch

(Modification of How do I boot an ISO file from my drive using grub2 on UEFI machines?)

GParted Partitions

GParted

  • Create a gpt partition table on a USB stick.

  • Create partitions as shown above, select unformatted for partition 2.

  • Create a casper-rw file:

    sudo dd if=/dev/zero of=casper-rw bs=1M count=512

    sudo mkfs.ext3 -L casper-rw -F casper-rw

(where count=512 is the persistence size in megabytes, with a max of 4GB).

Persistence partition

Persistence Partition

  • Create an uniquely name folder for each OS, (that requires persistence), on the USB-PRST partition.

  • Add a casper-rw file, (and optional home-rw file), to each persistence folder. A home-rw file can be made by renaming a casper-rw file. A home-rw file is like a separate home partition on a Full install, it can be reused after version upgrades.

Data Partition

Data Partition

  • Create a folder for the ISO files on the NTFS USB-DATA partition.

  • Add some ISO's to the isos folder.

Boot Folder

Boot Partition

  • Open the latest ISO file and copy the boot and the EFI folders to the USB-BOOT partition. Add rmmod tpm to grub.cfg above the first menuentry

  • Install grub

    sudo mount /dev/sdx3 /mnt

    sudo grub-install --boot-directory=/mnt/boot /dev/sdx

Edit grub.cfg to loopmount the ISO files. Include: persistent persistent-path=/<persistent-folder-name>/ if you want multiple persistence.

if loadfont /boot/grub/font.pf2 ; then
    set gfxmode=auto
    insmod efi_gop
    insmod efi_uga
    insmod gfxterm
    terminal_output gfxterm
    rmmod tpm
fi

set menu_color_normal=white/black
set menu_color_highlight=black/light-gray

set timeout=5

menuentry "ubuntu-19.10-desktop-amd64.iso" {
    set root=(hd0,1)
    set isofile="/isos/ubuntu-19.10-desktop-amd64.iso"
        loopback loop $isofile
        linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile persistent persistent-path=/persist-1/ splash --
        initrd (loop)/casper/initrd
}
menuentry "lubuntu-16.04.3-desktop-amd64.iso" {
    set root=(hd0,1)
    set isofile="/isos/lubuntu-16.04.3-desktop-amd64.iso"
        loopback loop $isofile
        linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile persistent persistent-path=/persist-2/ splash --
        initrd (loop)/casper/initrd.lz
}

Grub.cfg example

sudo parted -ls  /dev/sdx

sudo parted -ls /dev/sdx

sudo lsblk -f  /dev/sdx

sudo lsblk -f /dev/sdx

If the above is used as a USB stick it can be used to boot ISO's stored on a Windows only computer. Grub is not required on the internal drive.

1
0

To be safe¹, use two usbs, one to perform the installing, and the other to be intalled.

  1. Format the USB in FAT.

  2. Install the packages grub-efi-amd64 and grub-pc-bin.

  3. Plug the USB and take note of the device, say /dev/sdb, and the mount point, say /media/user/USB.

  4. Create a chroot:

    dirs=(dev bin sbin etc sys usr proc lib lib64)
    for dir in ${dirs[@]}; do
      mkdir /media/user/USB/$dir && sudo mount --bind /$dir /media/user/USB/$dir
    done
    sudo chroot /media/user/USB/
    
  5. Once inside the chroot, run these commands:

    grub-install --force --removable --target=x86_64-efi --efi-directory=/ /dev/sdb1
    grub-install --force --removable --target=i386-pc --boot-directory=/ /dev/sdb
    exit
    
  6. Now unmount and remove the directories:

    for dir in ${dirs[@]}; do
      sudo umount /media/user/USB/$dir && rm /media/user/USB/$dir
    done
    
  7. Copy the isos to your USB.

  8. In your the USB, create the file /grub/grub.cfg and add the content:

    set root='(hd0,1)'
    configfile /boot/grub/grub.cfg
    
  9. To boot Debian and Kali, in this example (you have to change the name of the isos according to what you have downloaded), add to /boot/grub/grub.cfg:

    set root='(hd0,1)'
    
    menuentry "Kali Live system" {
      set iso_path=/kali-linux-2020.1b-live-i386.iso
      loopback loop $iso_path
      linux (loop)/live/vmlinuz-5.4.0-kali2-686-pae boot=live components quiet splash noeject findiso=${iso_path}
      initrd  (loop)/live/initrd.img-5.4.0-kali2-686-pae
    }
    
    menuentry "Debian GNU/Linux Live (kernel 4.19.0-8-686)" {
      set iso_path=/debian-live-10.3.0-i386-xfce.iso
      loopback loop $iso_path
      linux (loop)/live/vmlinuz-4.19.0-8-686 boot=live findiso=$iso_path components splash quiet "${loopback}"
      initrd (loop)/live/initrd.img-4.19.0-8-686
    }
    

¹ You can do this in your machine OS, but there are a couple of commands that in error, may harm your system.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .