Hello FreeBSD lovers.
today I want to show you a qemu setup that I'm working on as a nice alternative to WSL2 (even because WSL2 does not support FreeBSD,but only Linux and that's not good. FreeBSD has the same dignity of Linux).
First of all I've developed this setup because I want to use FreeBSD even when I'm using Windows.
Another reason is because, when I use Windows,I can't access the information stored on my ZFS disks.
There are some tools that allow you to mount a ZFS disk directly in Windows,but I see that's not a good idea to install it because Windows crashes often. So,with my setup I've fixed this problem once for all.
I can avoid the installation of the driver ZFS for Windows because I can mount the ZFS pool directly inside FreeBSD and I can easily share the information stored there in both the systems : Windows and FreeBSD itself,even avoiding the crashes.
Once I can access the data inside the zfs disks within FreeBSD,it's easy to share this data with Windows.
I can easily set up a tunnel using sshfs.
I've cloned a physical installation of FreeBSD 14 by creating its img file with dd. The goal is to virtualize FreeBSD 14 on Windows 11 with qemu using the Hyper-V as hypervisor. The parameters that I've used to launch the vm are the following ones :
It works well,even Xorg and Xfce4. In addition,I have passed a ZFS physical disk to the vm,so that I can use it within the FreeBSD system. So,first of all I needed to find a tool that allows to Windows to recognize that kind of disk. The tool that I found is here :
https://github.com/openzfsonwindows/openzfs/releases/tag/zfswin-2.1.99
And luckily it worked and it seems stable. I've mounted the zfs disk using the command :
It mounted the zpool and it mapped it as H: drive. Anyway,the tool creates a NTFS disk.
Secondarily I have installed these tools :
1) sshfs-win-3.5.20357-x64
2) winfsp-2.0.23075
and I have configured sshfs like this :
Within the FreeBSD vm I have installed the package fusefs-sshfs and I've mounted the root of Windows as a fuse fs like this :
and voila',I can use the zroot disk that I've mounted on Windows directly inside the FreeBSD vm :
As a last 3 instructions :
a) I've installed the port "utouch-kmod" (needed to fix the mouse movements) and I got the information to add the kernel module to /boot/loader.conf. I didn't get any information when I have installed the package.
b) inside the FreeBSD vm I have installed the vmware graphic driver and I've reconfigured xorg with the command "Xorg -configure"
c) inside the rc.conf there isn't any need to add the vmware kernel module.
UPDATE :
Taking in consideration the disk I want to share is 10 and the partition 2,as you can see below :
the path of the disk to add to qemu is : \\.\PhysicalDrive10
So,I tried to pass it to qemu using this parameter :
-snapshot is used if you don't want to risk to damage the disk.
and...it worked. Then I've been able to mount the ZFS disk in FreeBSD and not in Windows and zfswin is not needed at all.
So,the working qemu parameters are the following :
That's all. I hope that this tutorial will be useful for someone...
today I want to show you a qemu setup that I'm working on as a nice alternative to WSL2 (even because WSL2 does not support FreeBSD,but only Linux and that's not good. FreeBSD has the same dignity of Linux).
First of all I've developed this setup because I want to use FreeBSD even when I'm using Windows.
Another reason is because, when I use Windows,I can't access the information stored on my ZFS disks.
There are some tools that allow you to mount a ZFS disk directly in Windows,but I see that's not a good idea to install it because Windows crashes often. So,with my setup I've fixed this problem once for all.
I can avoid the installation of the driver ZFS for Windows because I can mount the ZFS pool directly inside FreeBSD and I can easily share the information stored there in both the systems : Windows and FreeBSD itself,even avoiding the crashes.
Once I can access the data inside the zfs disks within FreeBSD,it's easy to share this data with Windows.
I can easily set up a tunnel using sshfs.
I've cloned a physical installation of FreeBSD 14 by creating its img file with dd. The goal is to virtualize FreeBSD 14 on Windows 11 with qemu using the Hyper-V as hypervisor. The parameters that I've used to launch the vm are the following ones :
Code:
qemu-system-x86_64w.exe -accel whpx -machine q35 \
-cpu kvm64,hv_relaxed,hv_time,hv_synic -m 8G \
-device vmware-svga,id=video0,vgamem_mb=16,bus=pcie.0,addr=0x1 \
-audiodev dsound,id=snd0 -device ich9-intel-hda -device hda-duplex,audiodev=snd0 \
-hda "FreeBSD-140-zfs.img" -rtc base=localtime -device usb-ehci,id=usb,bus=pcie.0,addr=0x3 \
-device usb-tablet -device usb-kbd -smbios type=2 -nodefaults -netdev user,id=net0 \
-device virtio-net-pci,netdev=net0,id=net0,mac=52:54:00:11:22:33 -device ich9-ahci,id=sata \
-bios "I:\OS\qemu\FreeBSD\OSX-KVM-master\OVMF_combined.fd"
It works well,even Xorg and Xfce4. In addition,I have passed a ZFS physical disk to the vm,so that I can use it within the FreeBSD system. So,first of all I needed to find a tool that allows to Windows to recognize that kind of disk. The tool that I found is here :
https://github.com/openzfsonwindows/openzfs/releases/tag/zfswin-2.1.99
And luckily it worked and it seems stable. I've mounted the zfs disk using the command :
Code:
c:\zpool import zroot-swap
It mounted the zpool and it mapped it as H: drive. Anyway,the tool creates a NTFS disk.
Secondarily I have installed these tools :
1) sshfs-win-3.5.20357-x64
2) winfsp-2.0.23075
and I have configured sshfs like this :
Within the FreeBSD vm I have installed the package fusefs-sshfs and I've mounted the root of Windows as a fuse fs like this :
Code:
sshfs -o Compression=no -o allow_root -o transform_symlinks marietto@192.168.1.5:/ /mnt/zroot-swap
and voila',I can use the zroot disk that I've mounted on Windows directly inside the FreeBSD vm :
As a last 3 instructions :
a) I've installed the port "utouch-kmod" (needed to fix the mouse movements) and I got the information to add the kernel module to /boot/loader.conf. I didn't get any information when I have installed the package.
b) inside the FreeBSD vm I have installed the vmware graphic driver and I've reconfigured xorg with the command "Xorg -configure"
c) inside the rc.conf there isn't any need to add the vmware kernel module.
UPDATE :
Taking in consideration the disk I want to share is 10 and the partition 2,as you can see below :
the path of the disk to add to qemu is : \\.\PhysicalDrive10
So,I tried to pass it to qemu using this parameter :
Code:
-drive file=\\.\PhysicalDrive10 -snapshot
-snapshot is used if you don't want to risk to damage the disk.
and...it worked. Then I've been able to mount the ZFS disk in FreeBSD and not in Windows and zfswin is not needed at all.
So,the working qemu parameters are the following :
Code:
qemu-system-x86_64w.exe -accel whpx -machine q35 \
-cpu kvm64,hv_relaxed,hv_time,hv_synic -m 8G \
-device vmware-svga,id=video0,vgamem_mb=16,bus=pcie.0,addr=0x1 \
-audiodev dsound,id=snd0 -device ich9-intel-hda -device hda-duplex,audiodev=snd0 \
-hda "FreeBSD-140-zfs.img" -drive file=\\.\PhysicalDrive10 -rtc base=localtime \
-device usb-ehci,id=usb,bus=pcie.0,addr=0x3 \
-device usb-tablet -device usb-kbd -smbios type=2 -nodefaults -netdev user,id=net0 \
-device virtio-net-pci,netdev=net0,id=net0,mac=52:54:00:11:22:33 -device ich9-ahci,id=sata \
-bios "I:\OS\qemu\FreeBSD\OSX-KVM-master\OVMF_combined.fd"
That's all. I hope that this tutorial will be useful for someone...
Attachments
Last edited: