KVM guest // NetBSD

assuming kvm is up and running already

vnc then serial

either launch the installation with graphics to switch to serial thereafter

guest=netbsd
port=5999

virt-install \
    --name $guest \
    --ram 128 \
    --disk path=/data/kvm/$guest.qcow2,size=2,bus=virtio \
    --vcpus 1 \
    --os-type generic \
    --os-variant generic \
    --network bridge=virbr0,model=virtio \
    --graphics vnc,port=$port \
    --console pty,target_type=serial \
    --cdrom /data/ISO-IMAGES/NetBSD-9.1-amd64.iso

com0/115200 boot blocks

/bin/ksh
no cgd
no raidframe

and in case you need to add some nic

virsh edit $guest

    <interface type='bridge'>
      <source bridge='dummybr0'/>
      <model type='virtio'/>
    </interface>

the MAC address will be defined and XML config will be updated accordingly

serial right away

or use the boot-com.iso to start from serial console right away!

wget -O - http://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-7.1.1/amd64/installation/cdrom/boot-com.iso > /data/guests/ISO-IMAGES/boot-com.iso
wget -O - http://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-7.1.1/amd64/installation/cdrom/SHA512 > /data/guests/ISO-IMAGES/SHA512.netbsd.bootcom

virt-install \
    --virt-type kvm \
    --name netbsdserial \
    --ram 128 \
    --disk path=/data/kvm/netbsdserial.qcow2,size=2,bus=virtio \
    --vcpus 1 \
    --network bridge=virbr0,model=virtio \
    --graphics none \
    --console pty,target_type=serial \
    --accelerate \
    --noautoconsole \
    --cdrom /data/ISO-IMAGES/boot-com.iso \
    --cpu host

during the installation, choose com0 and baud rate as for boot blocks, and you are good to continue with virsh console already.

Note. the only drawback with the boot-com.iso method is that you will have to provide another source than CDROM as for the installation sets (e.g. network through vioif0). The command,

/sbin/mount -rt cd9660 /dev/cd0a /mnt2

does not work during the installation when using boot-com.iso (83M instead of 374M for the full one).

Resources

https://raymii.org/s/articles/virt-install_introduction_and_copy_paste_distro_install_commands.html#Generic_ISO

https://imil.net/blog/2016/01/29/netbsdamd64-7-0-kvm/

http://mikhailian.mova.org/node/81

https://wiki.qemu.org/Hosts/BSD


GUIDES | LECTURES | BENCHMARKS | SMTP HEALTH