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

tested on a Slackware current dom0 (Sep 2020)

Requirements

grab latest release tarballs

    mkdir -p /data/kernels/freebsd130/
    cd /data/kernels/freebsd130/
    wget https://download.freebsd.org/releases/amd64/amd64/13.0-RELEASE/kernel.txz
    wget https://download.freebsd.org/releases/amd64/amd64/13.0-RELEASE/base.txz

    rm -rf boot/ usr/
    tar xaf kernel.txz

grab latest release ISO image

mkdir -p /data/ISO-IMAGES/fbsd/
cd /data/ISO-IMAGES/fbsd/
wget https://download.freebsd.org/releases/ISO-IMAGES/13.0/FreeBSD-13.0-RELEASE-amd64-disc1.iso
ln -s FreeBSD-13.0-RELEASE-amd64-disc1.iso disc1.iso

Guest vdisk

mkdir -p /data/guests/freebsd/
cd /data/guests/freebsd/
dd if=/dev/zero of=freebsd.img bs=1G count=0 seek=25

Guest skeleton

ls -lhF /data/kernels/freebsd130/boot/kernel/kernel
vi freebsd

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

# booting from official kernel on UFS
#kernel = "/data/kernels/freebsd130/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 = 12
maxvcpus = 12
disk = ['tap:tapdisk:aio:/data/guests/freebsd/freebsd.img,xvda,w',
    'tap:tapdisk:aio:/data/ISO-IMAGES/fbsd/disc1.iso,xvdb,r']
vif = [ 'bridge=xenbr0, 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.

Ready to go

xl create freebsd -c

ping opendns.com

^]

Tuning

xc0

# 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.img
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*

TODO

play with ACPI

sysctl -a | grep acpi
hw.acpi.power_button_state

Troubleshooting

Cannot write changes to UFS2 from GNU/Linux without corrupting it

losetup --find --partscan --show freebsd.img
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.

Resources

xen

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

acpi

https://www.freebsd.org/doc/handbook/acpi-overview.html


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5
Copyright © 2022 Pierre-Philipp Braun