Notes on building live CD

Have a look at pkgsrc/sysutils/mklivecd. It is a script maintained by NetBSD developer Juan RP for building a custom NetBSD i386 Live CD.

Also see the NetBSD Bootable CD ROM HOWTO at

For my script that I have used many times to build many live CDs, download A diff of the kernel config I've used under NetBSD/i386 1.6.x is netbsd-live-cd-kernel-config.diff. I use mount_null to make my read-write directories (using one /var/tmp memory file system). I had to patch the kernel sources because mount_null is broken. (This is not related to the i386live.iso distributed by NetBSD.)

The following notes are out-of-date. THIS IS OUT-OF-DATE.

(also have second NOTES files under /backups/netbsd on workstation)

Need base distribution with binaries

With /dev devices also, except:
#rm -rf ttyv* ptyp* ttyp* vga # which will be made later
# remove or move /dev directory -- init will create it
rm -rf /backups/destdir/dev


Boot from CD and mount the CD:
file-system     CD9660          # ISO 9660 + Rock Ridge file system
file-system UNION           # union file system
?Should I use "options MEMORY_DISK_IS_ROOT" and/or "options MEMORY_DISK_HOOKS"? maybe: config netbsd root on cd0a type ? config netbsd root on cd0a type cd0a dumps on none

Prepare files

# need a kernel at /netbsd or fstat and other tools won't work right
cp /usr/src/sys/arch/i386/compile/LIVECD/netbsd /backups/netbsd/destdir/
# remove devices that will be created later
#rm -rf destdir/dev/ttyv* destdir/dev/ptyp* destdir/dev/ttyp* #destdir/dev/vga
/var is really var.copy (to later copy to /var) and have a /var for mount point
touch destdir/etc/fstab


Before anything:
# 07/Mar/2002 reed - for livecd
mount_mfs -s 262144 swap /tmp
mount_mfs -s 262144 swap /home
mount_mfs -s 262144 -o union,rw swap /var
mount_mfs -s 262144 -o union,rw swap /root
mount_mfs -s 1m -o union,rw swap /etc
#mount_mfs -s 20480 -o union,noatime,rw swap /dev
#cd /dev && sh MAKEDEV vty12 pty0
#cp -R -p /var.copy/* /var
* should check for space ?? ** The above should be in /etc/fstab: like:
/dev/cd0c /     cd9660  ro,noatime                      0 0
#swap      /dev  mfs     rw,noatime,union,-s=12000       0 0
swap      /tmp  mfs     rw,nodev,noexec,nosuid,noatime,-s=262144  0 0
swap      /var  mfs     rw,-s=262144,noatime            0 0
swap      /etc  mfs     rw,noatime,-s=131072            0 0
swap      /home mfs     rw,noatime,-s=262144            0 0
cd /backups/netbsd/mybsd ; find . | cpio -vpdm /backups/netbsd/destdir

Build boot image

cd /backups/netbsd
dd if=/dev/zero of=myboot.fs count=5760
vnconfig -t floppy288 -v -c /dev/vnd0d myboot.fs
disklabel -rw /dev/vnd0d floppy288
newfs -B le -m 0 -o space -i 204800 -c 80 /dev/rvnd0a floppy288
/usr/mdec/installboot -v -f /usr/mdec/biosboot.sym /dev/rvnd0a
# maybe above installboot should use destdir/usr/mdec/ ...
mount /dev/vnd0a /mnt
#cp /backups/netbsd/release/binary/kernel/netbsd.GENERIC.gz /mnt/netbsd 
gzip -c -9 /usr/src/sys/arch/i386/compile/LIVECD/netbsd > /mnt/netbsd
chmod a+x /mnt/netbsd
umount /mnt
vnconfig -u vnd0d

build ISO9660

# according to mkhybrid it must be relative to the specified source path
# or it will say: Uh oh, I cant find the boot image!
cp myboot.fs destdir
mkhybrid -o output.iso -b myboot.fs -c boot.catalog \
 -a -l -J -r -L /backups/netbsd/destdir/
#maybe I should have used -m to exclude this myboot.fs image
**Later try mkisofs to see if it needs boot.fs within directory**

Creating the image (output.iso) took three minutes; it was 189 MB.

To look at it:

vnconfig -v -c /dev/vnd0d output.iso
mount -t cd9660 /dev/vnd0a /mnt
umount /mnt
vnconfig -u vnd0d

mkisofs has:

              Specifies that the boot image used  to  create  "El
              Torito" bootable CDs is a 'no emulation' image. The
              system will load and  execute  this  image  without
              performing any disk emulation.
       -boot-load-seg segment_address
              Specifies the load  segment  address  of  the  boot
              image for no-emulation "El Torito" CDs
       -boot-load-size load_sectors
              Specifies  the  number of "virtual" (512-byte) sec-
              tors to load in no-emulation mode.  The default  is
              to load the entire boot file.  Some BIOSes may have
              problems if this is not a multiple of 4.

burn the cd

cdrecord -v speed=4 dev=/dev/cd1c output.iso
MKISOFS?=       mkisofs
                -r -T -v \
                -P "The NetBSD Project" \
                -m "${RELEASEDIR}/installation/cdrom"
                -o ${RELEASEDIR}/installation/cdrom/netbsd-${MACHINE}.iso

-J Joliet directory records (64 Unicode chars long filenames)
-l allow 31 char filenames
-r uid/gid set to zero; sets all readable; and all executable if executable
-T generate TRANS.TBL file in each directory for non-Rock Ridge-capable systems
-v verbose
-P 128 char publisher ID / volume header (describe publisher, address, phone)
-m exclude glob or path from being written to CD
-o file to create
[pathspec] is the directory to copy into iso9660 filesystem
NetBSD Bootable CD ROM HOWTO original