Running FreeBSD 7.0 on ESX Server
I’m building new DNS servers for our corporate DNS due to our recent hardware problems with one of our old servers. We have had good success with publicly exposed BSD servers on the Internet, including OpenBSD and FreeBSD. My experience with FreeBSD is much more recent than with OpenBSD so for the new servers I am going with FreeBSD 7.0. We also have been building almost everything new as virtual machines on ESX server for the last year or so, so the DNS servers will be no exception.
FreeBSD is not officially supported by VMware on ESX server, but it runs on ESX 3.x without problems. My ESX server is configured with ESX 3.02. My first step was to build a template FreeBSD virtual machine. I’m going to use that as the basis for a master DNS server that we hide away and use to make changes on, and some slaves that are public-facing.
The first thing I didwas to get the FreeBSD iso files and put them somewhere where the ESX server can see them. I have an ISO library on my Sun x4500 that can be nfs mounted by my ESX servers, so that’s where I put the FreeBSD iso files (there are 3 iso files for FreeBSD 7.0 RC1).
Next, I set up a new virtual machine with 512 MB of RAM (probably overkill for a dedicated authoritative DNS server in charge of a few zones) and an LSI scsi adapter. For the guest OS, I chose Other/Other (not 64-bit). I pointed the VM’s CD-ROM drive at the FreeBSD disk1 iso file, and booted it. I’m not going to go over the partitioning and installation details of FreeBSD here. The install of FreeBSD is fairly straightforward if you have some UNIX/Linux experience. I chose to install the “Developer” package set, and to install the ports collection. I also added emacs and bash via the packages at the end of the installation because that’s how I roll. During the install it’s a good idea to add another user besides root, and to make them a member of the wheel group, so that they can run su to become root. In FreeBSD you have to be a member of the wheel group in order to be allowed to run su.
Once the install was completed, I rebooted, and logged in as root. To make the FreeBSD system a good virtual citizen on your ESX server, it’s a good idea to install the vmware tools. Unfortunately there is no vmware tools installer for FreeBSD on ESX 3.x. Luckily, the vmware tools for FreeBSD from VMware Server work in ESX Server. To install them on my virtual machine, I downloaded the tgz package for VMware Server 1.04, extracted it, and copied the file
vmware-server-distrib/lib/isoimages/freebsd.iso to my ISO library. Then I connected that iso file as the CD-ROM of the virtual machine. Then from inside the VM, I used the ports collection to install the vmware tools. To do that, I logged as root (or become root with su) and then ran the following commands:
make install clean distclean
Once the install completed, I rebooted to startup the vmware tools guest daemon. I logged in after the reboot and ran
ps ax | grep vmware to verify that the vmware guest daemon was running, and I saw output like this:
570 ?? Ss 0:03.52 /usr/local/sbin/vmware-guestd --background /var/run/vmware_guestd.pid --h
The final thing to get the FreeBSD VM ready to go is to replace the default ethernet device, which is a lance virtual nic. There are many anecdotes about the lance ethernet driver in FreeBSD dropping packets under load. It’s a good idea to change to either the vmxnet device or the e1000 device instead of lance. The FreeBSD GENERIC kernel (the default kernel) in FreeBSD 7.0 does not have a driver for the vmxnet device, but it does have one for the e1000 device. Either can be used, but if you choose the vmxnet device, you have to build a new kernel (waaay beond the scope of this post).
To replace the default lance virtual nic with the e1000 one, I first shut down and powered off the vm. Then, I accessed my ESX server as root with a shell (via ssh or on the console) and used vi to edit the
.vmx file of the FreeBSD virtual machine. I found a bunch of lines beginning with ethernet0 and inserted a line at the top of those lines like this:
Then, I saved the file and started up the virtual machine. When it came up, there was no IP address bound to the ethernet interface in the VM, and I had to login to it using the VMware ESX server Virtual Infrastructure Client console or Virtual Center. I logged in as root to the VM, and edited the
/etc/rc.conf file. I found the line that said
ipconfig_le0=... and changed it to
ipconfig_em0=... and then rebooted. The new virtual nic was then started up with the same settings as the old one had before I replaced it.
That’s it. If you follow this procedure, you will have a VM that is ready to be configured for whatever workload you want to put on it.