Git Product home page Git Product logo

grub2-bootstrap's Introduction

GRUB2 Bootstrap

This is an example on how to use GRUB2 as a bootstrap loader. This allows you to burn ISO9660 files within a partition rather than to burn it on the entire disk, creating the possiblity to have a single flash drive with multiple ISOs to boot from. It's like Ventoy, but using a different approach, maybe more suitable for other use cases.

For now, this project covers only UEFI-compatible system compatibility. For legacy/BIOS systems, take a look here: stefan-golinschi/microserver-bootstrap.

Disk Partitioning

Disk partitioning is done using gdisk, by creating an EFI system partition for the bootloader and some other partitions, depending on your specific requirements.

A sample partition layout is layout.sfdisk, which can be easily imported using sfdisk like this:

sfdisk /dev/sdg < layout.sfdisk

Remember, the partition code for EFI ESP is ef00.

Disk formatting

sudo mkfs.vfat -F32 /dev/sdg1

Installing the bootloader

If you use Fedora, you will need to install this package grub2-efi-x64.x86_64.

sudo mount /dev/sdg1 data
sudo grub2-install --target=x86_64-efi --efi-directory=./data/ --boot-directory=./data/boot --removable --force /dev/sdg

# TODO: For legacy/BIOS systems
# sudo grub2-install --target=i386-pc --boot-directory=./data/boot --removable /dev/sdg
# sudo grub2-install --target=i386-efi --efi-directory=./data/ --boot-directory=./data/boot --removable --force /dev/sdg

Burning bootable ISOs

For example, we will use two alpine linux ISOs.

sudo dd if=alpine-standard-3.19.1-x86_64.iso of=/dev/sdg2 status=progress
sudo dd if=alpine-extended-3.18.3-x86_64.iso of=/dev/sdg3 status=progress

After this, make sure to update the grub.cfg file accordingly. For example, I used GRUB2's search --label function to set the root for each menuentry.

If you want to know the labels of the ISOs, you can use file alpine-standard-3.19.1-x86_64.iso, or you can do a lsblk -o +LABEL after you burn the ISOs to the flash drive.

Finally, copy the grub config file to the EFI ESP partition on the flash drive.

sudo cp grub.cfg data/boot/grub2/

References

grub2-bootstrap's People

Contributors

stefan-golinschi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.