Use grub to make a BIOS/UEFI bootable USB flash drive

Moderator: Forum moderators

Post Reply
User avatar
Jafadmin
Posts: 377
Joined: Tue Aug 04, 2020 4:51 pm
Has thanked: 68 times
Been thanked: 84 times

Use grub to make a BIOS/UEFI bootable USB flash drive

Post by Jafadmin »

I've been doing this method for quite a while, now. It boots both UEFI aware OS's and those older OS's that are not UEFI aware.
(It is also on the old forum in the HowTo section: http://murga-linux.com/puppy/viewtopic.php?t=117536)

This HowTo is for making a USB flash drive that will contain and boot any mix of Puppies and ISO's, whether UEFI or not. It is NOT intended as a replacement for any given Puppy's single-use Install program.
This WILL NOT enable a non-UEFI OS to boot on a UEFI enabled computer!

#============================================================================#
Do this to your USB Flash using GPartEd (msdos partition table) and grub-install from a full linux distro:

bootusb.png
bootusb.png (34.39 KiB) Viewed 1214 times

Add this to the grub.cfg in the root of sdX1:

Code: Select all

set root=(hd0,msdos2)
configfile /boot/grub/grub.cfg

Add this to the /boot/grub/grub.cfg of sdX2:

Code: Select all

set timeout=5
set default=0

# Boot a puppy example
menuentry 'BionicPup64 8.0' {
   linux   /BionicPup64/vmlinuz   psubdir=BionicPup64 pmedia=usbflash pfix=fsck
   initrd   /BionicPup64/initrd.gz
}

# Boot an ISO file example
menuentry "linuxmint-19.2-mate-64bit ISO" {
   set isofile="/ISOs/linuxmint-19.2-mate-64bit.iso"
   loopback loop $isofile
   linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile liveimg noprompt noeject quiet splash --
   initrd (loop)/casper/initrd.lz
}

A BIOS machine will boot directly to partition 2 (sdX2), and a UEFI machine will boot to partition 1 (sdX1) and get transfered to the grub.cfg on partition 2 (sdX2)

Those entries boot puppies and ISO's that are on the ext3 partition. This is really important with large ISO's as Grub4Dos requires them to be on a fat32 and occupy only 1 extent. Grub will boot regardless of how many extents.

So for multiple large ISO's, ext3 and grub works better.

I create the initial thumbdrive using a version of Linux such as Mint or Ubuntu that has the 'grub-install' package already installed.
If you use an fstype other than ext3 for the second partition, do not come here asking us for help. The reasons are too numerous to list in a HowTo.

I recommend first creating the USB thumb drive, then cloning it before installing puppies on it using dd piped to gzip so you can easily create new ones using only a puppy command line. If you start by using a new USB or one wiped with zeros, then reformatted, it will create an amazingly small "img.gz" file.

Code: Select all

# backup:
dd bs=4M if=/dev/sdX | gzip > /path/to/saved/images/USB-boot-32GB.img.gz
# restore:
gzip -d -c /path/to/saved/images/USB-boot-32GB.img.gz | dd bs=4M of=/dev/sdX

FWIW, I add puppies to partition 2 by manually creating unique directories for them then copying the initrd, vmlinuz, and sfs files from the puppy ISO to the new directory. I then manually copy, paste, then edit the new entry in /boot/grub/grub.cfg. I do not use the puppy apps for this.

Last edited by Jafadmin on Thu Mar 25, 2021 6:02 pm, edited 7 times in total.
User avatar
Jafadmin
Posts: 377
Joined: Tue Aug 04, 2020 4:51 pm
Has thanked: 68 times
Been thanked: 84 times

Re: Use grub to make a BIOS/UEFI bootable USB flash

Post by Jafadmin »

1) For booting normal linux iso's, the 'boot=???' parameter has to point to the directory in the iso that contains the boot code (and no, I don't know all the names of all the boot folders in all the linux ISO's). Puppy iso's usually fail because they try to create a loop device inside a loop device and can't find their 'puppy_whatever.sfs' main file. This can be worked around by putting a copy of the 'puppy_whatever.sfs' in the root of partition2.

2) But why boot puppy iso's when the direct solution is smaller and simpler, right? (pfix=ram)
3) I get the UEFI files from 'efi.img' by looping up the img file.

LoopImg.tar.gz
(34.72 KiB) Downloaded 49 times
Post Reply

Return to “Boot”