Debian live
Debian live on USB pen-drive using Grub 2
Intro
This tutorial will show how to prepare a USB pen-drive with a bootable Debian LIVE image.
NOTE: in the past, we would like to use ISO images named 'unofficial'. Those images from the debian.org site are tagged as unofficial only because they contain non-free firmware usually useful to have something like wireless drivers working without have to do more work. Recently (from Debian Bookworm) non-free drivers are included in the default images and we don't need the 'unofficial' ones anymore.
Take a look at https://cdimage.debian.org/images/release/current-live/ to choose your iso image.
In this example, we will use the stable image from the follow link:
USB pen-drive partition
Usually, LIVE system are read-only. This means that the user lost any changes at reboot. Live systems like Debian allow to store the changes in a pendrive partition. However, the partition used to persist changes can not be the same that contains the Debian Live ISO file, or it will be mounted in 'read-only' mode and cannot be used to store changes. To avoid that, this pen-drive will have a separate partition to store the user modified data.
Moreover, Windows systems will not like this such of pen-drive with filesystem different than his FAT filesystem. To avoid problems with Windows, this pen-drive will have an additional separate partition to work both with Windows (MacOS etc.) and Linux systems. Again, this partition can not used to store the Debian Live ISO file, or it will be mounted 'read-only'.
At the end of the follow tutorial, we will have a pen-drive formatted with the follows partitions:
- a Windows compatible FAT32 partition;
- a small bootable Linux EXT2 partition with Grub bootloader;
- a Linux EXT2 partition with a Debian Live ISO image;
- a Linux EXT2 partition used for Persistence, to keep user data and to install custom programs.
- partition the pen-drive
If you follow the previous link steps, you should end up with 4 partitions, already formatted.
The first partition is to avoid problems, as the "world" expects the first partition to be a VFAT. You can still use it as a normal pendrive.
The second must configured to use Grub to boot a Debian Live image, and the third must contain the live image.
Prepare the second partition for Grub
See Grub#For_BIOS_partition_table_(MBR) and Grub#Configuration
If you follow the previous links steps, you should end up with a bootable pendrive, that can be further configured to boot Debian Live. Let's do that.
- Edit the content of /tmp/sdX2/boot/grub/menu.cfg :
menuentry "Debian GNU/Linux Live USB iso image" { set isofile="/images/debian-live.iso" search --no-floppy --set=isodev --file $isofile loopback loop ($isodev)$isofile linux (loop)/live/vmlinuz boot=live findiso=$isofile persistence persistence-media=removable-usb persistence-storage=filesystem persistence-label=persistence components initrd (loop)/live/initrd.img }
Prepare the third partition for Debian Live image
If you follow Bootable_pendrive you should end up with a third pendrive partition already formatted, you should only put your Debian Live image there. Let's do that.
root@host:~# mkdir /tmp/sdX3 root@host:~# mount /dev/sdX3 /tmp/sdX3 root@host:~# mkdir -p /tmp/sdX3/images root@host:~# curl -kLO /tmp/sdX3/images/debian-live.iso https://cdimage.debian.org/images/release/current-live/amd64/iso-hybrid/debian-live-12.5.0-amd64-gnome.iso root@host:~# umount /tmp/sdX3 root@host:~# rmdir /tmp/sdX3
Prepare the forth partition for Debian Live persistence
If you follow Bootable_pendrive you should end up with a forth pendrive partition already formatted with the label "persistence", you should only need to configure what to persist there. Let's do that.
root@host:~# mkdir /tmp/sdX4 root@host:~# mount /dev/sdX4 /tmp/sdX4 root@host:~# nano /tmp/sdX4/persistence.conf
- Edit the content of /tmp/sdX4/persistence.conf :
/home /root /etc /bin union /sbin union /srv union /usr union /var union
- Cleanup
root@host:~# umount /tmp/sdX4 root@host:~# rmdir /tmp/sdX4
Additional Packages
After the Debian LIVE boot, you can install additional packages, for instance:
sudo apt-get update sudo apt-get install gcc g++ make autoconf automake cmake git git-gui gitk geany diffuse kdiff3-qt
References
- https://www.debian.org/devel/debian-live/
- https://manpages.debian.org/stretch/live-boot-doc/live-boot.7.en.html
- http://www.linuxquestions.org/questions/linux-general-1/installing-grub2-on-pendrive-dev-sdb1-4175477710/
- http://www.normalesup.org/~george/comp/live_iso_usb/
- https://github.com/thias/glim/blob/master/grub2/inc-debian.cfg
See also
- Knoppix with persistence: [1]