Foreword
Please use sysutils/mklivecd to easily create a custom NetBSD LiveCD and read this article to understand the details.Introduction
You may have various reasons to create a LiveCD- You want to create a custom installer for your application and distribute it to your customers
- You want to create a desktop enviroment and boot it off your CD, whenever you cannot access your own computer
- Or maybe you want to 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(8) will use this size when creating the output iso9660 filesystem.
The image will include a kernel with root file system inserted into it.
The old way
For i386, compile your custom kernel or use kernel configuration from /usr/src/sys/arch/i386/conf/INSTALL.Then do following:
Creating the directories
Create a directory where you will build your CD image and change to it.# mkdir -p /my_build/dir ; cd /my_build/dir
Copying your kernel
Copy your custom kernel to this directory.# cp /usr/src/sys/arch/i386/compile/obj/${MYKERNEL}/netbsd .
Creating the directory tree
Now create another directory with a custom directory tree with files needed to run NetBSD (/dev, /etc, /tmp, /var ).Creating the file system image
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 ).
Inserting the Image
Now 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 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
Editing /etc/disktab
This 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 system
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
Bootstrapping
Bootstrap your virtual disk:# /usr/sbin/installboot -v -m i386 -o timeout=3,console=pc -t ffs /dev/rvnd0a /usr/mdec/bootxx_ffsv1Note: 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 vnd0dCreate 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 Image
To 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 isodirNote: 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
The 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 cdboot
To compile cdboot, run:# cd /usr/src/sys/arch/i386/stand/cdboot ; make
Copying cdboot
This 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 kernel
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/
Creating the Iso Image
Create the Iso Image:# mkisofs -l -J -R -o livecd.iso -c boot.catalog -b cdboot -no-emul-boot isodirNotice the -no-emul-boot option. It's because the boot image is not an image of a floppy.
Getting it Ready
And now we're done. You can burn your ISO image file to a CD or DVD and have fun.Mounting the Image
Note: 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 /mntWhen you're done:
# umount /mnt # vnconfig -u vnd0d
That's all.
Thanks to Yazzy
No hay comentarios:
Publicar un comentario
Nota: solo los miembros de este blog pueden publicar comentarios.