XEN guest // netbsd with the full disk flavor

full | brutal-ffs | malabar-ffs | live migration

Preliminary Note

The XEN host system here as well as the serving NFS are assumed to be a GNU/Linux, to be able to create sparse disks or partitions (dd seek option and underlying ext4 file-system). One could still imagine using a NetBSD dom0 as long as the guest virtual disk or partition are up and running. This setup could also be adapted to QCOW2 images instead of sparse RAW images or by means of using network block devices instead of vdisks on NFS.

Requirements

fetching the to-be-shared material

mkdir -p /data/ISO-IMAGES/
cd /data/ISO-IMAGES/

rel=9.3
#mirror=ftp.ee
#mirror=http://ftp.fr.netbsd.org/pub/NetBSD
mirror=https://cdn.netbsd.org/pub/NetBSD

wget $mirror/iso/$rel/NetBSD-$rel-amd64.iso
wget -O - $mirror/iso/$rel/SHA512 | grep amd64.iso > NetBSD-$rel-amd64.iso.SHA512
cat *.SHA512
sha512sum *amd64.iso

mkdir -p /data/kernels/netbsd${rel%%\.*}/
cd /data/kernels/netbsd${rel%%\.*}/
rm -f SHA512 netbsd-INSTALL_XEN3_DOMU.gz netbsd-INSTALL_XEN3PAE_DOMU.gz netbsd-XEN3_DOMU.gz netbsd-XEN3PAE_DOMU.gz
wget $mirror/NetBSD-$rel/amd64/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz
wget $mirror/NetBSD-$rel/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
wget $mirror/NetBSD-$rel/amd64/binary/kernel/SHA512
grep netbsd-INSTALL_XEN3_DOMU.gz SHA512
grep netbsd-XEN3_DOMU.gz SHA512
sha512sum *.gz

The full disk flavor (THE WRONG WAY)

guest=netbsdapr2023

mkdir -p /data/guests/$guest/
cd /data/guests/$guest/

dd if=/dev/zero of=$guest.disk bs=1024k count=1 seek=4096
#10GB -- seek=10240

grep ^proc /proc/cpuinfo 
vi $guest

name = "$guest"

kernel = "/data/kernels/netbsd9/netbsd-INSTALL_XEN3_DOMU.gz"
#kernel = "/data/kernels/netbsd9/netbsd-XEN3_DOMU.gz"
#root = "xbd0a"

vcpus = 2
memory = 256
disk = ['tap:tapdisk:aio:/data/guests/$guest/$guest.disk,xvda,w',
    'tap:tapdisk:aio:/data/ISO-IMAGES/NetBSD-9.3-amd64.iso,xvdb,r']
#disk = ['phy:/dev/drbd/by-res/netbsdapr2023/0,xvda,w',

vif = [ 'vifname=$guest.0' ]

#type = "pvh"
#extra = "-s"

launch the guest system installation

cd /data/guests/$guest/
xl create $guest -c

then install NetBSD on xbd0 using cdrom at xbd1a.

When finished,

x: Exit Install System

halt -p

Ready to go

Then switch to the ending production kernel and eventually remove the ISO,

vi $guest

kernel = "/data/kernels/netbsd7/netbsd-XEN3_DOMU.gz"
root = "xbd0a"
#root = "xbd0d"

and eventually remove the vdisk pointing to the ISO.

Start the guest and check,

xl create $guest -c

dmesg | grep ^xbd
sysctl kern.timecounter.hardware
sysctl -a | grep xen
mount

Full disk flavor XEN specific post-installation (THE WRONG WAY)

cp -pi /etc/rc.conf /etc/rc.conf.dist
vi /etc/rc.conf

wscons=no
no_swap=yes
savecore=no
sshd=yes

cp -i /etc/ttys /etc/ttys.dist
vi /etc/ttys

console "/usr/libexec/getty Pc"         vt100   on secure
ttyE1   "/usr/libexec/getty Pc"         wsvt25  off secure
ttyE2   "/usr/libexec/getty Pc"         wsvt25  off secure
ttyE3   "/usr/libexec/getty Pc"         wsvt25  off secure

Rescuing a full disk flavored netbsd/xen guest (THE WRONG WAY)

from another guest, say rescue,

disk = ['tap:tapdisk:aio:/data/guests/rescue/rescue.disk,xvda,w',
        'tap:tapdisk:aio:/data/guests/sec/sec.disk,xvdb,w',
        'tap:tapdisk:aio:/data/guests/netbsd71/NetBSD-7.1.2-amd64.iso,xvdc,r' ]

fsck /dev/rxbd1a 
mkdir /lala
mount /dev/xbd1a /lala

LVM

An alternative is to use LVM instead of a sparse file, which makes even more sense on a NetBSD dom0 as the dd seek option is not available. However I am not sure LVM is stable enough on NetBSD and the true value-added pvmove is missing anyway. Maybe another means of managing block devices would be appropriate.

lvm pvcreate /dev/rsd1d
lvm vgcreate guestsvg "/dev/rsd1d"
lvm lvcreate -n netbsdguest1 -L 5G guestsvg

'phy:/dev/mapper/guestsvg-netbsdguest1,0x03,w',
'file:/root/NetBSD-7.0.1-amd64.iso,0x04,r'

References

architecture

The reality of a XenServer 64 bit dom0

https://web.archive.org/web/20161022065456/https://xenserver.org/discuss-virtualization/virtualization-blog/entry/the-reality-of-a-64-bit-dom0.html

sysprep

tmpfs fstab example https://wiki.netbsd.org/tutorials/how_to_install_a_server_with_a_root_lfs_partition/

ptyfs fstab example https://wiki.netbsd.org/tutorials/how_to_install_netbsd_on_a_power_macintosh_g4___40__grey__41__/

How to install a NetBSD PV domU on a Debian Squeeze host (Xen 4.0.1) https://wiki.xenproject.org/wiki/How_to_install_a_NetBSD_PV_domU_on_a_Debian_Squeeze_host_(Xen_4.0.1)

guest config

/usr/pkg/share/examples/xen/

storage

xl-disk-configuration - XL Disk Configuration Syntax https://xenbits.xen.org/docs/unstable/man/xl-disk-configuration.5.html

XL DISK CONFIGURATION https://xenbits.xen.org/docs/4.8-testing/misc/xl-disk-configuration.txt

Blktap2 https://wiki.xen.org/wiki/Blktap2

lvm

https://wiki.netbsd.org/guide/lvm/

https://wiki.netbsd.org/tutorials/how_to_use_lvm_on_netbsd/

troubles

Xen troubleshooting http://silas.net.br/tech/xen/xen-troubleshooting.html

qemu

https://notes.kergis.com/netbsd_on_OVH_baremetal.html


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