Installing Pop!OS 24 Directly With Unsquashfs & Chroot (and No Reboot)
For a client project,
I needed to boot from a USB SSD
to isolate their background daemons
from my daily driver (encrypted) Pop!OS.
The official way to install Pop!OS is, of course, to copy their ISO onto a USB stick and reboot into that.
I couldn’t be bothered to find an empty USB stick,
and I also didn’t want to reboot just for the setup,
as that would have interrupted all of my other work
while the setup was running.
I know, I could have used a VM
and mounted my external USB drive into it
and mounted the setup ISO into it and …
it felt unnecessarily complicated.
Instead, I directly extracted the filesystem.squashfs file from the setup ISO onto my target drive.
Then chroot to fix the bootloader.
And it just works 👍️.
1. Get & Mount ISO
123456789
# get the isowget"https://iso.pop-os.org/24.04/amd64/nvidia/24/pop-os_24.04_amd64_nvidia_24.iso"# mount itsudomkdir-p/mnt/iso
sudomount-oloop~/Downloads/pop-os_24*.iso/mnt/iso
# confirm that it has a filesystem.squashfs insidels/mnt/iso/casper/|grepfilesystem.squashfs
2. Target Drive Partitions
12345
# find /dev/sd* mountpoint for USB drivelsblk
# open GDisk partition editorsudogdisk/dev/sdX
In gdisk:
Create GPT table: o (create new empty GUID partition table)
Create EFI System Partition:
n (new partition)
Partition number: 1
First sector: Enter (default)
Last sector: +1G (I like a slightly larger ESP)
Hex code: ef00 (EFI System)
Create root partition:
n (new partition)
Partition number: 2
First sector: Enter (default)
Last sector: Enter (use remaining space)
Hex code: 8300 (Linux filesystem)
Write changes: w
123456789101112
# Format EFI System Partition as FAT32sudomkfs.fat-F32/dev/sdX1
# Format root partition as ext4sudomkfs.ext4/dev/sdX2
# mount themsudomkdir-p/mnt/usb_ssd
sudomount/dev/sdX2/mnt/usb_ssd
sudomkdir-p/mnt/usb_ssd/boot/efi
sudomount/dev/sdX1/mnt/usb_ssd/boot/efi
(we need the -f force flag because /mnt/usb_ssd obviously already exists)
The output looks like:
1234567891011
Parallel unsquashfs: Using 32 processors
222856 inodes (219349 blocks) to write
[===...===] 219349/219349 100%
created 185357 files
created 16711 directories
created 37471 symlinks
created 8 devices
created 0 fifos
created 4 sockets
And afterwards your USB drive should look like a Linux root partition:
123456789101112131415161718192021
$ls/mnt/usb_ssd
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var
4. Fstab & Bootloader & Login User
1234567891011
sudoblkid/dev/sda2# and copy the UUID="" partsudonano/mnt/usb_ssd/etc/fstab
# add a line like # UUID=WHAT_YOU_COPIED / ext4 defaults 0 1sudoblkid/dev/sdX1# and copy the UUID="" partsudonano/mnt/usb_ssd/etc/fstab
# add a line like # UUID=WHAT_YOU_COPIED /boot/efi vfat defaults 0 2
sudomount--bind/dev/mnt/usb_ssd/dev
sudomount--bind/proc/mnt/usb_ssd/proc
sudomount--bind/sys/mnt/usb_ssd/sys
sudomount--bind/run/mnt/usb_ssd/run
sudochroot/mnt/usb_ssd
# install systemd-bootbootctlinstall
# NOTE: will print 2 warnings and a LoaderSystemToken EFI error. just ignore.# disable live modekernelstub
# create initramfsupdate-initramfs-u-kall
# login useruseradd-m-Gsudo-s/bin/bashyourusername
passwdyourusername
# exit chrootexit
The bootctl warnings and errors, BTW,
are because the chroot cannot access the real EFI firmware.
But if your Mainboard can boot from USB with UEFI in general,
this part of the systemd-boot setup is not needed anyway.