As promised, here’s a write-up of how I got VMware Fusion 2.0 and FreeBSD 7.0-RELEASE to play nicely with each other - or at least as nice as I could hope, I guess.
This guide is going to assume you are familiar with, or at least willing to learn as you go, the following things:
- How to use the FreeBSD installer. (It isn’t really that difficult; not quite in line with some of the easier Linux distributions, but far from rocket science too.)
- How to install stuff in FreeBSD, using either ports (which downloads source code, applies FreeBSD-specific patches and compiles it on your system, or its packages collection (which downloads and installs pre-compiled software). In my case, I used the ports system whenever possible because I am under the delusion that compiling software on your own machine makes it run significantly faster.
- Basic use of the Unix command line interface; navigating directories, running applications, mounting disks, using an editor, halting and rebooting, etc. Also, Unix concepts such as home directories, users and groups (especially root), etc.
- If you wish to run X, you should know how to start and configure that, as well as what it is in the first place.
If you need to catch yourself up on any of this, don’t forget the incredibly handy FreeBSD handbook. Most of what I’ve learned to get this working came either from that handbook, or this handy thread on VMware’s forums.
There’s no shame in screwing up and starting all over. In fact, one of the great things about VMs is that doing this is much easier than it is with real hardware. So experiment! You can’t delete VMs from within the VMware interface (grr), but you’ll find all their data in single individual files in the “Virtual Machines” folder in your Documents folder. Deleting them in the Finder will cause VMware to remove them from its “Library” window.
Finally, the stuff below worked for me. I can’t really guarantee that it’ll work for you. If you have questions or problems, feel free to post in the comments, but don’t expect me to be of much help - I’m still a n00b at VMware, and almost as much as a n00b at FreeBSD. Also comment if you think I’ve left something out - I’ve tried to remember everything and put it all in the right order, but I am just slightly short of the perfect human being. That said, let’s get started, shall we?
Step 0: Print these instructions
If I may be so bold, I recommend you print this web page. Why? Because to switch back and forth between your web browser and VMware, you’re either going to have to press Command-Tab (the standard OS X app switching key command) or Control-Command (which tells VMware to let the Mac have input focus back instead of the VM). And, as I whined in my previous post, VMware Fusion seems to send a press of the Escape key to the virtual system when you press the Command key on your real one. This may result in you backing up or exiting out of things accidentally, especially when using the FreeBSD installer. I’ve tweaked my site’s stylesheets to be more printer-friendly just for this article, so go kill a tree.
Step 1: Download a FreeBSD disk image
You should get the amd64 version - your Mac does not have an AMD processor, but it is 64-bit, and “amd64” is sort of shorthand for a 64-bit PC-compatible processor regardless of manufacturer. I also recommend getting the “bootonly” disk image, which just boots the FreeBSD installer but downloads all the stuff it will install as it installs it. The full disk images can take a long time to download, and this way you’ll save time by making sure that you’re only downloading the parts you really need. (The rest of this guide will assume you are taking this advice.)
Step 2: Set up a virtual machine
Start up VMware. When you see the “Virtual Machine Library” window, click the “New…” button. When it asks you for an operating system, select “Other” from the “Operating System” menu, then “FreeBSD 64-bit” from the “Version” menu. The other options should be self-expanatory (though make sure you’re allocating enough disk space to your VM now; increasing its size later will be a painful process). Once you get to the “Finish” screen, uncheck the “Start virtual machine and install operating system now” check box. Select the “Use operating system installation disk image file” radio button, select “Other…” from the menu below it, then navigate to the ISO file you downloaded in the previous step and select it. Click “Finish.”
Now you’ll be back at the “Virtual Machine Library” window. We didn’t want to immediately start the VM because there’s one more step I recommend doing before you fire it up; select your new VM and click the “Settings” button. From the list on the left, select “Processors” (expand “System Hardware” if you don’t see it), and set this setting to as high as it will let you set it. By default, it’ll only tell your virtual system use one of your processors (or cores). This is great if you want to make sure your Mac outside of the VM always has at least one processor to work with, but you might as well let your VM use as much power as it needs, especially if you’re going to be compiling ports.
OK out of the settings pane and head back to the “Library” window. Click “Run” and your new VM will fire up and start booting from the FreeBSD disk image.
Step Somewhere In Between: Networking, yay!
Accessing the internet with FreeBSD, both when you’re booting from the disk image and when you’re running your VM straight from your hard drive, seems to not be a problem with VMware… for the most part. By default, VMware will use its “NAT” network setting to pass networking stuff from your Mac’s network system to the VM. But I’ve noticed that, for no apparent reason, networking will eventually stop working. It’s seemingly random, but it’s fixed easily: just use the “Bridged” networking setting instead, then reboot the VM. This can be changed by clicking on the icon with the ethernet symbol on the lower left of the VMware window, or through the “Settings” pane (where we selected the number of processors to use above). Once this change is made, problems seem to never recur.
Step 3: Installing FreeBSD
Like I said, it’s fairly straightforward. Install the standard boot manager, because dual-booting a VM is weird. When it comes time to choose what to install, I don’t recommend installing X at this point, but do install the ports collection. When it asks you to try to use IPv6 and DHCP, both should work, so say Yes to both. Create user accounts and then reboot to finalize the installation. “Eject” the installation disk image by selecting “Virtual Machine” > “CD/DVD” > “Disconnect CD/DVD” from the Mac’s menu bar or clicking the icon in the lower-left of the window that looks like a disc. If all has gone well so far, your new VM will boot and present you with a login prompt. Log in as root.
Step 4: Edit /boot/loader.conf
Your new VM is now running, but it’s using more than its fair share of your Mac’s resources. This is due to the operating system polling the VM too often for interrupts, or something like that that geekier people than I would only understand. Fortunately, this is easily fixed. Your first step after logging in to your new VM for the first time should be editing /boot/loader.conf. It’ll be a blank file to start; add the line:
kern.hz=100
Save and reboot. Log in as root again.
Step 5: Update ports
This step is probably unnecessary if you’re just installing packages instead, but it won’t hurt. When you installed ports in step 3, you also installed a very handy took for updating ports called portsnap.
# portsnap fetch; portsnap update
…and go make a sandwich while your ports collection is updated. This will take some time the first time you run it.
Step 6: Install compat6x
We’re going to want to install VMware Tools, but it doesn’t directly support FreeBSD 7, so we’ll need to install a compatibility doodad. The port is in misc/compat6x; make install clean it. (I’m not sure if this will work as a package, but you can try…)
Now we need to put the doodad in a place where VMware Tools will find it.
# ln -s /usr/local/lib/compat/libc.so.6 /lib
Step 7: Install Perl
Installing VMware Tools requires Perl, so if you don’t have it yet, install it. The port is in lang/perl5.8, or install the package if you’d rather.
Step 8: Install VMware Tools
From VMware’s “Virtual Machine” menu, select “Install VMware Tools.” This won’t do anything obvious, but what it actually did was stick a virtual CD-ROM into your virtual machine’s virtual optical drive. mount /cdrom it. It will contain a single file, entitled “vmware-freebsd-tools.tar.gz”. Extract it to somewhere convenient. This will create a directory named “vmware-tools-distrib”; cd into it, then ./vmware-install.pl.
During the installation process, the installer will tell you that it looks like you’re installing via a remote shell, and are you sure you want to continue? This is, of course, a dirty rotten lie, so say “yes.” Other than that, all of the default choices should suffice.
Step 9: Install X and a WM of some sort
If you don’t intend to use X, you’re done. If you do, there’s one more step. Install X and your window manager of choice now, and test that it works. You’ll notice that it works inside an annoyingly tiny window, though.
(If you want to install command-line stuff like vim and bash now too, go ahead.)
Step 10: Run vmware-config-tools.pl
Exit out of X and go back to the command line. Run /usr/local/bin/vmware-config-tools.pl. Like the previous Perl script, you may be told you’re logging in from a remote terminal.
Step 11: vmware-toolbox
Start X again and start up your X-powered terminal of choice. Run vmware-toolbox for an ugly X application which will let you adjust a few other options with regards to how VMware interacts with X.
Known unknowns
Two problems not solved by the steps above, and which may not be solvable: One, how to stop an escape character from being sent to the standard FreeBSD command line when you press the Command key on your keyboard (interestingly, this doesn’t seem to happen once you’ve got X running), and two, how to get VMware to realize when you’ve moved the pointer to the edge of the screen in X and release it so that you are controlling it in your Mac again, just as it can do with Windows. How to stop VMs from grabbing focus just when you merely mouse over their windows would be great to know too. If you’ve solved any of these problems yourself, please share in the comments.