## Setup a virtual kernel environment A couple of steps are necessary in order to prepare the system to build and run a virtual kernel. ### Setting up the filesystem The vkernel architecture needs a number of files which reside in `/var/vkernel`. Since these files tend to get rather big and the `/var` partition is usually of limited size, we recommend the directory to be created in the `/home` partition with a link to it in `/var`: mkdir /home/var.vkernel ln -s /home/var.vkernel /var/vkernel Next, a filesystem image to be used by the virtual kernel has to be created and populated (assuming world has been built previously): dd if=/dev/zero of=/var/vkernel/rootimg.01 bs=1m count=2048 vnconfig -c -s labels vn0 /var/vkernel/rootimg.01 disklabel -r -w vn0s0 auto disklabel -e vn0s0 # add 'a' partition with fstype `4.2BSD' size could be '*' newfs /dev/vn0s0a mount /dev/vn0s0a /mnt Assuming that you build your world before, you can populate the image now. If you didn't build your world see [chapter 21](../updating-makeworld.html). cd /usr/src make installworld DESTDIR=/mnt cd etc make distribution DESTDIR=/mnt Create a fstab file to let the vkernel find your image file. echo '/dev/vkd0s0a / ufs rw 1 1' >/mnt/etc/fstab echo 'proc /proc procfs rw 0 0' >>/mnt/etc/fstab Edit `/mnt/etc/ttys` and replace the console entry with the following line and turn off all other gettys. console "/usr/libexec/getty Pc" cons25 on secure Then, unmount the disk. umount /mnt vnconfig -u vn0 ### Compiling the virtual kernel In order to compile a virtual kernel use the VKERNEL kernel configuration file residing in `/usr/src/sys/config` (or a configuration file derived thereof): cd /usr/src make -DNO_MODULES buildkernel KERNCONF=VKERNEL make -DNO_MODULES installkernel KERNCONF=VKERNEL DESTDIR=/var/vkernel ### Enabling virtual kernel operation A special sysctl(8), `vm.vkernel_enable`, must be set to enable vkernel operation: sysctl vm.vkernel_enable=1 To make this change permanent, edit `/etc/sysctl.conf`