Nethence Newdoc Olddoc Lab Your IP BBDock  

Setting up a NetBSD XEN Guest

Prepare the Guest (seek on Linux only)

Fetching the to-be-shared material,

mkdir -p /data/guests/netbsd71
cd /data/guests/netbsd71

wget http://ftp.fr.netbsd.org/pub/NetBSD/iso/7.1.1/NetBSD-7.1.1-amd64.iso
wget http://ftp.fr.netbsd.org/pub/NetBSD/iso/7.1.1/SHA512
grep NetBSD-7.1.1-amd64.iso SHA512
sha512sum NetBSD-7.1.1-amd64.iso

wget http://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-7.1.1/amd64/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz
wget http://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-7.1.1/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
wget http://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-7.1.1/amd64/binary/kernel/SHA512
grep netbsd-INSTALL_XEN3_DOMU.gz SHA512
sha512sum netbsd-INSTALL_XEN3_DOMU.gz

Creating 4GB disk, 8 cores and 256MB of RAM,

guest=rescue
mkdir -p /data/guests/$guest
cd /data/guests/$guest
dd if=/dev/zero of=$guest.disk bs=1024k count=1 seek=4096
grep ^proc /proc/cpuinfo 
cat > $guest <<-EOF
kernel = "/data/guests/netbsd71/netbsd-INSTALL_XEN3_DOMU.gz"
#kernel = "/data/guests/netbsd71/netbsd-XEN3_DOMU.gz"
memory = 256
name = "$guest"
vcpus = 2
disk = [ 'file:/data/guests/$guest/$guest.disk,sda,w',
         'file:/data/guests/netbsd71/NetBSD-7.1.1-amd64.iso,hdc,r' ]
vif = [ 'vifname=$guest.0, bridge=xenbr0' ]
root = "xbd0a"
EOF

Ready to go

Create a GNU/Screen session as wheeled user,

cd /data/guests/
screen -ls
screen -S xen

launch the netbsd guest installation,

cd $guest/
xl create $guest -c

then install NetBSD on xbd0 using cdrom at xbd1a. Once the system is installed, switch the kernel parameter from the installer to the ending production one. Then run the guest normally and tune some shit,

cp -pi /etc/rc.conf /etc/rc.conf.dist
vi /etc/rc.conf

wscons=no
sshd=yes

vi /etc/ttys

and put all terminals to off but the console.

ref. https://wiki.xenproject.org/wiki/How_to_install_a_NetBSD_PV_domU_on_a_Debian_Squeeze_host_(Xen_4.0.1)

rescuing a netbsd guest

from another guest, say rescue,

disk = [ 'file:/data/guests/rescue/rescue.disk,sda,w',
     'file:/data/guests/sec/sec.disk,sdb,w',
         'file:/data/guests/netbsd71/NetBSD-7.1.1-amd64.iso,hdc,r' ]

fsck /dev/rxbd1a 
mkdir /lala
mount /dev/xbd1a /lala

SPECIAL ROUTING

For some special Failover IP usage (think of Dedibox/Online.net),

vif = [ 'vifname=netbsdsec.0, mac=00:16:3e:XX:XX:XX, bridge=xenbr0' ]

Note. no proxy_arp nor ip_forward are needed, this is bridge.

And in the netbsd guest,

XEN_HOST=x.x.x.x
ISP_GW=x.x.x.x
FAILOVER_IP=x.x.x.x

route add -net $XEN_HOST/32 -link -cloning -iface xennet0
ping -c1 $XEN_HOST

route add -net $ISP_GW/32 -link -cloning -iface xennet0
ping -c1 $ISP_GW

route add default $ISP_GW -ifa $FAILOVER_IP
ping -c1 8.8.8.8

netstat -rn -f inet

vi /etc/ifconfig.xennet0

inet FAILOVER_IP/32 up
!/sbin/route add -net XEN_HOST/32 -link -cloning -iface xennet0
!/sbin/route add -net ISP_GW/32 -link -cloning -iface xennet0
!/sbin/route add default ISP_GW -ifa FAILOVER_IP

Note. eventually add a route to the whole subnet instead of XEN_HOST + ISP_GW.

And if you need a fake switch for the guests on this only to communicate with each other,

brctl addbr dummybr0
ifconfig dummybr0 ...

vif = [ 'vifname=$guest.0, bridge=xenbr0',
    'vifname=$guest.1, bridge=dummybr0' ]

Refs.

LVM

An alternative is to use LVM instead of a sparse file, which makes even more sense on a NetBSD dom0 as the dd seek option is not available,

lvm pvcreate /dev/rsd1d
lvm vgcreate guestsvg "/dev/rsd1d"
lvm lvcreate -n netbsdguest1 -L 5G guestsvg

'phy:/dev/mapper/guestsvg-netbsdguest1,0x03,w',
'file:/root/NetBSD-7.0.1-amd64.iso,0x04,r'

References


Home | GitHub | Docker Hub | Donate | Contact