Skip to content

Add GPT layout support: ext4 GLIM partition, optional data partition, automated setup#157

Open
codemedic wants to merge 2 commits into
thias:masterfrom
codemedic:add-gpt-multipartition
Open

Add GPT layout support: ext4 GLIM partition, optional data partition, automated setup#157
codemedic wants to merge 2 commits into
thias:masterfrom
codemedic:add-gpt-multipartition

Conversation

@codemedic

Copy link
Copy Markdown

Closes #78. Fixes #156. Alternative approach to #131.

Problem

Two things have been bugging me about GLIM for a while:

  1. The FAT32 4 GiB file-size limit. Ubuntu 22.04+ desktop ISOs already exceed it, and
    the trend is only going in one direction.
  2. No way to have a data partition on the same stick, which would be useful for
    transferring files between live environments.

What this PR does

It adds glim-partition.sh, a new automated partitioning script, and extends glim.sh
to support a GPT multi-partition layout, while keeping the existing single-partition
FAT32 setup working exactly as before.

Default mode (simple, universal):

./glim-partition.sh /dev/sdX

Creates a single FAT32 partition (MBR), identical to what you'd set up manually today.
Works on Windows and macOS, works across BIOS and EFI. Still subject to the 4 GiB limit.

GPT mode (for large ISOs):

./glim-partition.sh /dev/sdX --gpt
./glim-partition.sh /dev/sdX --gpt --data-size 32G
./glim-partition.sh /dev/sdX --gpt --data-size 32G --data-fs ext4
Partition Size Type Label Purpose
P1 1 MiB BIOS Boot (ef02) (none) GRUB BIOS core image
P2 256 MiB EFI System (ef00) (none) FAT32 EFI bootloader
P3 [rest] Linux (8300) GLIM GRUB config + ISO files (ext4)
P4 [opt] Linux (8300) GLIMDATA User storage (exFAT by default)

--data-size implies --gpt. The GLIMDATA partition defaults to exFAT, which has no
file size limit and is readable natively on Windows, macOS, and Linux without drivers.
Use --data-fs ext4 if you only care about Linux. exFAT partitions are accessible
to all users by default when mounted. ext4 GLIMDATA is set world-writable (chmod 1777)
so any live environment can write to it regardless of UID/GID.

Why no grub.cfg changes?

grub-install --boot-directory pointing at the ext4 GLIM partition makes GRUB's $root
that partition naturally. The existing probe --set rootuuid --fs-uuid $root picks up
the correct UUID, so all iso-scan/filename=, img_dev=, and findiso= boot parameters
work without modification. Existing ISO paths are preserved.

Changes

  • glim-partition.sh (new): automated partitioning script. Destructive; requires
    explicit yes confirmation and refuses to run as root or touch the system disk.

  • glim.sh: detects a separate ESP via partition type GUID for EFI install;
    handles NVMe naming correctly; chowns the GLIM partition after grub-install so
    rsync and subsequent ISO copies work without sudo. Also fixes glim.sh: Escape key (and other non-'n' input) accepted as yes at prompts #156: prompts now only
    accept y, Y, or Enter as yes; Escape no longer silently proceeds.

  • README.md: documents both layouts with automated and manual setup instructions.
    Includes a Secure Boot note: some ISOs (Gentoo, Arch, Artix) ship shims not signed by
    a Microsoft-trusted CA and will fail on Secure Boot systems; this is not a GLIM bug.

  • tests/ (new): pytest suite that runs against real loop devices. Covers partition
    layout, glim.sh install correctness, and QEMU BIOS/UEFI boot smoke tests. No mocking.

Comparison with #131

#131 solves the same problem differently: a small FAT32 anchor partition plus a separate
GLIMISO partition for ISOs. That approach requires significant grub.cfg changes and
moves ISOs from boot/iso/ to iso/, a breaking change for existing setups. This PR
avoids both by using --boot-directory to point GRUB at the ext4 partition directly.

Tested

Tested on a 232 GB USB stick with a GPT layout and 64 GB GLIMDATA partition. Elementary
OS boots successfully via UEFI. BIOS boot confirmed working.

Closes thias#78. Fixes thias#156.

glim-partition.sh (new):
- Default mode: single FAT32 partition (MBR), universal compatibility
- --gpt: GPT layout with BIOS Boot (ef02) + ESP (ef00, FAT32) + ext4 GLIM
- --data-size SIZE: optional GLIMDATA partition (implies --gpt)
- --data-fs exfat|ext4: GLIMDATA filesystem, defaults to exFAT (cross-platform,
  no file size limit); ext4 GLIMDATA is chmod 1777 for live-env write access
- Zaps corrupted GPT headers in a separate pass before writing new layout
- Refuses to run as root or touch the system disk

glim.sh:
- Detects a separate EFI System Partition via type GUID for EFI install;
  falls back to the GLIM partition on single-partition layouts
- Uses lsblk -no PKNAME for parent device detection (handles NVMe correctly)
- Chowns boot/ after grub-install so rsync works without sudo on ext4 mounts
- Chowns the GLIM partition root after install so ISOs can be copied without sudo
- Fixes thias#156: prompts now only accept y, Y, or Enter as yes; Escape and other
  non-n input no longer silently proceed with installation

README.md:
- Documents both partition layouts with automated and manual setup instructions
- Secure Boot note: ISOs with unsigned shims (Gentoo, Arch, Artix) require
  Secure Boot to be disabled; this is not a GLIM bug

tests/ (new):
- pytest suite running against real loop devices; no mocking
- Covers partition layout (MBR/GPT/exFAT/ext4), glim.sh install correctness,
  and QEMU BIOS/UEFI boot smoke tests
- setup-sudo.sh installs a sudoers drop-in for passwordless test commands;
  --remove flag tears it down
@codemedic

Copy link
Copy Markdown
Author

Real hardware test results (232 GB USB, GPT layout with 64 GB exFAT GLIMDATA)

Booted successfully via UEFI: clonezilla debian elementary gparted kubuntu nixos popos ubuntu

Not working: gentoo, OpenBSD, Netrunner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

glim.sh: Escape key (and other non-'n' input) accepted as yes at prompts Is a storage partition possible?

1 participant