JA Control Panel

A Theory For Everything

Using Apple’s Time Machine In Linux (With VMware’s Fusion)

Recently I was responsible for setting up a new production web server. This server would be responsible for serving several small, low traffic websites (about 25 GB of traffic per month). Since the data is important, I wanted to create a great backup solution from the start.

Being on a tight budget (none of the sites are real revenue producers), I wanted a cheap, yet reliable option. Having been very happy using Mac OS X as my primary desktop OS for years now, and being completely in love with Apple's Time Machine, I opted for a Mac Mini. The plan was to use VMware's Fusion to host an Ubuntu Linux virtual machine, which would serve the web files stored in the Mac OS file system, and thus have those files protected by Time Machine. We will also create separate full backups of the system to be used in the event of a hardware failure. Ie, our Time Machine backups will be used for a restore, if a file or two (or thousands) are deleted/damaged due to hacking/accidents, etc, and our other backup will be used in the case of some physical problem.

This worked very successfully, here's how I did it...

Software used:

Hardware used:

Using partitions, I split the internal drive of the Mac Mini into two, Leopard HD at 40 GB (Mac OS Extended, Journaled), and DataHD at 260 GB (Mac OS Extended, Journaled). Then I used the standard method to install Mac OS X on Leopard HD partition.

Next I attached the LaCie external drive, and setup three partitions. Leopard HD Clone at 40 GB (Mac OS Extended, Journaled), DataHD Clone at 260 GB (Mac OS Extended, Journaled), and Time Machine at 630 GB (Mac OS Extended, Journaled).

I configured Time Machine to use the Time Machine partition for the Leopard HD and DataHD partitions of the internal hard drive. The two 'Clone' partitions on the external drive will be used by Carbon Copy Cloner later for additional backups in the case of a hardware (or Time Machine) failure.

I installed Fusion next and created an Ubuntu Linux virtual machine with the following configuration:

  • Processors: 1 CPU
  • RAM: 256 MB
  • Hard Disks: 8 GB (for the OS) & 0.6 GB (for swap)
  • Network: Bridged

The virtual machine files are saved in DataHD/Virtual Machines/Ubuntu/Ubuntu 64-bit.

I installed the Linux OS, using the second virtual hard drive for swap space, and allocating the entire first virtual hard drive to / (as ext3). Networking was configured with a private IP address, the Mac side has address

The VM was then set to start automatically when Fusion starts, and Fusion was set to start automatically when the Mac started. This is so that whenever the physical machine is rebooted, it will automatically start the VM as well. One thing I would like to see in a future update to Fusion, is the ability to autostart multiple VMs. As it is now, you can only flag one VM to start automatically.

Now, to setup the file sharing. Back in Mac OS X side I created a folder DataHD/Shared that will hold all of our Linux VM's data. This will be /home in our VM. I enabled NFS sharing by editing /etc/exports on the Mac side.

/Volumes/DataHD/Shared -maproot=root -network -mask

and started nfsd with sudo nfsd (this will start automatically on a reboot). You can see if your share is working by typing showmount -e in a terminal window. If you need to make changes to your /etc/exports file, you can make nfsd reload the configuration by typing sudo kill -HUP `cat /var/run/nfsd.pid` in a terminal window.

This configuration allows any machine on my private network to mount the share.

In the VM, I mounted the new share by creating a new directory /nfshome and editing our /etc/fstab file:

/etc/fstab:    /nfshome    nfs    defaults,rw    0    0

and then issue mount /nfshome in a terminal window.

Since I want this /nfshome to actually become the /home mount, I copied everything from /home to /nfshome with: cp -Rfp /home/* /nfshome/

This copied everything to the Mac side of the system, through the NFS mount, while preserving the permissions, owners etc.

To make the /nfshome be /home, I unmounted /nfshome, updated my /etc/fstab file:

/etc/fstab:    /home    nfs    defaults,rw    0    0

Moved the original /home to /oldhome and created a new empty directory called /home, and then mounted the new /home share.

With all this setup, I then did my normal installs for Apache etc and setup up all my virtual hosts to use document roots such as /home/com/atheoryforeverything/www etc.

Now it's all protected by Time Machine!

To complete the backup paradise, I installed Carbon Copy Cloner and cloned each of the partitions Leopard HD to Leopard HD Clone and DataHD to DataHD Clone. I setup tasks to repeat this backup each night.

These Carbon Copy Clones are useful in case of a hardware failure, or in case something is deleted that Time Machine didn't actually backup (I'll cover these issues in a future blog entry). They're also bootable, so if the machine explodes, I can be up and running as fast as I can pick up a new Mac Mini.

I then installed the Mac Mini into a data centre (changing all the private IPs to routable ones). Everything worked flawlessly.

Tags: apache | backup | lamp | linux | mac os x | time machine | ubuntu

Last Updated ( Monday, 17 November 2008 01:47 )