1 ## Setup a virtual kernel environment
5 A couple of steps are necessary in order to prepare the system to build and run a virtual kernel.
7 ### Setting up the filesystem
9 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`:
13 mkdir /home/var.vkernel
14 ln -s /home/var.vkernel /var/vkernel
16 Next, a filesystem image to be used by the virtual kernel has to be created and populated (assuming world has been built previously):
18 dd if=/dev/zero of=/var/vkernel/rootimg.01 bs=1m count=2048
19 vnconfig -c -s labels vn0 /var/vkernel/rootimg.01
20 disklabel -r -w vn0s0 auto
21 disklabel -e vn0s0 # add 'a' partition with fstype `4.2BSD' size could be '*'
23 mount /dev/vn0s0a /mnt
26 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).
31 make installworld DESTDIR=/mnt
33 make distribution DESTDIR=/mnt
36 Create a fstab file to let the vkernel find your image file.
40 echo '/dev/vkd0s0a / ufs rw 1 1' >/mnt/etc/fstab
41 echo 'proc /proc procfs rw 0 0' >>/mnt/etc/fstab
44 Edit `/mnt/etc/ttys` and replace the console entry with the following line and turn off all other gettys.
46 console "/usr/libexec/getty Pc" cons25 on secure
49 Then, unmount the disk.
58 ### Compiling the virtual kernel
60 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):
64 make -DNO_MODULES buildkernel KERNCONF=VKERNEL
65 make -DNO_MODULES installkernel KERNCONF=VKERNEL DESTDIR=/var/vkernel
69 ### Enabling virtual kernel operation
71 A special sysctl(8), `vm.vkernel_enable`, must be set to enable vkernel operation:
73 sysctl vm.vkernel_enable=1
76 To make this change permanent, edit `/etc/sysctl.conf`