|
|
Build your own NetBSD LiveCDFrom ezUnix
ForewordPlease use sysutils/mklivecd to easily create a custom NetBSD LiveCD and read this article to understand the details. IntroductionYou may have various reasons to create a LiveCD
This HowTo is for NetBSD 3.0 and newer and was tested on i386.
ImplementationThere are two ways to create a LiveCD running NetBSD.
The old wayFor i386, compile your custom kernel or use kernel configuration from /usr/src/sys/arch/i386/conf/INSTALL.
Creating the directoriesCreate a directory where you will build your CD image and change to it. # mkdir -p /my_build/dir ; cd /my_build/dir Copying your kernelCopy your custom kernel to this directory. # cp /usr/src/sys/arch/i386/compile/obj/${MYKERNEL}/netbsd .
Creating the directory treeNow create another directory with a custom directory tree with files needed to run NetBSD (/dev, /etc, /tmp, /var ). Creating the file system imageCreate 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 ). Inserting the ImageNow you need to insert the created image into your kernel, which will then get extracted off the kernel and mounted as a memory file system: # mdsetimage -v -s netbsd md.img ( netbsd is the name of your kernel ) Compressing the kernelCompress 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 Editing /etc/disktabThis part is not needed, if you use cdboot as described below in the new way part. 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:
Creating a file systemCreate 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 BootstrappingBootstrap 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. Creating the Iso ImageTo create the Iso Image, you will need mkisofs which is part of sysutils/cdrtools. # 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 wayThe new way is to use a cdboot file instead of a boot floppy. This will allow you to use kernels beyond the size of 2880 kB. Compiling cdbootTo compile cdboot, run: # cd /usr/src/sys/arch/i386/stand/cdboot ; make Copying cdbootThis time we will not create a floppy image. We don't need it, since we can use cdboot instead. Put cdboot to your isodir. # cp /usr/src/sys/arch/i386/stand/cdboot/cdboot isodir/ Copying the kernelCopy 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/ Creating the Iso ImageCreate the 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 because the boot image is not an image of a floppy.
Getting it ReadyAnd now we're done. You can burn your ISO image file to a CD or DVD and have fun. Mounting the ImageNote: You can also mount your ISO image instead 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
Additional InformationMore info on creating custom kernel images with root file system in them: http://www.yazzy.org/docs/NetBSD/netbsd-on-cf.txt Also check out the LiveCD version of wifiBSD - NetBSD and FreeBSD based router software. See also
|