schierlm / usb-modboot

Boot multiple systems from a single GRUB2-powered USB drive (just drop ISO or other modules to integrate into menu)
GNU General Public License v3.0
42 stars 4 forks source link
grub2 loopback-cfg secure-boot uefi usb

usb-modboot

Boot multiple systems from a single GRUB2-powered USB drive (just drop ISO or other modules to integrate into menu)

Design Principles

Supported Modules

To add modules, just copy them into /usb-modboot/ directory. The following module types are supported:

Installing usb-modboot

Installing the core

For this, you need a USB key which contains a single partition (MBR partitioning scheme) which is formatted with FAT32 filesystem. Most USB keys are formatted like this from the factory. When formatting it yourself in Linux, choose partition type 0B and don't forget to set the bootable flag (which is required by some BIOSes to make the USB key appear in the boot menu).

Then, copy the content of usb-modboot.zip to that USB key. On Windows, double click \install\bios-install.cmd file, on Linux you can change to install directory and run ./bios-install.sh if you have grub-bios-setup installed (which will dynamically set up GRUB like on Windows), or run ./bios-install-from-bootblock.sh /dev/sdX (which will use some dd magic to put GRUB onto the MBR). Note that the latter command will need the name of the device as an argument, while the first command (both on Windows and on Linux) will autodetect the device from where the file is stored and (after a confirmation) work automatically.

On other operating systems that support neither of the script, you can write the disk image usb-bootblock.img.xz (after extracting) onto an empty USB key with at least 1GB capacity. Then you'll have to increase the partition size of the partition to fill the full USB key, and then copy the contents on the USB key again. This is more like a last resort method; if possible I would always prefer one of the other methods.

After installation is finished, you may delete the install directory (or keep it in case you want to copy the files to another USB key later, for easier re-running).

Adding modules

Download the modules you like and copy them to usb-modboot directory. Modules available here are .zip files; they need to be extracted to the root of the USB key (but will drop the majority of files in usb-modboot, too). Modules will be automatically picked up when booting, so there is no need to edit menu files (unless you want to add the modules into the favourite modules menu).

There are also modules that should be dropped next to an UltimateBootCD 5.3.7 ISO or a Debian 9.3.0 netinst ISO, to support booting from them. More modules may be added in the future (maybe without updating this README file).

Configuring favourite modules

When you have many modules on usb-modboot, the menu can become long and selecting may take some time. Therefore, you can add favourites which appear in the main menu (other modules will still appear in the "All Boot Modules" menu). Therefore you edit menu.ini and add lines like

addmodule ubuntu.iso

or

addmodule ubuntu.iso "My Favourite Ubuntu"

in case you want to use a custom title. The first argument to addmodule is the filename of the file inside /usb-modboot/ directory (but without the directory name).

In fact, you can use all GRUB commands (including submenu) in this file, so you can build more complex favourite menus if you prefer. But you don't have to - for most users, just using addmodule should be fine.

Compiling usb-modboot from source

If you want to modify how usb-modboot works, you have to compile it from source. If you just want to use usb-modboot, you can ignore this part.

I use a minimal Debian Stretch VM for building; it should work on other distros as well. root privileges are required.

First you need some build tools:

# apt install build-essential unzip gettext libfreetype6-dev dosfstools autoconf automake bison flex xfonts-unifont python ca-certificates git

Then checkout this repo:

# git clone https://github.com/schierlm/usb-modboot

First compile grub

# cd usb-modboot
# ./build-grub

Then build the main core image and some more auxiliary files

# ./build-main

The resulting files are in dist now. Note that this command also builds some modules; other modules have dedicated build scripts; yet other modules do not have any build scripts but are put together manually from other source pages.