Creating a Debian Live Iso-Hybrid USB key
using a simple method explained step by step
You may find convenient to boot your system from a USB key or disk and enjoy your favorite programs instantly. However, Debian's Live iso-hybrid images do not provide persistance by default. This means that any changes made during the session (as the installation of new software) is lost when the session finishes. In this tutorial we shall explain how to add persistence to our iso-hybrid installation in a USB device. Take into account that we need a USB device with a storage capacity bigger than 1GB (Iso-Hybrid images are around 1GB). It is better to have a USB unit with a capacity at least 4 GB in order to be able to apply Debian's updates on the system later on.
First of all we need an Iso-Hybrid image. We will use the XFCE desktop so we download the file debian-live-7.0.0-amd64-xfce-desktop.iso from the Debian's site. We need to install some programs, so open a terminal and install the following:
sudo apt-get install gparted mbr dosfstools p7zip syslinux
and wait a bit for the installation of those programs.
Plug the USB device.
Make sure it is empty or contains nothing important.
All the files will be erased in this step!. Please make a copy of any important files you may have on the device.
Start gparted. In the right upper side you may access the USB device. Usually it is identified as /dev/sdb if you have a single hard disk in your system. We shall assume from now on /dev/sdb is our USB device. If in your system it is /dev/sdc or whatever, please take it into account from now on. Make sure you work with the intended USB device if you have several units working at the same time. Right click on the partition (usually indicated with a long rectangle with green color indicating a fat32 partition) and make sure it is unmounted.
We write a new partition table by going to Device -> Create Partition table. After writing the new partion table there are no partitions on the USB device. We need at least two partitions, one for the iso-hybrid image and a second one for persistence.
Our Iso-hybrid needs at least 926 MB. Then we prepare a fat32 partition with a size around 1.2GB, (so we have no trouble if we update the kernel later on), with label XFCE and boot flag. Do not forget the boot flag.
The rest of the unit may become our persistence partition. So we prepare an ext4 partition with label persistence. The label "persistence" is mandatory.
After applying all the changes make sure all partitions are unmounted. Close gparted and unplug the USB device.
Plug the USB device again and mount your /dev/sdb1 partition. Usually it is mounted on /media/usb0 (you can check that by using df or checking in gparted). We move to the folder /media/usb0:
and decompress in there the iso-hybrid:
7z x ~/Desktop/debian-live-7.0.0-amd64-xfce-desktop.iso
This may take long depending on the system and the USB device.
The syslinux bootloader configuration folder and files within it are named isolinux when installed on an ISO. You need to rename the directory and two files changing isolinux to syslinux so the bootloader will find them on your fat32 live image partition:
mv isolinux syslinux
mv syslinux/isolinux.cfg syslinux/syslinux.cfg
mv syslinux/isolinux.bin syslinux/syslinux.bin
Now, we append persistence to the live boot parameters:
sed -i 's/\(append boot=.*\)$/\1 persistence/' syslinux/live.cfg
This can be done also by editing the file live.cfg with your favorite editor. Mount your /dev/sdb2 partition (persistence). We need writing permision to make changes in the partition persistence. Since we used gparted (as root) to create the permissions we have to change the owner:
sudo chown username /media/persistence
where username is ... your user name! Now we turn on full persistence by putting "/ union" in a persistence.conf file in the persistence partition.
echo / union > persistence.conf
Unmount the partitions (you can use gparted). Then we use install-mbr to install an MBR (Master Boot Record) on the USB device and syslinux to install the bootloader to boot into the live image partition (XFCE partition with boot flag) .
syslinux -i /dev/sdb1
Finished!!! Now you stop the computer and boot from the USB device. After booting you may apply updates to the system and install your favorite programs in your customized Debian Live image.
When you use your Iso-Hybrid, you work with:
When the system boots, it does not ask you for a user name and password and you are automatically logged in. If you do not like this feature, you have to make changes in the configuration file of the display manager. For XFCE, the display manager is LightDM, so changes are easy to do. Edit the configuration file /etc/lightdm/lightdm.conf and make sure that after [SeatDefaults] you have this:
Next time you boot you can use your user name and password to log in.