1

I want to create my own Debian Live boot stick from a chroot (debootstrap) environment.

The root filesystem should be mounted as squashfs and grub should be able to boot the system from a single EFI partition.

So far, I have a squashfs image of the chroot environment, vmlinuz and initrd.img on the stick. However, I don't know, how I have to configure grub so that it doesn't boot my local system (tried with: grub-install...) but instead the squashfs of the USB stick.

1 Answer 1

0

I solved the problem!

First, the chroot environment must have the necessary initframes to load a shquashfs image. For this, I simply installed the live boot packet in the chroot and then updated the initframes. /proc, /dev/pts, /dev, /sys should be available in the chroot for this to work.

# @ root on localhost
mount -o bind /proc /debootstrap/proc
mount -o bind /dev /debootstrap/dev
mount -o bind /dev/pts /debootstrap/dev/pts
mount -o bind /sys /debootstrap/sys
# @ root in chroot
apt install live-boot live-boot-initramfs-tools
update-initramfs -u

When that is done, these directories should be unmounted and the shquashfs can be created to /target/live/filesystem.squashfs.

# @ root on localhost
umount /debootstrap/proc
umount /debootstrap/dev
umount /debootstrap/dev/pts
umount /debootstrap/sys
# @ root on localhost
mksquashfs -comp xz /debootstrap /target/live/filesystem.squashfs

I formatted the USB stick in fat32 and mounted it in /target. Now Grub can be installed.

# @ root on localhost
grub-install --target=x86_64-efi --root-directory=/target

Once that's done, copy vmlinuz and the initrd.img to /target/boot and create the grub.cfg in /target/boot/grub/grub.cfg with the following contend.

insmod all_video

set default=0
set timeout=0

menuentry "debian live" {
    linux /boot/vmlinuz boot=live toram=filesystem.squashfs quiet
    initrd /boot/initrd.img
}

This is it, your pc should be able to EFI boot this stick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .