Getting in deep with dfsbuild

Posted by malcolm on Sun 29 May 2005 at 03:55

Tags: none.

Steve's article Building Debian CD-ROMS Part 1 - dfsbuild convinced me that dfsbuild was the tool to put together a rescue CD for my laptop. The default configuration wasn't quite what I wanted, as my wireless card needs a patched kernel. I also needed to include some extra files so that networking would work "out of the box".

Making it happen involved getting elbow deep in the code that makes DFS work. As the DFS documentation doesn't cover these things, I thought I'd share what I found.

How to include extra files

The [createfiles] and [appendfiles] sections of the DFS config file dfs.cfg let you specify text to add to files on the CD image. Unfortunately, you can't include blank lines, or the characters "=" or ":". There's also no way to copy binary files to the image (I contacted DFS' author John Goerzen and now there is a wishlist bug #308876 filed about these limitations).

Luckily, there was another way to change the files included on the CD.

Modifying the CD image

When dfsbuild has finished, it doesn't erase the directory containing the files for the CD image. The root of the CD filesystem is the directory image under wdir, the dfsbuild working directory.

As long as you have specified the option compress = no in dfs.cfg, you can modify the files here to your heart's content before rebuilding the CD image.

If you want an i386 boot CD, the command to build an ISO image dfs.iso is

cd wdir
mkisofs -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 1 -boot-info-table -pad -R -o dfs.iso image

If you need a compressed image, you can still create one. Use the mkzftree command and then run mkisofs with the "-z" flag.

Using a custom kernel

I built my custom kernel using make-kpkg, so I included it on the CD using the unpackdebs command in dfs.cfg. Like the standard Debian kernels, my kernel boots using an initial RAM disk initrd.

It turns out that DFS has its own special initrd, and that the initrd from the kernel package is ignored. This means that your kernel should have built-in drivers for mounting the root file system from the CD, not modules (i.e. iso9660 and any necessary IDE/SCSI drivers).

This didn't present a problem for me, so after adding a few key files and running mkisofs, I had a working DFS CD for my laptop.

Actually, that's a lie. Once I discovered that DFS had its own initrd, I had to satisfy my curiosity about what DFS was doing under the hood before I could go on with building my CD.

More DFS internals

The directory structure under image is the familiar Debian one. DFS has its own directories under /opt, including the RAM disk used for writable files once the system is running.

# RAM disk mount point
/opt/dfsruntime/runtimemnt
# files and directories to copy to the RAM disk
/opt/dfsruntime/runtimerd

The initrd image that mounts the root filesystem from CD and bootstraps the system is included at /opt/dfsruntime/initrd.dfs. You can inspect the contents of the initrd by mounting the image

cd wdir/image
mount -t cramfs -o loop opt/dfsruntime/initrd.dfs /mnt

One thing to note is that DFS' startup scripts are binaries. The DFS components and dfsbuild itself are written in the compiled functional programming language OCaml. The initrd startup script /sbin/init performs the equivalent of the following shell commands:

mount -n -t iso9660 -o ro cd_dev /realroot
cd /realroot
pivot_root . initrd
chroot .
# run the main DFS startup script
/opt/dfsruntime/startup

The main DFS startup script /opt/dfsruntime/startup completes the process with the following operations:

umount -n /initrd
mount -n -t tmpfs none /opt/dfsruntime/runtimemnt
cp -a /opt/dfsruntime/runtimerd/* /opt/dfsruntime/runtimemnt
echo "proc  /proc   proc    defaults        0 0\n" >/etc/fstab
# start the normal Linux init process
/sbin/init

As you can see, the operation of DFS is quite simple. DFS, bootcd and the various installer projects all have their strengths and weaknesses, so I expect there'll be some productive cross-fertilisation between them as they evolve.

 

 


Posted by malcolm (203.217.xx.xx) on Sun 29 May 2005 at 06:02
I forgot to mention that I used dfsbuild version 0.6.17.

Looking at the changelog for the current version, 0.6.19, there have been no significant changes in between.

[ Parent | Reply to this comment ]

Posted by Anonymous (84.133.xx.xx) on Wed 16 Aug 2006 at 00:37
I have searched a mailing list or forum for dfsbuild but I there is none, yet, so I post my problem here. I am using v0.99.0

I'd like to use a dfs for fileserving, so I need the samba package being installed, but the dfsbuild process breaks, because invoke.rc-d samba fails, when nmbd can't be started while setting up samba (3.0.22-1), the error message is

Starting Samba daemons: nmbdstart-stop-daemon: nothing in /proc - not mounted? (Success)
failed!
invoke-rc.d: initscript samba, action "start" failed.
dpkg: error processing samba (--configure):
subprocess post-installation script returned error exit status 1
...
Errors were encountered while processing:
samba
E: Sub-process /usr/bin/dpkg returned an error code (1)

I see no way to solve this problem with my little means. Maybe the author can say somthing about samba and dfsbuild?

[ Parent | Reply to this comment ]

Posted by Anonymous (84.133.xx.xx) on Wed 16 Aug 2006 at 00:55
Reply to myself and you: I decided to write a bug report because this problem is severe.

[ Parent | Reply to this comment ]

Posted by malcolm (61.95.xx.xx) on Wed 16 Aug 2006 at 02:20
Version 0.99.0 of dfsbuild represents a complete rewrite since the 0.6.* versions.

dfsbuild is now written in the Haskell programming language rather than OCaml (with different libraries etc), and things may work quite differently in the new version.

Sorry I'm not able to offer any advice.

[ Parent | Reply to this comment ]

Posted by Anonymous (84.133.xx.xx) on Sun 20 Aug 2006 at 15:58
Hi malcolm,
I repeated the build and when the process stopped because of the samba error, I chrooted to the target dir. I mounted /proc before executing /ect/init.d/samba start, and then no error occured anymore.

I am pretty shure that this is the solution for the error. Can you verify that and can you implement mounting /proc at dfsbuild?

[ Parent | Reply to this comment ]

Posted by malcolm (61.95.xx.xx) on Mon 21 Aug 2006 at 02:42
John Goerzen is the author of dfsbuild.

If you've submitted a bug report already, then he should be aware of the problem.

[ Parent | Reply to this comment ]

Posted by malcolm (61.95.xx.xx) on Sun 19 Nov 2006 at 23:19
For anyone interested in making a custom Debian rescue disk, I'd recommend a look at Debian Live.

It's young software, but clean, functional and easy to hack on. I recently used their minimal image as a USB flash rescue system.

[ Parent | Reply to this comment ]

Posted by mario (190.72.xx.xx) on Mon 19 Apr 2010 at 07:59
[ View Weblogs ]
dfsbuild has been removed from testing:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570272

The maintainer talks about "Debian Live scripts". I think that's live-helper.

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

What do you use for configuration management?








( 828 votes ~ 10 comments )