Skip to content

Instantly share code, notes, and snippets.

@jperkin
Last active September 11, 2018 15:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jperkin/5243605 to your computer and use it in GitHub Desktop.
Save jperkin/5243605 to your computer and use it in GitHub Desktop.
Creating a NetBSD VM on SmartOS

Instructions for building a NetBSD VM

Install

vmadm create < netbsd-install.json
vmadm list
zoneuuid=...
cp NetBSD-6.0-amd64.iso /zones/$zoneuuid/root/netbsd.iso
vmadm boot $zoneuuid order=cd,once=d cdrom=/netbsd.iso,ide
vmadm info $zoneuuid vnc

You can now VNC to vnc.host:vnc.port as per the output of the vmadm info command, and perform the OS install.

Once the install is done, 'poweroff' in the VM.

Create image

Take a snapshot of the installed image, update the image manifest with the image size and SHA1, then install it.

zfs snapshot zones/$zoneuuid-disk0@snap
zfs send !$ | gzip >netbsd6-0.0.1.zvol.gz
ls -l !$
digest -a sha1 !$
vi netbsd6-0.0.1.json # add size and sha1
imgadm install -m netbsd6-0.0.1.json -f netbsd6-0.0.1.zvol.gz

Create new VMs

Finally, now that the image is installed, we can create as many NetBSD images from it as we want.

vmadm create < netbsd.json
{
"brand": "kvm",
"autoboot": false,
"ram": 512,
"disks": [
{
"boot": true,
"model": "virtio",
"size": 2048
}
],
"nics": [
{
"nic_tag": "admin",
"model": "virtio",
"ip": "dhcp"
}
]
}
{
"v": 2,
"uuid": "93bfa14a-931c-11e2-88ec-abddd29e435d",
"owner": "0ca387a2-92d2-11e2-b623-6b615ec71835",
"name": "netbsd-6.0-amd64",
"version": "0.0.1",
"state": "active",
"disabled": false,
"public": true,
"published_at": "2013-03-23T00:00:00Z",
"type": "zvol",
"os": "netbsd",
"files": [
{
"sha1": "f577ab706ffd4567fae09858a1da3ddcce272542",
"size": 59148086,
"compression": "gzip"
}
],
"description": "NetBSD/amd64 6.0 Minimal Install",
"urn": "smartos:jperkin:netbsd-6.0-amd64:0.0.1",
"requirements": {
"networks": [
{
"name": "net0",
"description": "public"
}
],
"ssh_key": true
},
"acl": [],
"nic_driver": "virtio",
"disk_driver": "virtio",
"cpu_type": "qemu64",
"image_size": 2048
}
{
"brand": "kvm",
"autoboot": true,
"ram": 512,
"alias": "netbsd6",
"disks": [
{
"boot": true,
"model": "virtio",
"image_uuid": "93bfa14a-931c-11e2-88ec-abddd29e435d",
"image_size": 2048
}
],
"nics": [
{
"nic_tag": "admin",
"model": "virtio",
"ip": "dhcp"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment