Installing NetBSD on FFS2 from GNU/Linux

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

tested as XEN/PV(H) guest, not yet for bare-metal

Requirements

first grab the source and build the tools on GNU/Linux

    ls -lF /var/tmp/usr/tools/bin/nbmakefs

–or– eventually extract the tools you’ve prepared on another machine

wget https://lab.nethence.com/nunux/tools.tar.gz
mkdir /var/tmp/usr/
tar xzf tools.tar.gz -C /var/tmp/usr/
ls -lF /var/tmp/usr/tools/bin/nbmakefs
rm -f tools.tar.gz

Build the initial image

warning: we had to use --numeric-owner within the script only read UID/GID from the archive and NOT the owner and group names that would match with the system we’re on

second, also make binaries available into /data/kernels/

note this guide has been converted into a script

cd /data/templates/
wget https://pub.nethence.com/bin/xen/installffs.bash
wget https://pub.nethence.com/bin/xen/installffs.conf
chmod +x installffs.bash

define where you want the initial image to be deployed

vi installffs.conf

(tune options)

this assumes you have read-write access to UFS in your Linux kernel

./installffs.bash
ll netbsd-current.ffs
du -sh netbsd-current.ffs
# 915M

Write and expand the image to a vdisk

mkdir -p /data/guests/netbsd-current/lala/
cd /data/guests/netbsd-current/

assuming a DRBD resource

ll /dev/drbd/by-res/netbsd-current/0
dd if=/data/templates/netbsd-current.ffs of=/dev/drbd/by-res/netbsd-current/0 bs=4M status=progress

make sure you are still able to mount it read-write (works with FFSv1, not sure about FFSv2)

#mount -t ufs -o rw,ufstype=44bsd netbsd-current.ffs lala/
mount -t ufs -o rw,ufstype=44bsd /dev/drbd/by-res/netbsd-current/0 lala/
mount | grep ufs
ls -lF lala/

check the size expansion is enabled

cat lala/etc/rc.conf

eventually tune a few additional things

cat lala/etc/myname
cat lala/etc/hosts
vi lala/etc/ifconfig.xennet0

inet 10.1.0.99/16 up

vi lala/etc/mygate

10.1.255.254

vi lala/etc/resolv.conf

nameserver DNS1
nameserver DNS2

we absolutely need this folder to be created before-hand (see troubles section)

mkdir lala/root/.ssh/
vi lala/root/.ssh/authorized_keys

PASTE YOUR PUB KEY HERE

chmod 700 lala/root/.ssh/
chmod 600 lala/root/.ssh/authorized_keys

umount lala/
rmdir lala/

proceed with the expansion by booting it once (will eventually reboot by itself)

vi netbsd-current

kernel = "/data/kernels/netbsd-current/netbsd-XEN3_DOMU.gz"
root = "xbd0a"
memory = 1024
name = "netbsd-current"
vcpus = 2
disk = ['phy:/dev/drbd/by-res/netbsd-current/0,xvda,w']
vif = [ 'bridge=guestbr0,vifname=netbsd-current0',
    'bridge=guestbr0,vifname=netbsd-current1' ]

#disk = ['tap:tapdisk:aio:/data_local/guests/netbsd-current/netbsd-current.ffs,xvda,w']

    xl create netbsd-current -c

this will eventually make it reboot by itself. get back to it and proceed

xl console netbsd-current

df -h # space available?
ls -lF /var/db/postfix/ # check that a lock file could be written there

#ls -lF /var/db/entropy-file
#rndctl -S /var/db/entropy-file
#/etc/rc.d/random_seed start

ping -c1 opendns.com

vi /etc/rc.conf # disable resize_root
/usr/libexec/locate.updatedb
sync
^]

xl shu netbsd-current
cd ../

Troubleshooting

when trying larger volume 3g, 4g, 5g i.e

/var/tmp/usr/tools/bin/nbmakefs -t ffs -o v=2,o=time -s 5g slime.ffs2 tree/

gives

Calculated size of `slime.ffs2': 5368709120 bytes, 21246 inodes
Extent size set to 8192
slime.ffs2: 5120.0MB (10485760 sectors) block size 8192, fragment size 1024
    using 93 cylinder groups of 55.19MB, 7064 blks, 256 inodes.
super-block backups (for fsck -b #) at:
       32,   113056,   226080,   339104,   452128,   565152,   678176,
   791200,   904224,  1017248,  1130272,  1243296,  1356320,  1469344,
  1582368,  1695392,  1808416,  1921440,  2034464,  2147488,  2260512,
  2373536,  2486560,  2599584,  2712608,  2825632,  2938656,  3051680,
  3164704,  3277728,  3390752,  3503776,  3616800,  3729824,  3842848,
  3955872,  4068896,  4181920,nbmakefs: ffs_wtfs: seek error for sector 4294944: Invalid argument

when trying to mount it with 5.8.1 and UFS built-into the kernel

# mount -t ufs -o ro,ufstype=ufs2 netbsd.ffs2 lala/
mount: /data2/guests/netbsd/lala: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.

Sep 27 22:10:51 pro5s2 kernel: [326485.863237] ufs: ufs_fill_super(): bad magic number

this happens with ffsv2

# mount -t ufs -o ro,ufstype=44bsd netbsd.ffs2 lala/
mount: /data2/guests/netbsd/lala: mount(2) system call failed: Stale file handle.

first boot shows

random_seed: /var/db/entropy-file: Not present

while tuning the system read-write on UFS

kernel: ufs filesystem being mounted at /root/lala supports timestamps until 2038 (0x7fffffff)
kernel: ufs: error (device drbd1027): ufs_new_inode: cylinder group 0 corrupted - error in inode bitmap
kernel: ufs: ufs_fill_super(): fs is bad

==> happens on mkdir and file write – prepare folders before-hand and try avoid write during sysprep from the host

Resources

https://netbsd.gw.com/cgi-bin/man-cgi?makefs

make it an image sparse

https://wiki.archlinux.org/index.php/sparse_file

netbsd growfs

http://mail-index.netbsd.org/tech-toolchain/2020/08/09/msg003831.html


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