Add Zorin OS USB stick to Grub menu

If you keep your Zorin OS USB stick plugged in so you can easily boot from it, you know that you then have to change the boot order to do so. The procedure for doing so ranges from entering your BIOS and changing the boot order, to pressing a certain key as the machine boots to change the boot order, depending upon your machine.

Here's another way, with a couple distinct advantages:

To add the Zorin OS USB stick as a Grub menu entry:

Use one of two methods to open the 40_custom file:

sudoedit /etc/grub.d/40_custom

  • or -

install Nautilus Admin:
sudo apt install nautilus-admin

... then right-click the /etc/grub.d/40_custom file and select "Edit As Administrator".

Add the following at the bottom of the text:

menuentry 'Zorin OS Boot USB' --class gnu-linux --class gnu --class os {
	insmod part_gpt
	insmod ext2
	search --no-floppy --set=root --fs-uuid 2022-12-08-19-53-13-00
	configfile /boot/grub/grub.cfg
}

Where "--fs-uuid 2022-12-08-19-53-13-00" is the UUID of the Zorin OS USB stick as found in sudo blkid.

Save that file, then issue:
sudo update-grub

You can view what your Grub menu entries will be via:
awk -F\' '/^menuentry / {print $2}' /boot/grub/grub.cfg|cat -n|awk '{print $1-1,$1="",$0}'

Now, the advantages:

  1. The original grub menu pops up, you select 'Zorin OS Boot USB', then another grub menu pops up for the Zorin OS USB stick... so you can input kernel parameters for it, just as you can for the installed Zorin OS.

  2. You no longer have to change BIOS settings or press a special key to boot the Zorin OS USB stick.

  3. You can reboot from Zorin OS into the Zorin OS Boot USB without having to press any key...

Running the command above, my grub boot menu looks like:
0 Zorin OS 16.2
1 UEFI Firmware Settings
2 Zorin OS Boot USB

So if I wanted to reboot into the Zorin OS Boot USB, I could just issue:
grub-reboot 2

Of course, it helps if your Grub menu comes up every time you boot.

I've since wiped the USB drive, installed Ventoy on it, then put both the Zorin OS .ISO file and a Win10 PE .ISO file on the drive.

This allowed me to update the UEFI / BIOS on my HP computer (since HP only provides .exe BIOS update files, and manually arranging the files so they work under Linux is a pain) under Win10 PE.

1 Like

Question

  • How does this modification handle the USB not present?
  • Does it need to be modified with an if statement if you don't keep a bootable USB plugged in?
  • Is the menu option present if the USB isn't present?
  • Is there a dynamic way to do this without manually adding the UUID?
  1. On my machine, it gives a "Drive not found" error, then reboots to a built-in interface that lets you choose the UEFI setup, or to continue to a normal boot via the Grub menu.

  2. It can be, but I'm not sure how to go about determining if a particular UUID is present.

  3. Yes, the menu option is still present if the USB isn't present... I'll think about how to fix that.

  4. You can use the drive label or the PARTUUID, but they're not as reliable as UUID. Perhaps I can whip up something that searches the drives for a particular file, and if found, it determines that drive's UUID, then adds that drive to the Grub menu? Dunno, I'll have to try that. That'd be especially handy... want a particular drive (or partition) added to your Grub menu when you plug it in (and not added when it's not plugged in)? Just drop this GrubMe file into the root directory of that drive. The file contents wouldn't matter, as it's just looking for the existence of that file, not the contents, so it could be a text file describing how to use it.

1 Like

I've been experimenting with Grub scripting... basically in /etc/grub.d/40_custom, I'm searching for /EFI/BOOT/BOOTX64.EFI, and if it's found, it adds that OS to the Grub menu.

In so doing, the search for that file slowed down the startup process just enough to show two error messages that have been there forever, but I just didn't notice them because they flash up and disappear too quickly:


error: no video mode activated.

This error comes about because /etc/grub.d/00_header searches for the Grub font file, but because I'm running ZFS, and the font file is stored on a ZFS volume, that volume isn't readable just as the machine turns on.


error: can't find command 'hwmatch'.

This is a command called in /etc/grub.d/10_linux... it appears to be a reversion to a bug from 2019 (which is a reversion to a bug from 2011).

The solution noted there doesn't work for me. Again, this is because the hardware blacklist is stored on a ZFS volume which isn't readable right as the machine starts up.

I'll report back once I get the Grub scripting working.

I've since moved from a straight Zorin OS-only USB stick to a Ventoy USB stick containing the Zorin OS .ISO file and the Hiren's Boot CD Win10 PE .ISO file.

This allows me to use Win10 PE to update the UEFI (since HP only provides UEFI updates in Windows-specific format), in addition to booting to the Zorin OS .ISO to do full backups and for emergency booting.

The further advantage of this is that you can drop any .ISO file for any Linux flavor onto the Ventoy USB stick, and try it out. I've got Pop!OS on there, too (although Pop!OS isn't to my liking, so I'll likely delete it).