Plan9/Virtualisation
How to create an OpenBSD 6.8 VM on 9front using vmx(1) in 8 minutes…
Vmx(1) uses Intel VT-x through vmx(3) to simulate a virtual PC. Using vmx(1) you can run other operating systems as virtual machines on 9front.
Preparation
Make sure you read vmx(3) first to understand how to control a VM. Especially if your host machine does not have a lot of RAM ensure to stop and destroy a virtual CPU after shutting down your VM before starting a new VM instance, otherwise your system will crash.
After shutting down an OpenBSD VM by running halt
or some other command
and after vmx(1) returns to the terminal,
stop the virtual CPU and then destroy it:
term% echo stop >> '#X/0/ctl'
term% echo quit >> '#X/0/ctl'
If the VM disk (assuming it is a file) is stored on a cwfs
file
system it is advisable to mark it as a temporary file using chmod +t vm.disk
to avoid it being dumped to the worm
every night. Another
approach is to store the VM disk to the other
partition that is not
backed up.
OpenBSD 6.8 as a VM on 9front
Download
Download 6.8 install media from OpenBSD mirror:
term% mkdir /n/other/usr/$user/vm/bsd/o/amd64
term% cd /n/other/usr/$user/vm/bsd/o/amd64
term% hget https://cdn.openbsd.org/pub/OpenBSD/6.8/amd64/bsd.rd > bsd68.rd
term% hget https://cdn.openbsd.org/pub/OpenBSD/6.8/amd64/bsd > bsd68
term% hget https://cdn.openbsd.org/pub/OpenBSD/6.8/amd64/install68.img > install68.img
Install
Create virtual disk (the example creates a 20G disk):
term% cd /n/other/usr/$user/vm/bsd/o/
term% dd </dev/zero -of obsd.disk -bs 1 -count 1 \
-seek `{echo 20*1024*1024*1024-1 |pc -n}
Start the installation procedure (NOTE to install the VM use bsd.rd
):
term% cat install.rc
#!/bin/rc
ARCH=amd64
OBSD=68
echo stop >> '#X/0/ctl'
echo quit >> '#X/0/ctl'
vmx -M 1G \
-n ether0 \
-d obsd.disk \
-d $ARCH/install$OBSD.img \
-v vesa:1600x710 \
$ARCH/bsd$OBSD.rd
echo stop >> '#X/0/ctl'
echo quit >> '#X/0/ctl'
term% ./install.rc
Checkout the screencast on youtube as an example demonstrating how to chose the install media and other options if in doubt.
Run
After having installed the VM the following script can be used to run
it (NOTE to run the VM use bsd
):
term% cat $home/bin/rc/vm/start
#!/bin/rc
rfork e
ARCH=amd64
OBSD=68
DISK=/n/other/usr/$user/vm/bsd/o/obsd.disk
BSD=/n/other/usr/$user/vm/bsd/o/$ARCH/bsd$OBSD
fn VmxStop{
if(test -d '#X/0'){
echo stop >> '#X/0/ctl'
sleep 1
echo quit >> '#X/0/ctl'
sleep 1
}
}
fn VmxStart{
vmx -M 4G \
-n ether0 \
-d $DISK \
-v vesa:1600x710 \
$BSD 'device=sd0a'
}
VmxStop
VmxStart
VmxStop
term% vm/start
…
Good luck! You will need it…
And here is the above screencast on youtube: