tested on a Slackware current dom0 (Sep 2020)
We are considering FOUR way to deploy FreeBSD as a XEN/PVH guest:
The current guide is about for forth and brutal way. First, we need a kernel with ZFS built-in because we don’t have a loader here and we cannot load deliver the zfs
and opensolaris
modules. We then bootstrap the guest system from the XEN host/dom0, similarly to what we did with NetBSD and Slackware.
on the Lignux dom0
mkdir -p /data/kernels/freebsd-current/ cd /data/kernels/freebsd-current/ wget http://ftp.free.fr/mirrors/ftp.freebsd.org/snapshots/amd64/13.0-CURRENT/kernel.txz wget http://ftp.free.fr/mirrors/ftp.freebsd.org/snapshots/amd64/13.0-CURRENT/base.txz rm -rf boot/ usr/ tar xJf kernel.txz
on the Lignux dom0
ls -lhF /data/kernels/kernel-zfs vi freebsdzfs kernel = "/data/kernels/kernel-zfs" extra = "vfs.root.mountfrom=zfs:tank/root" memory = 7168 name = "freebsdzfs" vcpus = 3 maxvcpus = 8 disk = ['tap:tapdisk:aio:/root/guests/freebsdzfs/freebsdzfs.zfs,xvda,w'] vif = [ 'bridge=br0, vifname=freebsdzfs.0', 'bridge=br0, vifname=freebsdzfs.1' ] type = "pvh"
raw sparse file virtual disk
mkdir -p /root/guests/freebsdzfs/lala/ cd /root/guests/freebsdzfs/ dd if=/dev/zero of=freebsdzfs.zfs bs=1G count=0 seek=10
the kernel wants a GPT partition (GUID a504
)
cgdisk freebsdzfs.zfs Part. # Size Partition Type Partition Name ---------------------------------------------------------------- 1007.0 KiB free space 1 10.0 GiB FreeBSD ZFS zfs0 losetup -a losetup --find --partscan --show freebsdzfs.zfs #cannot work - kernel won't find it #zpool create tank `pwd`/freebsdzfs.zfs ls -lF /dev/loop* zpool create tank /dev/loop0p1 zpool list zpool status zfs get compression zfs set compression=lz4 tank zfs create -o mountpoint=`pwd`/lala/ tank/root zfs list zfs mount
slackpkg install libarchive bsdtar -xJ --numeric-owner -f /data/kernels/freebsd-current/base.txz -C lala/
no need for a valid file-system table unless you have swap, but still it’s good to have one, even empty, to avoid complains at system startup
vi lala/etc/fstab # Device Mountpoint FStype Options Dump Pass# #/dev/xbd0p2 none swap sw 0 0 vi lala/etc/ttys #ttyv0 "/usr/libexec/getty Pc" xterm onifexists secure xc0 "/usr/libexec/getty Pc" xterm onifexists secure zfs unmount `pwd`/lala/ zfs unmount /tank/ zfs mount rmdir lala/ zpool export tank zpool list losetup -a losetup -d /dev/loop0
Now that you got fstab
and ttys
alright
xl create freebsdzfs -c
ls -lF /etc/localtime ln -s ../usr/share/zoneinfo/Europe/Moscow /etc/localtime ln -s ../usr/share/zoneinfo/Europe/Paris /etc/localtime vi /etc/rc.conf ifconfig_xn0="inet 10.3.3.9 netmask 255.255.255.0 up" defaultrouter="10.3.3.1" hostname="freebsdzfs.localdomain" mv /etc/hosts /etc/hosts.dist vi /etc/hosts ::1 localhost localhost.localdomain 127.0.0.1 localhost localhost.localdomain # happy happy sendmail 10.3.3.9 freebsdzfs.localdomain freebsdzfs 10.3.3.1 gw 62.210.16.6 dns1 62.210.16.7 dns2 vi /etc/resolv.conf nameserver 62.210.16.6 nameserver 62.210.16.7 shutdown -r now
hostname ping -c1 opendns.com /usr/libexec/locate.updatedb date sync history -c rm -f .history shutdown -p now ^] xl des freebsdzfs
cd /root/guests/freebsdzfs/ mount -o remount,rw /data/ tar cSf /data/templates/freebsdzfs.zfs.tar freebsdzfs.zfs mount -o remount,ro /data/ cd ../ rm -rf freebsdzfs/
Chapter 19. The Z File System (ZFS) https://www.freebsd.org/doc/handbook/zfs.html
19.8. ZFS Features and Terminology https://www.freebsd.org/doc/handbook/zfs-term.html
ZFS Tutorials : Creating ZFS pools and file systems https://www.thegeekdiary.com/zfs-tutorials-creating-zfs-pools-and-file-systems/
How to Create ZFS File Systems https://docs.oracle.com/cd/E19253-01/819-5461/gayog/index.html
Creating a degraded raidz via sparse files https://www.ixsystems.com/community/threads/creating-a-degraded-raidz-via-sparse-files.18276/
Mount RAW Pool Image with ZFS on Linux https://wiki.orzfly.com/topics/zfs-on-linux-mount-raw-pool-image
Unmounting ZFS File Systems https://docs.oracle.com/cd/E19253-01/819-5461/gamnr/index.html
13.5. zfs mount/umount http://www.netkiller.cn/freebsd/filesystem/zfs.mount.html
Managing Devices in ZFS Storage Pools https://docs.oracle.com/cd/E19253-01/819-5461/gayrd/index.html
Custom Kernel build and ZFS prefetch https://lists.freebsd.org/pipermail/freebsd-questions/2015-February/264111.html
ZFS module parameters in Linux (OR kernel parameter in FreeBSD or zfs-in-kernel OS) https://billtian.github.io/digoal.blog/2014/06/25/03.html
Make ZFS depend on xdr.ko only. It doesn’t need kernel RPC. https://github.com/freebsd/freebsd/commit/77755bd98c42004a010540bd9b6c171a557337a2
12.2. FreeBSD Boot Process https://www.freebsd.org/doc/handbook/boot-introduction.html
loader – kernel bootstrapping final stage https://www.freebsd.org/cgi/man.cgi?query=loader
https://www.freebsd.org/doc/handbook/config-network-setup.html