Installing NetBSD on FFS2 from GNU/Linux

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

Requirements

Obtain NetBSD sets and kernel

And see the Building NetBSD from GNU/Linux chapter of the NetBSD cross-building guide.

Script

This guide has been converted into a script

cd /root/guests/
wget https://pub.nethence.com/bin/xen/installffs.bash.txt
mv installffs.bash.txt installffs.bash
chmod +x installffs.bash
vi installffs.bash

#current
name=netbsd
repo=/data/kernels/netbsd-current

./installffs.bash

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

Make sure you are still able to mount it (works with FFSv1, not sure about FFSv2)

cd netbsd/
mkdir lala/
mount -t ufs -o ufstype=44bsd netbsd.ffs lala/
mount | grep ffs
ls -lF lala/
cat lala/etc/rc.conf
echo ok > lala/ok
cat lala/ok
rm -f lala/ok
umount lala/
rmdir lala/

Finish-up & template

    xl create netbsd -c

this will make it reboot once

Created tmpfs /dev (1818624 byte, 3520 inodes)
Sun Oct 25 10:32:52 CET 2020
Starting root file system check:
/dev/rxbd0a: file system is clean; not checking
Resizing / (/dev/xbd0a)
reboot: rebooted by root

get back to it and proceed

xl console netbsd

ls -ldF /var/db/postfix/ # check ownerships

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

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

xl shu netbsd
tar cSf /data/templates/netbsd.ffs.tar netbsd.ffs
cd ../
rm -rf netbsd/

Troubles

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

# 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

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


GUIDES | LECTURES | BENCHMARKS | SMTP HEALTH