Installing NetBSD on bare-metal through qemu-kvm

warning: the malabar guide provides a smarter way

Hardware

Tested on a Dedibox Start-1-M-SATA (XC 2015)

SuperMicro SuperServer 5038MA-H24TRF

Ready?

Start in rescue mode and switch to root,

sudo su -
#screen -S netbsd

English please, and no colors,

export LANG=C
export LC_MESSAGES=C
alias ll='ls -alkF'
echo 'syn off' >> ~/.vimrc

Freaking Ubuntu — it mounts the swap space if it finds one,

swapon -s
swapoff -a

We need a virtual machine to get the BSD environment — mainly for disklabel and installboot. We do not give a shit about libvirt and virt-install which fail to provide us a console, and we force boot on cdrom.

egrep 'vmx|svm' /proc/cpuinfo
apt update
export DEBIAN_FRONTEND=noninteractive
apt install -y qemu-kvm ksh
wget http://ftp.fr.netbsd.org/pub/NetBSD/iso/8.0/NetBSD-8.0-amd64.iso
#wget http://ftp.fr.netbsd.org/pub/NetBSD-daily/HEAD/201903080930Z/images/NetBSD-8.99.35-amd64.iso

dd if=/dev/zero of=/dev/sda bs=1M count=1

qemu-system-x86_64 \
    -m 2048 \
    -drive file=/dev/sda,format=raw \
    -cdrom NetBSD-8.0-amd64.iso \
    -boot d \
    -enable-kvm \
    -nographic -curses
#-hda /dev/sda

You might want to use -no-kvm if you have a VIA CPU — issues with VIA-VT.

Wait a few seconds until the keyboards responds (?), refresh the screen with ^L and proceed. Eventually use sysinst as usual BUT DEAL WITH THE ONE BIG ISSUE ABOUT 128GB QEMU vs NETBSD BUG, 25GB will be enough for BSD partition a. And keep b.

               a:         1     25000     25000 FFSv2      Yes   Yes   /   

and at the end

configure the network (and save it)
root shell /bin/ksh
disable cgd
disable raidframe

validate the completion screen – it then umounts the targetroot. You are now safe to brutally switch to NORMAL MODE from your Online.net customer console.

In case you need to get to the rescue system prompt again for some reason,

Ctrl-A X

and clean-up the mess in your terminal

reset
ps auxww | grep qemu

Maintenance

Boot FreeBSD 11.0 (in fact 11.1) rescue system and mount your NetBSD partition

fdisk ada0
bsdlabel -A ada0s1
gpart show ada0
#gpart list ada0
ls -lF /dev/ada0*
mount /dev/ada0s1 /mnt
#mount /dev/ada0s1a /mnt

Result (dmesg)

See http://tmp.nethence.com/dmesg/xc2015.txt.

Alternative Install Methods

dd the netbsd installer

about writing the installer to the disk on freebsd (no much space on temp disk)

fdisk ada0
bsdlabel ada0 # bsdlabel: /dev/ada0: no valid label found
gpart show
dd if=/dev/zero of=/dev/ada0 bs=1M count=1

wget -O - http://ftp.fr.netbsd.org/pub/NetBSD-daily/HEAD/201903080930Z/images/NetBSD-8.99.35-amd64-install.img.gz | zcat > /dev/ada0
sync

fdisk ada0
gpart show

or from linux system (lots of space on temp disk)

fdisk -l /dev/sda
dd if=/dev/zero of=/dev/sda bs=1M count=1
wget http://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-8.0/iso/NetBSD-8.0-amd64-install.img.gz
ls -lhF NetBSD-8.0-amd64-install.img.gz
zcat NetBSD-8.0-amd64-install.img.gz | dd of=/dev/sda status=progress
fdisk -l /dev/sda
sync

FreeBSD Bhyve

draft: this is just to keep a trace of that attempt – the installer kernel DOES NOT HAVE vmm.ko

kldstat
kldstat -v | grep vmm
kldload vmm # kldload: can't load vmm: No such file or directory
ls -lhF /boot/kernel/

It is even absent from kernel.txz release 11.1. An attempt could be made to build it and try to plug it to that running minimal kernel with kldload /path/to/vmm.ko.

freebsd-version
pkg update
pkg install pdksh vm-bhyve
ksh
set -o emacs
echo vm_enable="YES" >> /etc/rc.conf
echo vm_dir=/guests >> /etc/rc.conf
mkdir /guests/
vm init

What File-System?

This is in case there is an ext4 partition you wanted to keep. NetBSD has ext2fs support.

ext2: ext_attr resize_inode dir_index filetype sparse_super large_file
ext3: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
ext4: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file \
huge_file dir_nlink extra_isize

It is possible to revert an ext3 file-system to ext2. But ext4 cannot be reverted

tune2fs -O ^has_journal,^extent,^flex_bg,^huge_file,^dir_nlink,^extra_isize /dev/sda3

gives

Clearing filesystem feature 'extent' not supported.

w/o sysinst

Using sysinst or doing the installation manually does not matter much. The point is about using virtualization or being able to avoid it. But here’s some draft against wd0.

From the rescue system

(eventually prepare a DOS partition table)
(eventually build an ext2 file-system)

then from within the installer VM

dmesg | grep ^wd
dd if=/dev/zero of=/dev/rwd0d bs=1024k count=1
fdisk wd0
disklabel wd0
newfs /dev/rwd0a
mount /dev/wd0a /mnt
#mount -t ext2fs /dev/wd0d /mnt

Resources

Dedibox


Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml