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

1
2
3
4
5
6
7
8
9
# get the iso
wget "https://iso.pop-os.org/24.04/amd64/nvidia/24/pop-os_24.04_amd64_nvidia_24.iso"

# mount it
sudo mkdir -p /mnt/iso
sudo mount -o loop ~/Downloads/pop-os_24*.iso /mnt/iso

# confirm that it has a filesystem.squashfs inside
ls /mnt/iso/casper/ | grep filesystem.squashfs

2. Target Drive Partitions

1
2
3
4
5
# find /dev/sd* mountpoint for USB drive
lsblk

# open GDisk partition editor
sudo gdisk /dev/sdX

In gdisk:

  1. Create GPT table: o (create new empty GUID partition table)
  2. 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)
  3. Create root partition:
    • n (new partition)
    • Partition number: 2
    • First sector: Enter (default)
    • Last sector: Enter (use remaining space)
    • Hex code: 8300 (Linux filesystem)
  4. Write changes: w
1
2
3
4
5
6
7
8
9
10
11
12
# Format EFI System Partition as FAT32
sudo mkfs.fat -F32 /dev/sdX1

# Format root partition as ext4
sudo mkfs.ext4 /dev/sdX2

# mount them
sudo mkdir -p /mnt/usb_ssd
sudo mount /dev/sdX2 /mnt/usb_ssd

sudo mkdir -p /mnt/usb_ssd/boot/efi
sudo mount /dev/sdX1 /mnt/usb_ssd/boot/efi

3. Extract filesystem.squashfs

1
sudo unsquashfs -f -d /mnt/usb_ssd /mnt/iso/casper/filesystem.squashfs

(we need the -f force flag because /mnt/usb_ssd obviously already exists)

The output looks like:

1
2
3
4
5
6
7
8
9
10
11
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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ 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

1
2
3
4
5
6
7
8
9
10
11
sudo blkid /dev/sda2   
# and copy the UUID="" part
sudo nano /mnt/usb_ssd/etc/fstab
# add a line like 
# UUID=WHAT_YOU_COPIED   /          ext4   defaults   0 1

sudo blkid /dev/sdX1   
# and copy the UUID="" part
sudo nano /mnt/usb_ssd/etc/fstab
# add a line like 
# UUID=WHAT_YOU_COPIED                              /boot/efi  vfat   defaults   0 2

Copy the bootloader:

1
sudo rsync -avhPHAXx --numeric-ids /mnt/iso/efi/ /mnt/usb_ssd/boot/efi/EFI/

And chroot to install it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
sudo mount --bind /dev /mnt/usb_ssd/dev
sudo mount --bind /proc /mnt/usb_ssd/proc
sudo mount --bind /sys /mnt/usb_ssd/sys
sudo mount --bind /run /mnt/usb_ssd/run

sudo chroot /mnt/usb_ssd

# install systemd-boot
bootctl install
# NOTE: will print 2 warnings and a LoaderSystemToken EFI error. just ignore.

# disable live mode
kernelstub

# create initramfs
update-initramfs -u -k all

# login user
useradd -m -G sudo -s /bin/bash yourusername
passwd yourusername

# exit chroot
exit

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.

5. Unmount Everything

1
2
3
4
5
6
7
sudo umount -l /mnt/usb_ssd/sys
sudo umount -l /mnt/usb_ssd/proc
sudo umount -l /mnt/usb_ssd/dev
sudo umount -l /mnt/usb_ssd/run
sudo umount /mnt/usb_ssd/boot/efi
sudo umount /mnt/usb_ssd
sudo umount /mnt/iso

And now you can reboot into your fresh install of Pop!OS 24.