XEN/PVH FreeBSD guest (UFS & ZFS) using the installer

tested on a Slackware current dom0 (Sep 2020)


mkdir -p /data/kernels/freebsd-current/lala/
cd /data/kernels/freebsd-current/
wget http://ftp.free.fr/mirrors/ftp.freebsd.org/snapshots/ISO-IMAGES/13.0/...disc1.iso
ln -s ... disc1.iso
mkdir lala/
mount disc1.iso lala/
tar xJf lala/usr/freebsd-dist/kernel.txz


on the Lignux dom0

cd /data2/guests/freebsd/
dd if=/dev/zero of=freebsd.disk bs=1G count=0 seek=10
ls -lhF /data/kernels/freebsd-current/lala/boot/kernel/kernel
ls -lhF /data/kernels/freebsd-current/boot/kernel/kernel
vi freebsd

# booting from install cd
kernel = "/data/kernels/freebsd-current/boot/kernel/kernel"
extra = "vfs.root.mountfrom=cd9660:xbd1"

# booting from official kernel on UFS
kernel = "/data/kernels/freebsd-current/boot/kernel/kernel"
extra = "vfs.root.mountfrom=ufs:xbd0s1a"

# booting from custom ZFS kernel
kernel = "/data/kernels/kernel-zfs"
extra = "vfs.root.mountfrom=zfs:zroot/ROOT/default"

memory = 7168
name = "freebsd"
vcpus = 3
maxvcpus = 8
disk = ['tap:tapdisk:aio:/data2/guests/freebsd/freebsd.disk,xvda,w',
vif = [ 'bridge=br0, vifname=freebsd.0' ]
type = "pvh"

Note: no idea why xbd1 won’t show up in kernel’s dmesg while defining xvdb:cdrom in the guest configuration as usual.



# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/xbd0s1a    /               ufs     rw      1       1
/dev/xbd0s1b    none            swap    sw      0       0

ZFS post-install maintenance

Mount and rescue from the XEN dom0 host

losetup -a
losetup --find --partscan --show freebsdzfs.disk
ls -lF /dev/loop*
fdisk -l /dev/loop0
#/dev/loop0p3 4196352 20969471 16773120    8G FreeBSD ZFS

#zpool import -d /dev -R `pwd`/lala/ zroot freebsdzfs-zroot
zpool import -d /dev -R `pwd`/lala/ -a
#-o readonly=on -f
zpool list
zpool status

zfs mount
zfs mount zroot/ROOT/default

fix and rescue

vi lala/etc/fstab
vi lala/etc/ttys

and when finished

zpool export freebsdzfs-zroot
losetup -d /dev/loop0
ls -lF /dev/loop*


play with ACPI

sysctl -a | grep acpi


Cannot write changes to UFS2 from Lignux without corrupting it

losetup --find --partscan --show freebsd.disk
ls -lF /dev/loop*
mount -t ufs -o ufstype=ufs2,rw /dev/loop0p4 lala/
mount -t ufs -o ufstype=ufs2,rw /dev/loop4p4 lala/

gives at startup

Superblock check-hash failed: recorded check-hash 0x4f4ff20c != computed check-hash 0x631ba28f (Ignored)
/: inode 2: check-hash failed
Mounting from ufs:xbd0p4 failed with error 22.



FreeBSD PVH https://wiki.xen.org/wiki/FreeBSD_PVH

21.8. FreeBSD as a Xen™-Host https://www.freebsd.org/doc/handbook/virtualization-host-xen.html