By yazzy[at]yazzy[dot]org Version 0.1.1 Created: Mon Jul 18 08:29 UTC 2005 Last change: Fri Jan 27 19:45 UTC 2006 How To Create NetBSD LiveCD? Introduction. You may have various reasons to create a LiveCD; - Create a custom installer for your application and distribute it to the customers. - Create a desktop enviroment and boot it off your CD whenever you cannot access your own computer. - Or maybe you have a diskless router and you want to run your operating system off your custom CD. Implementation. There are two ways to create a LiveCD running NetBSD. The "old" way is to create a boot floppy sized image. The boot image must be exactly the size of either a 1200, 1440 or a 2880 kB floppy, and mkisofs will use this size when creating the output iso9660 filesystem. The image will include a kernel with root file system inserted into it. For i386, compile your custom kernel or use kernel configuration from /usr/src/sys/arch/i386/conf/INSTALL. Then do following: - Create a directory where you will build your CD image and cd to it. # mkdir -p /my_build/dir ; cd /my_build/dir - Copy your custom kernel to this directory. # cp /usr/src/sys/arch/i386/compile/obj/${MYKERNEL}/netbsd . - Create custom directory tree with files needed to run NetBSD (/etc, /var , /usr, etc.). - Create file system image from your directory tree for the LiveCD. # makefs -s ${FS_SIZE} -t ffs md.img ${IMG_DIR} ( where ${FS_SIZE} is the size of your md.img and ${IMG_DIR} is where you have your custom directory tree ). Now you need to insert the created image into your kernel, which will then get extracted off the kernel and mounted as memory file system: # mdsetimage -v -s netbsd md.img ( netbsd is the name of your kernel ) Compress your kernel to save space and rename it (optional step, the boot loader will also search for kernel named netbsd.gz): # gzip -f -9 netbsd ; mv netbsd.gz netbsd For vnconfig, newfs and disklabel to "understand" the notion of floppy288 you need to edit your /etc/disktab and add there: floppy288|2.88MB 3.5in Extra High Density Floppy:\ :ty=floppy:se#512:nt#2:rm#300:ns#36:nc#80:\ :pa#5760:oa#0:ba#4096:fa#512:ta=4.2BSD:\ :pb#5760:ob#0:\ :pc#5760:oc#0: Create virtual disk and file system on it. # dd if=/dev/zero of=image.fs count=5760 # vnconfig -t floppy288 -v -c /dev/vnd0d image.fs # disklabel -rw /dev/vnd0d floppy288 # newfs -m 0 -o space -i 204800 /dev/rvnd0a Bootstrap your virtual disk: # /usr/sbin/installboot -v -m i386 -o timeout=3,console=pc -t ffs /dev/rvnd0a /usr/mdec/bootxx_ffsv1 Note: use console=com0 if you want the boot output to be displayed to console instead of screen. Mount the virtual disk you just created and copy over your kernel and second stage boot loader. # mount /dev/vnd0a /mnt # cp /boot /mnt/ # cp netbsd /mnt/ # umount /mnt # vnconfig -u vnd0d Create a directory for your ISO image and copy your image there. # mkdir isodir/ ; cp image.fs isodir/ You can put some additional files to the isodir, they will be avaliable when you mounted your CD. Create ISO image: # mkisofs -l -J -R -o livecd.iso -c boot.catalog -b image.fs isodir Note: mkisofs has more options, you can e.g specify publisher id, preparer id, system ID etc. Burn your ISO image and have fun. The new way is to use cdboot file instead of boot floppy. This will allow you to use kernel beyond 2880 kB. To compile cdboot, run: # cd /usr/src/sys/arch/i386/stand/cdboot ; make This time we will not create a floppy image. We dont need it since we can use cdboot instead. Put cdboot to your isodir. # cp /usr/src/sys/arch/i386/stand/cdboot/cdboot isodir/ Copy over your kernel with rootfs inserted into it (as described in the "old way" section above) and second stage boot loader to your ISO directory: # cp netbsd isodir/ # cp /boot isodir/ Create ISO image # mkisofs -l -J -R -o livecd.iso -c boot.catalog -b cdboot -no-emul-boot isodir Notice the -no-emul-boot option. It's becouse the boot image is not an image of a floppy. Burn your ISO image file and have fun. You can also mount your ISO image insted of burning it to see what's on it: # vnconfig -v -c /dev/vnd0d livecd.iso # mount -t cd9660 /dev/vnd0a /mnt When you're done: # umount /mnt # vnconfig -u vnd0d Read also http://www.yazzy.org/docs/NetBSD/netbsd-on-cf.txt to learn more about creating your custom directory tree, creating and compiling your custom kernel. That's all folks. Marcin Jessa Check out http://www.wifibsd.org/ to download LiveCD version of wifiBSD - NetBSD and FreeBSD based router software.