I tried the VM a bit before expected

So I've done some porting of ptts, which is documented here, but it turns out it had a bug that needed fixing. This also means new release and that means recompiling. I don't have any Windows machine on me, so I had to do some VM experiments, which I planed to do a bit later into my FreeBSD journey.

At first, I tried the easy route and installed VirtualBox. It turns out that the port is broken however, and the kernel module does not support current version. Accorting to forums, recompiling should do the trick, but that would be a bit too much work (and dependencies) just to setup a program I plan on replacing.

bhyve

What is bhyve? Well, it stands for BSD hypervisor (somehow?). It's the FreeBSD's native virtualisation tool.

I didn't want to use it right now, because as you can see from the handbook entry, it's a complex tool that takes a LOT of arguments and configuration. I was saved however, as there are some frendlier frontends for all this.

I decided for vm-bhyve, because it feels simple and well documented. Also plain UFS support (which I have for reasons detailed in previous post).

I set up a VM mostly by just following the title page instructions and the Windows specific instructions.

I decided to have all VM stuff in '/vm/', as it can only be accessed by root, so it doesn't feel right to have it in my '$HOME'. I like how stuff comes in modules and you need to enable/setup them in '/etc/rc.conf', but it is a bit annoying to remove remove them.

I called:

sudo vm iso ~/Downloads/win10-install.iso
sudo vm create -t windows winguest
sudo vm install winguest win10-install.iso

The vm started in the background and nothing happened. This is because if you want to run a graphical VM, you have to use a VNC protocol. I installed TigerVNC and connected with the address 0.0.0.0:5900.

From there it was a normal Windows install, except that I had no internet. You see, vm-bhyve has problems with using Wi-Fi as a bridged network. To solve this, I had to create a NAT using the pf(4) tool and then create a vm-bhyve switch with no interface, but a IP of the default gateway of that network, as documented in the vm-bhyve manual.

I also tried the DHCP server, but it didn't work. No problem tho, as I can still set network information by hand.

Problems

Windows problems

I needed to install the crystal language. The crystal installer by itself is not enough however, as it also needs the Windows SDK.

Turns out the default 20GB disk was not enough for the Windows install, so I had to get a bigger disk. Thankfully, it was not that hard tho:

# create a 40GB file
truncate -s 40G disk1.img

# copy the data
dd if=disk0.img of=disk1.img conv=notrunc

I didn't manage to expand the partition however, so I had to reinstall anyways.

VM problems

I encountered this very strange bug, where the VM (or just the VNC?) would freeze and not even restarting the WM would fix it. I had to reboot the entire machine. This however only happened during the crystal installer, which I find quite strange.

Getting the data

I compiled the program, but now I needed to get the executable on my main system to make the github release. Normally I would start a simple python web server, but since it's behind a NAT, that was not a option. I decided to mount the disk instead.

long sotry short:

sudo mdconfig -a -t vnode -u 0 -f disk1.img
sudo ntfs-3g /dev/md0p3 /mnt

You will need to install and enable the 'fusefs-ntfs' package.

mdconfig(8) is used to create a virtual disk '/dev/md0' from the image file.

After further testing, I can say that

sudo mdconfig disk1.img

should be enough

If you ask why I wasn't able to expand the partition, this is the disk:

% gpart show /dev/md0
=>      34  83886013  md0  GPT  (40G)
        34      2014       - free -  (1.0M)
      2048    204800    1  efi  (100M)
    206848     32768    2  ms-reserved  (16M)
    239616  82571749    3  ms-basic-data  (39G)
  82811365      1563       - free -  (782K)
  82812928   1069056    4  ms-recovery  (522M)
  83881984      4063       - free -  (2.0M)

The new space extended the last 'free' space and Windows wasn't able to move 'ms-recovery'.

Summary

I actually quite like it.

I will conduct more experiments in the future.