Setting Up FreeBSD 9.1 With VirtIO On IaaS Platform

Setup notes for FreeBSD with VirtIO on Iaas platform of ProfitBricks, Berlin.

$ hdiutil convert -format UDRW -o FreeBSD.img FreeBSD-9.1-RELEASE-amd64-bootonly.iso
FREEBSD_INSTALL (Apple_ISO : 0) lesen...
..................................................................................................................................
(Apple_Free : 1) lesen …
Dauer: 1.293s
Geschwindigkeit: 113.0M Byte/s
Ersparnis: 0.0 %
created: /Users/rbe/Downloads/FreeBSD.img.dmg

How?

  1. Setup a server with storage, choose IDE as bus
  2. Add a CD/DVD with a FreeBSD image
  3. Install FreeBSD
  4. Add VirtIO drivers, change fstab
  5. Change bus settings from IDE to VirtIO
  6. Reboot

Install VirtIO drivers from http://people.freebsd.org/~kuriyama/virtio/9.1/virtio-kmod-9.1-0.242658.tbz

mount /dev/ad1p2 /mnt
kldload /mnt/boot/modules/virtio*.ko kldload /mnt/boot/modules/if_vtnet.ko

Boot FreeBSD using a hard drive attached through an IDE bus for your first boot:

root@free1:/root # dmesg
Copyright (c) 1992-2012 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
    The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 9.1-RC2 #0 r241106: Mon Oct  1 18:26:44 UTC 2012
    root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64

CPU: AMD Opteron 23xx (Gen 3 Class Opteron) (2200.15-MHz K8-class CPU)
  Origin = "AuthenticAMD"  Id = 0xf61  Family = f  Model = 6  Stepping = 1
  Features=0x783fbfd<FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>
  Features2=0x80802001<SSE3,CX16,POPCNT,HV>
  AMD Features=0x20100800<SYSCALL,NX,LM>
  AMD Features2=0xe5<LAHF,SVM,ABM,SSE4A,MAS>

real memory  = 1073741824 (1024 MB)
avail memory = 1009635328 (962 MB)

virtio_pci0: <VirtIO PCI Balloon adapter> port 0xc0a0-0xc0bf irq 11 at device 3.0 on pci0
vtballoon0: <VirtIO Balloon Adapter> on virtio_pci0
virtio_pci0: host features: 0x71000002 <EventIdx,RingIndirect,NotifyOnEmpty,StatsVq>
virtio_pci0: negotiated features: 0x0
virtio_pci1: <VirtIO PCI Block adapter> port 0xc000-0xc03f mem 0xfebf0000-0xfebf0fff irq 10 at device 5.0 on pci0
vtblk0: <VirtIO Block Adapter> on virtio_pci1
virtio_pci1: host features: 0x710006d4 <EventIdx,RingIndirect,NotifyOnEmpty,Topology,FlushCmd,SCSICmds,BlockSize,DiskGeometry,MaxNumSegs>
virtio_pci1: negotiated features: 0x10000254 <RingIndirect,FlushCmd,BlockSize,DiskGeometry,MaxNumSegs>
vtblk0: 10240MB (20971520 512 byte sectors)
virtio_pci2: <VirtIO PCI Block adapter> port 0xc040-0xc07f mem 0xfebf1000-0xfebf1fff irq 10 at device 6.0 on pci0
vtblk1: <VirtIO Block Adapter> on virtio_pci2
virtio_pci2: host features: 0x710006d4 <EventIdx,RingIndirect,NotifyOnEmpty,Topology,FlushCmd,SCSICmds,BlockSize,DiskGeometry,MaxNumSegs>
virtio_pci2: negotiated features: 0x10000254 <RingIndirect,FlushCmd,BlockSize,DiskGeometry,MaxNumSegs>
vtblk1: 20480MB (41943040 512 byte sectors)
virtio_pci3: <VirtIO PCI Network adapter> port 0xc0c0-0xc0df mem 0xfebf2000-0xfebf2fff irq 11 at device 7.0 on pci0
vtnet0: <VirtIO Networking Adapter> on virtio_pci3
virtio_pci3: host features: 0x711f8060 <EventIdx,RingIndirect,NotifyOnEmpty,RxModeExtra,VLanFilter,RxMode,ControlVq,Status,MrgRxBuf,TxAllGSO,MacAddress>
virtio_pci3: negotiated features: 0x110f8020 <RingIndirect,NotifyOnEmpty,VLanFilter,RxMode,ControlVq,Status,MrgRxBuf,MacAddress>
vtnet0: Ethernet address: 02:01:5c:e9:fc:2c

Trying to mount root from ufs:/dev/vtbd0p2 [rw]...

Change system settings:

hostname="free1"
keymap="german.iso.acc.kbd"
dumpdev="AUTO"

ifconfig_vtnet0="dhcp"
#ifconfig_vtnet0_name="em0"
static_routes="gw def"
route_gw="X6.Y6.Z6.1/32 -iface vtnet0"
route_def="default -host X6.Y6.Z6.1"

sshd_enable="YES"
ntpd_enable="NO"

Change filesystem mounts, from:

root@free1:/root # cat /etc/fstab
# Device        Mountpoint  FStype    Options    Dump    Pass#
/dev/ada0p2    /           ufs       rw         1       1
/dev/ada0p3    none        swap      sw         0       0

to:

root@free1:/root # cat /etc/fstab
# Device        Mountpoint  FStype    Options    Dump    Pass#
/dev/vtbd0p2    /           ufs       rw         1       1
/dev/vtbd0p3    none        swap      sw         0       0

You can also add another volume (for /usr in this case):

root@free1:/root # cat /etc/fstab
# Device        Mountpoint  FStype    Options    Dump    Pass#
/dev/vtbd0p2    /           ufs       rw         1       1
/dev/vtbd1p1    /usr        ufs       rw         1       1
/dev/vtbd0p3    none        swap      sw         0       0

Install FreeBSD ports:

root@free1:/root # portsnap fetch
Looking up portsnap.FreeBSD.org mirrors... 6 mirrors found.
Fetching public key from ec2-eu-west-1.portsnap.freebsd.org... done.
Fetching snapshot tag from ec2-eu-west-1.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Wed Jan  9 00:09:55 UTC 2013:
1d498e2b96bd612c33c6806b3913cf985f0f79b58e470a100% of   67 MB  673 kBps 00m00s
Extracting snapshot... done.
Verifying snapshot integrity... done.
Fetching snapshot tag from ec2-eu-west-1.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Updating from Wed Jan  9 00:09:55 UTC 2013 to Wed Jan  9 16:09:34 UTC 2013.
Fetching 4 metadata patches... done.
Applying metadata patches... done.
Fetching 0 metadata files... done.
Fetching 61 patches.....10....20....30....40....50....60 done.
Applying patches... done.
Fetching 1 new ports or files... done.
root@free1:/root # portsnap extract
/usr/ports/.cvsignore
/usr/ports/CHANGES
/usr/ports/COPYRIGHT
/usr/ports/GIDs
/usr/ports/KNOBS
/usr/ports/LASTCOMMIT.txt
/usr/ports/LEGAL
/usr/ports/MOVED
/usr/ports/Makefile
This entry was posted in System Administration and tagged , , . Bookmark the permalink.