HOWTO Debian Live
Contents |
How to have YOUR debian in almost every PC – Debian live-helper
WARNING: you cannot run this in shellium.org – root/sudo is needed for this.
So, you like Debian and have some personal settings you like. But your girlfriend don't want Linux installed in her PC and most of your friends use other distros you don't like and/or don't want you to mess with their computers... No problem, just bring your Debian Live CD like system in your pocket, in a USB pen, reboot, and feel like at home everywhere. You can use it as a rescue system too.
Debian live-helper was created to help you to build a Debian Live CD or USB. It is very good and helps you to setup your debian Live the way you want through scripts (called hooks) and preseeding debconf questions (to install packages with personalized settings). It needs a lot of free space and root/sudo privileges.
Installation
You will need an installed Debian system to start. Install the live-helper package. The one in lenny repos is fine, but the latest one is better.
# echo “deb http://live.debian.net/debian/ sid/snapshots main contrib non-free” >> /etc/apt/sources.list # echo “deb-src http://live.debian.net/debian/ sid/snapshots main contrib non-free” >> /etc/apt/sources.list # wget http://live.debian.net/debian/project/openpgp/archive-key.asc -O - | apt-key add - # apt-get update # apt-get install live-helper
Configuration And Testing
Create and cd to a work directory:
$ mkdir my-livecd $ cd my-livecd
To create a simple test Live system (no X, just shell, like in a debian minimal/standard install):
$ lh_config # lh_build
lh_config will create a config/ directory with some very simple default settings in very commented files that can be edited by hand. lh_build will download the packages from the debian repository, install them in a chroot, apply hooks and other things in the chroot and then create an ISO file to be burned in a CD/DVD. Once it's done, test it with qemu/kvm or virtualbox or vmware (qemu/kvm can also boot .img files).
Rebuilding
Each time you want to rebuild the live-cd to include some changes, you'll have to run:
# lh_clean # lh_build
The process will repeat, but this time the packages downloaded before will be reused from a cache directory where they were saved at the first run.
Example USB image with Xfce
Now for real, let's build a Debian Lenny with Xfce live USB image and some extra stuff:
# lh_clean $ lh_config --architecture i386 --categories "main contrib non-free" --packages-list xfce
You can find more packages lists for gnome, kde and others in /usr/share/live-helper/lists/. The i386 architecture boots on 32 and 64 bits processors.
Add some more packages you'd like:
$ lh_config --packages “irssi screen pidgin xchat”
Rebuild:
# lh_build
Customizations
You can make changes to the system interactively during the build process in a shell, using interactive shell parameter.
# lh_clean $ lh_config --interactive shell # lh_build
A prompt will appear during the build process. Make the changes you want and then log out with “exit” to finish the build process. To disable interactive shell again for unattended builds run 'lh_config --interactive disabled'.
The real fun starts when you create scripts (hooks) to automate those customizations. Add the following example script inside config/chroot_local-hooks/, make it executable and then rebuild (more hooks in /usr/share/live-helper/hooks/):
#!/bin/sh echo "HOOK: ssh server" # install apt-get install --yes --force-yes -y openssh-server # disable root login echo "I: disabling root login in ssh" sed -i "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config # don't start ssh on boot (safer) update-rc.d -f ssh remove
Now rebuild. To add some files to the user $HOME directory, copy them to config/chroot_local-includes to the /etc/skel directory (a better alternative is to use persistence, look down this page):
# lh_clean $ mkdir -p config/chroot_local-includes/etc/skel $ cp -ra ~/.irssi config/chroot_local-includes/etc/skel/ # lh_build
Installing in USB pen
To build and install an USB image:
# lh_clean --binary $ lh_config -b usb-hdd #lh_build
Now you can copy the resulting image file to the USB pen – BE CAREFUL: ALL DATA WILL BE ERASED!
$ dd if=binary.img of=/dev/sdz
where /dev/sdz is the usb pen. To know what device is your USB pen, verify it plugging in the USB pen and running the dmesg command. In the dd command do not use a partition (like in /dev/sdz1), use the whole pen (/dev/sdz). Please be sure about the USB pen device, or you can end up wipping your harddisk!
Persistent
To save changes between boots (a.k.a. live persistence), create a new partition with the remaining free space in the pen and change the label of the new partition to “home-rw”. Boot with the “persistent” boot option to use it. Now the changes in $HOME will survive. They can be used again booting with “persistent” again.
Installing To Hard Disk
One of the advantages of live-helper is being closely linked to Debian, Debian Policy and to Debian-Installer. Once you have selected the packages you want and have the system setup/configured the way you want with your hooks and preseeds, you can use the livecd (ISO, not USB img - it will be available to USB img soon) to actually install this system to hard disk with debian-installer (d-i) as with a normal official Debian CD.
The installer work normally (language selection, partitioning) but when it comes to installing the system, it will extract the live system to disk, then remove the live addons and install a bootloader. It is actually much faster that the normal installation, because it doesn't have to unpack all the deb packages.
Links
Much more in http://debian-live.alioth.debian.org/, http://wiki.debian.org/DebianLive/FAQ and http://live.debian.net/manual/html/index.html.
Have fun.