How to build your own Debian
Debian live-build was created to help you to build a Debian Live CD or USB. There are other applications and scripts which allow you to respin/remaster, but live-build will help you buil a Debian-based distro "the Debian way".
Anybody can start with a base Debian and add a desktop environment and within around 30 minutes have their own Debian-based distro. It is that simple to use. A more experienced user could dig-in deep and add scripts, themes, wallpapers, specific applications and scripts.
You will need an installed Debian system to start. Install the live-build package.
*NOTE* sid-snapshot live-build error with squeeze builds
cp: cannot stat `/usr/share/Squeeze or Wheezy based distro?
If you want to build a Squeeze-based distro, use "squeeze-snapshots" to avoid the above error.
If you want to build Wheezy/sid-based distros, use the sid-snapshots repo. (live-build 3.0 is still under development, and therefore can break)
For Squeeze Pin the Squeeze Live-Build version:
cd /etc/apt/apt/preferences.dThen create a file called "live_build" and add the Pin:
Pin: release a=squeeze
Package: live-buildNow add the Squeeze Live Build to your sources.list:
Pin: release a=squeeze
echo deb http://live.debian.net/debian/ squeeze-snapshots main contrib non-free >> /etc/apt/sources.list
echo deb-src http://live.debian.net/debian/ squeeze-snapshots main contrib non-free >> /etc/apt/sources.list
wget http://live.debian.net/debian/project/keys/archive-key.asc -O - | apt-key add -
apt-get install live-build dosfstools genisoimage memtest86+ mtools parted squashfs-tools genext2fs mtd-tools sudo fakeroot uuid-runtime win32-loader syslinux syslinux-themes-debian syslinux-themes-debian-squeeze
Configuration And Testing
Create a work directory as Root:
cd my-livecdTo create a simple test Live system (no X, just shell):
lb configAnd you should end up with this directory structure:
`-- templatesThe Config Directory
lb config will create a CONFIG directory with some very simple default settings in commented files that can be edited by hand. This is where you will be adding your config files, packages (.debs) and the contents of your skel directory. This will probably be the most important directory for live-build distro builders.
Get lb config info from your Debian terminal:
man lb_configThe Build Command
lb build will download the packages from the debian repository, install them in a chroot, apply hooks and other things and then create an ISO file which you can burn or run virtually.
Editing/Adding/Removing and Rebuilding
Each time you want to rebuild the live-cd to include some changes, you’ll have to run:
lb buildThe process will be repeated, but this time the packages you downloaded before will be reused from a cache directory where they were saved the first time round.
Build an Xfce4 based Debian
Debian Squeeze with Xfce live USB image and some extra stuff: (These are straight commands that will add the information to the live-build scripts. Obviously you can edit the scripts themselves manually, and have all this preconfigured so that you run "lb build", go and have a coffee and come back to a shiny new Debian iso, alreday to be fired up in VirtualBox to test.
lb config --architecture i386 --archive-areas "main contrib non-free" --packages-list xfceYou can find more packages lists for gnome, kde and others in /usr/share/live/build/lists/.
debian-forensics debian-live-pxe-server gnome-core gnustep kde-extra lxde standard studio-gnome xfce debian-junior debian-science gnome-full kde kde-full minimal standard-x11 studio-kde xfce-junior debian-live-devel gnome gnome-junior kde-core kde-junior rescue studio studio-xfce [your-personal-list]
Add some more packages you’d like:
lb config –packages “irssi screen obmenu obconf iptraf vim”Rebuild
You can make changes to the system interactively during the build process in a shell, using interactive shell parameter.
lb config --interactive shell
lb buildA 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:
lb config --interactive disabledCreate Hooks to automate 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/):
echo "HOOK: ssh server"
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 removeNow rebuild.
Skel and the /home/user directory
To add some files to the user $HOME directory, copy them to config/chroot_local-includes to the /etc/skel directory:
mkdir -p config/chroot_local-includes/etc/skel
cp -ra ~/.config/openbox config/chroot_local-includes/etc/skel/
lb buildInstalling to USB pendrive:
lb clean --binary
lb config -b usb-hdd
Now copy the resulting image file to the USB pen drive
dd if=binary.img of=/dev/sdbWhere /dev/sdb is the usb pendrive.
Persistent Pendrive (Allows you to save files and settings)
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 to install your distro 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.