Howto Debian Live – Build your own Squeeze based distro


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.

Installation
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/syslinux/themes/debian-squeeze/isolinux-live’

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.d

Then create a file called “live_build” and add the Pin:

vim live-build

Package: live-helper
Pin: release a=squeeze
Pin-Priority: 900 

Package: live-build
Pin: release a=squeeze
Pin-Priority: 900 

Now add the Squeeze Live Build to your sources.list:

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 update

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:

su
password

mkdir my-livecd

cd my-livecd

To create a simple test Live system (no X, just shell):

lb config

And you should end up with this directory structure:

|– binary_debian-installer

|– binary_grub

|– binary_local-debs

|– binary_local-hooks

|– binary_local-includes

|– binary_local-packageslists

|– binary_local-udebs

|– binary_rootfs

|– binary_syslinux

|– chroot_apt

|– chroot_local-hooks

|– chroot_local-includes

|– chroot_local-packages

|– chroot_local-packageslists

|– chroot_local-patches

|– chroot_local-preseed

|– chroot_sources

|– includes

`– templates

The 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_config

The 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 clean

lb build

The 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 clean

lb config –architecture i386 –archive-areas “main contrib non-free” –packages-list xfce

You 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]

The i386 architecture boots on 32 and 64 bit processors.

Add some more packages you’d like:

lb config –packages “irssi screen obmenu obconf iptraf vim”

Rebuild

lb build

Customizations
You can make changes to the system interactively during the build process in a shell, using interactive shell parameter.

lb clean

lb config –interactive shell

lb 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:

lb config –interactive disabled

Create 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/):

#!/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.

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:

lb clean

mkdir -p config/chroot_local-includes/etc/skel

cp -ra ~/.config/openbox config/chroot_local-includes/etc/skel/

lb build

Installing to USB pendrive:

lb clean –binary

lb config -b usb-hdd

lb build

Now copy the resulting image file to the USB pen drive

dd if=binary.img of=/dev/sdb

Where /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.

Debian guides:
http://debian-live.alioth.debian.org/,
http://wiki.debian.org/DebianLive/FAQ,
http://live.debian.net/manual/html/index.html,
http://www.debianuserforums.org/viewtopic.php?f=9&t=185.

Advertisements

15 thoughts on “Howto Debian Live – Build your own Squeeze based distro

  1. i have an error come ( Malformed line 1 in source list /etc/apt/sources.list.d/virtualbox.list (URI parse)) plz give any sugestions from anyone.
    thanks

  2. Thanks

    For recreating my same distro squeeze, installed onto my hdd
    with all the package/program present on hdd, how can I do?

    Thanks

    Regards

  3. Hi Rich

    I have been trying to encrypt the squafs with the lh config -e 256aes, but in squeeze the aes module dos not exist anymore.

    Have you by any chance messed around with this problem, and maybe have a solution for it?

    Thanks in advanced, Michael

  4. Simply because I would like to store some private files in the homedir with links and so fourth, to use with webbanking etc. Then it would be nice to make sure that if I ever lost the USB pen drive, no one would be able to extract the data. To bad you dont know any tricks but thanks anyway 🙂

    Now that I am here, could you tell me how to make a password for the default user “Debian Live user” I know how to give the “root” account a password through a script, but I have been unsuccessful with the default user.

    Again, thank for your time 🙂

  5. Michael (and anyone reading),

    In the “lb config” step, you can simply pass a parameter of “–encryption aes256”. The full revised command is:

    lb config –encryption aes256

    This will cause you to be prompted for an encryption password during the build, and the resulting image will require that you enter the same password to boot.

  6. is it possible to create a custom debian live disc with debian live? or do you have to install debian to the hard disk and run the live-build commands?

    I tried to install debian on my desktop at home and it had issues with the video driver and I couldn't ever figure out how to get it running…
    is there some sort of driver pack that I could install so the live cd works on as many systems as possible?

  7. Hi Anonymous,
    Creating your own “respin/distro” is pretty complicated and requires quite an in depth knowledge of the Linux operating system.
    If you are at the stage where you still have problems with graphic card drivers, I would suggest focusing on learning Debian in depth and running it for a while before attempting to create a Live CD.

    There are other easier solutions for more user friendly distros like Ubuntu, and you may want to look at http://www.remastersys.com/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s