Update awk version (was a typo)
[ikiwiki.git] / docs / user / vKernelSetup.mdwn
1 ## Setup a virtual kernel environment 
2
3
4
5 A couple of steps are necessary in order to prepare the system to build and run a virtual kernel.
6
7 ### Setting up the filesystem 
8
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`:
10
11     
12
13     mkdir /home/var.vkernel
14     ln -s /home/var.vkernel /var/vkernel
15
16 Next, a filesystem image to be used by the virtual kernel has to be created and populated (assuming world has been built previously):    
17
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 '*'
22     newfs /dev/vn0s0a
23     mount /dev/vn0s0a /mnt
24
25
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).
27
28     
29
30     cd /usr/src
31     make installworld DESTDIR=/mnt
32     cd etc
33     make distribution DESTDIR=/mnt
34
35
36 Create a fstab file to let the vkernel find your image file.
37
38     
39
40     echo '/dev/vkd0s0a      /       ufs     rw      1  1' >/mnt/etc/fstab
41     echo 'proc              /proc   procfs  rw      0  0' >>/mnt/etc/fstab
42
43
44 Edit `/mnt/etc/ttys` and replace the console entry with the following line and turn off all other gettys.
45
46     console "/usr/libexec/getty Pc"         cons25  on  secure
47
48
49 Then, unmount the disk.
50
51     
52
53     umount /mnt
54     vnconfig -u vn0
55
56
57
58 ### Compiling the virtual kernel 
59
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):
61     
62
63     cd /usr/src
64     make -DNO_MODULES buildkernel KERNCONF=VKERNEL
65     make -DNO_MODULES installkernel KERNCONF=VKERNEL DESTDIR=/var/vkernel
66
67
68
69 ### Enabling virtual kernel operation 
70
71 A special sysctl(8), `vm.vkernel_enable`, must be set to enable vkernel operation:
72
73     sysctl vm.vkernel_enable=1
74
75
76 To make this change permanent, edit `/etc/sysctl.conf`