Building Debian CD-ROMS Part 1 - dfsbuild
Posted by Steve on Sun 24 Apr 2005 at 16:25
dfsbuild is a relatively recent tool which allows you to build livecds based upon Debian. It's intended purpose is to allow you to install Debian from scratch, but because it is a simple means of building livecds it is useful for people who use Debian and don't wish to reinstall.
This is the first of two systems we're going to look at for building directly bootable, custom, Debian CD-ROMs the other being bootcd next time.
Installing the software is as simple as running:
root@mystery:~# apt-get install dfsbuild Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed: apt-move cdebootstrap libdebian-installer-extra4 libdebian-installer4 The following NEW packages will be installed: apt-move cdebootstrap dfsbuild libdebian-installer-extra4 libdebian-installer4 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 1131kB of archives. After unpacking 3316kB of additional disk space will be used. Do you want to continue? [Y/n]
Once the package is installed you'll find the default configuration created and placed in the file /etc/dfsbuild/dfs.cfg.
The configuration file contains details of the repositories you wish to use, for downloading software from along with details of the packages you wish to install upon your new system.
By default the image includes testing, stable, and unstable repositories and builds the image against packages from testing. I changed this by updating the configuration to read:
# Repositories to mirror. Details about each one are configured below. dlrepos = testing # Repository to build the CD with. Must be in above list. suite = testing
This saves you from mirroring packages from systems you don't care about.
As I'm running on an x86 system I also removed all references to amd64 from the default configuration file, once that was done I had to tell the software where it should mirror the relevent packages from. This is as simple as adding a line next to the relevent repository:
[repo testing] suite = testing mirror = http://http.us.debian.org/debian
The only other thing I had to do was update the following section which tells the build script which kernel to use. The kernel here comes from my local filesystem - so you'll either have to download it, or update the file:
# Debs from local fs to unpack on live FS (will not be configured) unpackdebs = /var/cache/apt/archives/kernel-image-2.6.8-2-k7_2.6.8-13_i386.deb
The other thing you might wish to adjust is the list of packages which are to be included in the image:
# Packages to install on live FS, on all archs, besides base system allpackages = util-linux mkisofs cdrecord dvd+rw-tools ocaml hugs ghc6 perl vim nano joe libncurses5-dev ftp ssh telnet elinks less zip unzip tar info man-db manpages-dev manpages cdebootstrap diff patch gawk tcpdump bash devfsd module-init-tools modutils rsh-client tftp traceroute iputils-tracepath strace iputils-ping iptraf iproute ipchains ipfwadm iptables ifupdown dhcp-client bind9-host whois dnsutils rsync rdiff-backup mutt netcat cpio buffer alien bzip2 dpkg-dev devscripts busybox-static dash sash pciutils hotplug discover buffer cramfsprogs minicom hdparm ntpdate disktype ddrescue umsdos recover dpkg-repack devscripts debhelper emacs21-nox mtr-tiny python-dev build-essential g++ wget lftp lynx cu debconf grep-dctrl lsof sysutils epic4 screen gnupg dfsbuild less sudo
These pacakgs are enough to test that the software works, and also have a useful system afterwards. By default the configuration file contained a few packages which weren't installable from testing, such as ext2-resize, this is another reason why my configuration file contains fewer packages than those in the default setup.
(My complete configuration file can be studied for reference).
Once the configuration file has been amended for your preferences you can then build the CD-ROM with the following command:
dfsbuild -c /etc/dfsbuild/dfs.cfg dir
The directory you give should be empty it is wiped with no prompting as the imaging creation process starts.
dfsbuild will download the named repositories and packages to place upon the CD-ROM, and then proceed to build the bootable image.
All being well the bootable image will be found in the working director you specified image.iso.Tweaking Things
Testing The Image
As well as just including raw packages from the Debian mirror of your choice you can also create files and directories upon the bootable image, append data to existing files, remove files, or create symbolic links.
In my configuration file you can see examples of each of these operations.
For example I create the /etc/resolve.conf file specific to my home network so that DNS lookups will work on the booted system.
Creating a file is as simple as placing the following in the configuration file:[createfiles] /etc/hostname = bootablesystemshostname [createfiles] /etc/resolve.conf = search my.flat search 192.168.1.1
You can also append to existing files with the following:[appendfiles] /etc/network/interfaces = iface eth0 inet dhcp iface eth1 inet dhcp iface eth2 inet dhcp iface wlan0 inet dhcp iface wlan1 inet dhcp iface wlan2 inet dhcp iface ath0 inet dhcp
Finally symbolic links can be created as you can see in the sample configuratoin file:[symlinks] /etc/mtab = /proc/mounts
What would you use it for?
If you have Qemu installed you can test out your new image without booting a real machine:qemu -boot c -cdrom image.iso
Warning: using transparent compression. This is a nonstandard Rock Ridge extension. The resulting filesystem can only be transparently read on Linux. On other operating systems you need to call mkzftree by hand to decompress the files.
If you're wondering what you'd use a bootable Debian CD-ROM for then here are a couple of suggestions:
- Use as a rescue disk in case you render your machine unbootable.
- Use to install Debian on a new machine.
- Creating a booting disk which will serve as a webserver, mounting the documents its serving via NFS.
- Acting as a proxy server, or traffic sniffer in a simple manner.
- Testing a potentially compromised machine without disturbing it.
There are many other possible uses!