Create a Custom Debian Live Environment (CD or USB)
These are steps that I used on an Ubuntu 12.04 (precise) 64-bit system to build an i386 Debian Wheezy live environment that I can boot from CD or USB
Warning: I have highlighted all the places you should be in the chroot environment. You should be in chroot for steps 5 - 10. I will leave it to you to figure out that you are in the right environment. The hostname of your chroot will be the same as your local machine by default so don’t rely on hostname to be sure which environment you are in. Be careful! Running some of these commands on your local environment instead of in the chroot can cause issues.
You should also be careful about deleting the chroot and your working folder. Make sure you unmount all mounted file systems before trying to delete anything.
Install applications we need to build the environment.
Setup the base Debian environment. I am using wheezy for my distribution and i386 for the architecture. Please do change your mirror if you are not in the U.S. or know of a mirror close to you.
A couple of important steps before we chroot.
Chroot to our Debian environment.
chroot
Set a few required variables and system settings in our Debian environment. You should be able to copy and paste this whole block into a terminal to save you some time.
chroot
Set a custom hostname for your Debian environment.
chroot
Figure out which Linux Kernel you want in your live environment.
chroot
I chose the 3.2.0-4-486 Kernel. I also believe live-boot is required. Everything else was a program of my choosing.
chroot
Set the root password (my only user will be root in the live environment)
chroot
Clean up our Debian environment before leaving. You should be able to copy and paste this whole block into a terminal to save you some time.
Unmount dev from the chroot
Make directories that will be copied to our bootable medium.
Compress the chroot environment into a Squash filesystem.
Prepare our USB/CD bootloader. You should be able to copy and paste these lines into a terminal to save you some time.
Create a menu for the isolinux bootloader. Create a text file at image/isolinux/isolinux.cfg with this content.
Create a bootable medium
CD
Copy files necessary for the ISO to boot and then create the ISO
Now burn the ISO to a CD and you should be ready to boot from it and go.
USB
Copy files necessary for the USB to boot and copy the environment to the USB drive (I am assuming you have an umounted FAT32 formatted USB drive /dev/sdf and the BOOT flag is set on /dev/sdf1 and you have a ready mount point at /mnt/usb)
You should be able to copy and paste this block into a terminal to save you some time.
Now unmount the drive and you should be ready to boot from it and go.
The goal of these steps and my work were to make a relatively small Linux live environment with applications that I often need when live booting. You can adapt these steps to customize your environment however you like. The man page for debootstrap is a helpful resource.
I also used these guides for help LiveCDCustomizationFromScratch Debian Current live-build Manual Syslinux How Tos Syslinux Common Problems: Missing Operating System Ubuntu Precise live-build man page
The process for creating a live Debian environment has been documented by other more knowleadgeable people, but of all the guides I looked at no one had every step I needed. I decided to document my steps in case anyone else might find them useful.
I have not tested any variation on these instructions nor have I tested building on any other system than my own. Please let me know in the comments if you have any feedback or suggestions.
If you are wondering why I did not use live-build I will say that I fought with live-build 3.0~a24-1ubuntu32.5 for several evenings before I admitted defeat.
I could write a whole new post about the problems I had with that, but if anyone is curious, and if I can avoid going on too long of a tanget, this solved my biggest issue with that version of live-build.
In the config/binary_local-hooks directory create this hook script and make it executable.
Even with that hook to properly setup the vmlinuz and initrd so that the live.cfg menu was accurate, I was never able to get a package list working or otherwise install packages of my choosing.
I don’t know why precise 12.04 installs a version of live-build that appears to be unstable. I worked with it for several evenings and I ran into a lot of problems. Much of the documentation I found was either inaccurate or inappropriate for that version of live-build.
I have since tested live-build 2.0.12-1 on a Debian VM and saw a generic build worked. I wish I had tested on another platform earlier or tried another version of live-build so I could see that it can work and does work well. I believe live-build is the right way to build a Debian live envionrment, and my instructions are needlessly long, but like I said, my version of live-build would not cooperate.
I am aware that there is an online live-build tool for building a Debian live distribution. I tried it and I used the provided configuration options and got an email an hour later saying my build failed with no specifics. I am sure the tool does work but at that point I had given up on live-build.
Although I wasted a few evenings I was able to get a good lesson in deboostrap, chroot, and how Debian live environments work. I hope these instructions can help you too.


