malabar // netbsd with the brutal ffs flavor

bsd/ffs | xen guest

this guide has been implemented as a script

Brutal FFS or EXT2FS on a BSD Partition (THE RIGHT WAY)

Setting up NetBSD/XEN on EXT2FS vdisk image instead of FFS vdisk image is almost the same. The main difference is that the formating may be done from the dom0, and then BSD partition d should be used.

The FFS vdisk image will however be READ-ONLY by default on most GNU/Linux systems as the CONFIG_UFS_FS_WRITE kernel feature is not compiled in. Fortunately we use to have that additional kernel configuration enabled. It can otherwise be mounted read-write from a FreeBSD rescue system with no specific mount argument.

guest=netbsdffs
#guest=netbsdextfs

mkdir -p /data/guests/$guest
cd /data/guests/$guest
dd if=/dev/zero of=$guest.ffs bs=1000k count=0 seek=5000
#dd if=/dev/zero of=$guest.ext2 bs=1000k count=0 seek=5000
#mkfs.ext2 $guest.ext2
#mkfs.ext2 -O^dir_index,^ext_attr $guest.ext2
#tune2fs -l netbsdextfs.ext2

grep ^proc /proc/cpuinfo | tail -1
cat > $guest <<-EOF
kernel = "/data/kernels/netbsd${rel%%\.*}/amd64/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz"
#kernel = "/data/kernels/netbsd${rel%%\.*}/amd64/binary/kernel/netbsd-XEN3_DOMU.gz"
#root = "xbd0a"
#root = "xbd0d"
memory = 2048
#memory = 7168
name = "$guest"
vcpus = 16
disk = ['tap:tapdisk:aio:/data/guests/$guest/$guest.ffs,xvda,w']
#disk = ['tap:tapdisk:aio:/data/guests/$guest/$guest.ext2,xvda,w',
vif = [ 'bridge=xenbr0,vifname=$guest.0',
    'bridge=xenbr0,vifname=$guest.1' ]
EOF

#   'tap:tapdisk:aio:/data/ISO-IMAGES/netbsd.iso,xvdb,r']

Note. providing the DOS partition xvda1 instead of xvda does not make any difference in contrary to linux guest setups. NetBSD fdisk xbd0 still shows no DOS partition at all and its size remains identical. So I simply stick with xvda.

xl create $guest -c

exit sysinst and proceed

^C

#dhclient xennet0
#mount -t nfs x.x.x.x:/data/tftpboot /cdrom

dmesg | grep ^xbd
fdisk xbd0
disklabel xbd0
newfs /dev/rxbd0a
mount /dev/xbd0a /mnt
#mount -t ext2fs /dev/xbd0a /mnt
#mount -t ext2fs /dev/xbd0d /mnt

mkdir /cdrom
mount_cd9660 /dev/xbd1a /cdrom
cd /cdrom/amd64/binary/sets
#cd /cdrom/i386/binary/sets

all sets but x and kern

for set in `ls -1 *.tgz | sed -rn '/^[^xk]/p'`; do
    echo -n extracting $set to /mnt...
    tar xzphfe $set -C /mnt && echo done
done; unset set

chroot /mnt
cd /dev
./MAKEDEV all
ls -l pty* opty*
./MAKEDEV pty # ./MAKEDEV: pty: unknown device
./MAKEDEV opty

cd /etc
ls -l localtime
ls -l ../usr/share/zoneinfo/Europe/Moscow
ln -sf ../usr/share/zoneinfo/Europe/Moscow localtime
#ln -sf ../usr/share/zoneinfo/Europe/Paris localtime

vi /etc/fstab

/dev/xbd0a / ffs rw 0 1
#/dev/xbd0d / ext2fs rw 0 1
ptyfs /dev/pts ptyfs rw 0 0 
tmpfs /tmp tmpfs rw 0 0
#procfs /proc procfs ro,linux 0 0

chpass -s /bin/ksh root
useradd -D -s /bin/ksh

network setup

echo inet x.x.x.x/xx up > /etc/ifconfig.xennet0
echo x.x.x.x > /etc/mygate
vi /etc/hosts

x.x.x.x netbsdffs 
x.x.x.x gw

cat > /etc/resolv.conf <<-EOF
search sne.lan
nameserver x.x.x.x
#nameserver 208.67.222.222
#nameserver 208.67.220.220
EOF

and see guest-netbsd-tuning

^D
umount /mnt
cd ~/
umount /cdrom
sync
halt -p

You will then be able to mount the thing from the dom0 for templating or maintenance (you might avoid chrooting into it, though),

mkdir lala
mount -t ufs -o loop,rw,ufstype=44bsd $guest.ffs lala

If you get this error,

mount: /data/guests/ufs/lala: WARNING: device write-protected, mounted read-only.

==> you did not enable UFS writes in your Linux kernel, but you can still mount it as ro.


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