Linux? That sounds hard and boring…
Waiiit! Don’t leave just yet! Even if you have no Linux experience at all, you will easily be able to follow this simple guide and setup your very own, DIY Time Capsule. You don’t even need a separate computer!
I will to try to write this guide as simple as possible, but with the possibility to get more information, should you want it. Bear in mind that I’m writing this tutorial so that anyone can easily follow it.
Even though this guide could work with several versions of Linux and Mac OS X, I am going to concentrate on Ubuntu Linux 12.04 and Mac OS X 10.8.
Ubuntu Server 12.04 64bit to be exact. This is the current long-support version of Ubuntu Server, and is possibly the most stable version.
Mac OS X 10.8 is the newest OS from Apple (10.9 Mavericks in the making), so I will concentrate on this version. But don’t worry, this guide will most likely work perfectly on 10.7, and maybe older versions as well. I don’t have the opportunity to test it, so if you succeed on an older version, please leave a comment!
As this is going to be a backup-server, a 24/7 uptime is highly recommended. I have a Windows Home Server (WHS 2011) where I installed a virtual Linux server, but you could install it on an old desktop computer or a laptop with a dead monitor etc. Just about anything with some storage will do! I recommend internal storage!
OK – Let’s get on with the tutorial:
What separates this guide from all the other guides I’ve found?
A lot of the guides has unnecessary steps, including guest access and hacking your mac to show unsupported network volumes. This is not recommended, as it could give false backups if the backup volume is out space.
This is the code that almost all the other guides have:
Defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
I have written this guide to help you create a Time Capsule as close to OEM as possible, no extra edits on your Mac necessary.
I will start by installing VirtualBox and Ubuntu. Even though you have a server running, it could be a good thing to test with a virtual environment first. You could use VMware ESXi (VMvisor 5.1) or something similar to create multiple servers on a single computer, but I’m going to install VirtualBox on top of a running operating system.
PS! Make sure you have hardware virtualization enabled in your computers BIOS! Read up on your hardware manual to see how. Or else you won’t be able to virtualize a 64-bit processor.
Installation is like any normal application install, but remember that VirtualBox will reset your network card during install, this is to create a shared network so that your virtual machine(s) can get an IP from your router.
This is what you will meet after install, except you won’t have a virtual Windows XP computer of course. Click New to create a new computer. Then give it a fitting name (only for VirtualBox) and choose Linux and Ubuntu 64bit. All options I choose were defaults, but I’ve listed them here anyways:
10GB is more than enough for the Ubuntu installation. We will create a secondary drive later for backups.
And there you go! You have successfully created a brand new virtual computer. Now we need to install an operating system, and later add some storage.
You should now open settings, then network, and choose “Bridged Adapter”. This will make sure your Time Capsule will be visible on your LAN, it will get an IP from your router and act as a normal separate computer.
Installing Ubuntu Server 12.04.
You now have to download the Ubuntu Server image (656MB). Please choose Ubuntu Server 12.04.2 LTS. It will take a couple of minutes to download, depending on your Internet connection.
Now, start your virtual machine, and you should be prompted with a window asking you to choose a startup disk. If not, go to settings, choose storage, and click the one named “Empty”. You should be able to browse for an image file (Ubuntu download) at the right.
Then the Ubuntu ISO should boot in a console window, and you’ll be prompted to choose your language for Ubuntu. Then just click Install Ubuntu Server. (PS, notice that you have a so called “Host Key” displayed at the lower right corner of the console window, this is to break out of the virtual machine console. On Mac it is your left cmd-key).
You will be prompted with several language selections. Click enter after choosing your preferred options.
After identifying your keyboard, you will be prompted to give a hostname to your Time Capsule. I recommend “TimeCapsule” as a name. This is the name that will be seen on your network. Don’t use spaces! To easily move between text and navigation buttons (Go back, Continue), click the tab-key. You can also just press the down arrow.
Continue with writing your name and a username, or just put “Time Capsule” as full name and “timecapsule” as username.
Choose a password and remember it!
I choose not to encrypt my home directory, but this is optional.
After the installer has found a time server etc, you will be prompted to choose a partitioning method.
Choose the first one. You don’t need LVM for a simple server like this. You can choose it, but then you probably know what you’re doing. It’s mainly just the possibility of having a logical drive stored over multiple physical drives. On a small virtual server like this, it’s really not needed.
Select the drive (the only option) afterwards, and choose yes to write changes to disk. Ubuntu will start installing just after. When asked for proxy, you can click continue, and leave it blank. After this you could take a small break, go grab a coffee. This shouldn’t take to long.
When asked about updates, leave it at default with no automatic updates. This will ensure that no updates will break the setup. It’s better to do manual updates from time to time.
Then you’ll get the option to install some extra software. Install OpenSSH, but leave the rest blank. (Choose with space, then click tab and choose “Continue”) OpenSSH will give the opportunity to log in to your server through terminal. This is much easier than opening VirtualBox.
This will take a couple of minutes, and you will be prompted with the GRUB installer. Click yes to install. This is the bootloader for Ubuntu on your virtual machine.
Seconds after, your installation is finished! Congratulations! Make sure your Ubuntu ISO is unmounted (through settings -> Storage, it should read empty under “Controller: IDE”. ) Click continue to restart the virtual machine. It should take approximately 10 seconds to boot.
When booted, you’ll be met with a login. Bear in mind that if you have taken a quick break after the reboot, and now came back to a black screen, just click a key inside the virtual machine console, and you should be met by the Ubuntu login. Insert your username (click enter) then your password. (PS. There are no stars when typing the passwords).
First of all, to make things easier, log in as root. This will give you administrator rights, and make it possible to do changes on the system. Write “sudo su” and your password when prompted
Notice that you are now located at “root@TimeCapsule:/home/timecapsule#.
The first thing you should do is update the system. It’s easily done by writing the following:
apt-get update && apt-get upgrade
When asked if you would want to continue, click enter. You can see that it says “Y/n”. As “Y” is in capital letters, it’s the default choice.
Then let it do its thing, it shouldn’t take to long before you’re ready to continue. This could also be a good place to continue your coffee or take a small break before we start installing the actual services.
Install Netatalk and Avahi
Netatalk is an open source version of AppleShare File System (AFP) which will give the ability to create Macintosh and TimeMachine supported shares. Avahi is an open source Bonjour service, which will announce your shares for your Macs. Avahi is included with netatalk, but I experienced problems with the Time Capsule not being listed, so to be sure, we will install both netatalk and avahi-daemon.
It’s easy! Run this command:
apt-get install netatalk avahi-daemon
and click enter. You should be prompted with a message asking if you want to continue, click enter again. It should be approx. 7MB. This should only take a couple of seconds to finish.
Now we’re going to edit its configuration file with Nano, a simple text editor. Write the following command:
Now hold Ctrl+V to scroll down to the last line.
There’s a “#” sign in front of the line, remove it. This is a comment sign, which disables the following line.
It should now look like this:
- -tcp -noddp -uamlist uams_dhx.so,uams_dhx2_passwd.so -nosavepassword
What’s worth noticing here is “uams_dhx.so” and “uams_dhx2_passwd.so”. These are the authentication methods, the “Diffie-Hellman eXchange” and “Diffie-Hellman eXchange 2”. The latter being the most advanced and secure.
I removed “uams_dhx.so” from my configuration , as DHX is no longer supported from 10.7 Lion and up, this because Apple has considered it insecure. DHX2 is supported from OS X 10.2, so all Time Machine supported Macs should only need the latest DHX2 authentication, thus making the system a bit more secure. “uams_dhx2_passwd.so” is needed, or else you will only get “This server is not supported” when trying to connect.
This is also the reason why a lot of NAS devices has lost Time Machine compatibility from 10.7 Lion, they don’t support DHX2.
- -tcp -noddp -uamlist uams_dhx2_passwd.so -nosavepassword
If you don’t want to mess around with these settings, you can just remove the “#” sign in front, and that’s it!
Some recommend adding “uam_guest.so”, which could resolve an error in Ubuntu Syslog due to a bug in netatalk:
INTERNAL ERROR: Signal 11 in pid 2413
I haven’t experienced this error with my configuration, so it could be corrected in the newest version of Netatalk.
To exit nano after doing your changes, press Ctrl+X, then Y (for yes) and click enter (overwrite the file).
If you have followed everything in this guide, you’ll need to setup an extra hard drive for storage. To do this, you have to turn of the virtual machine.
The easiest way through VirtualBox is to click the red X on the console window and choose “Send the shutdown signal”.
You can also do it by command:
If it fails, try this command:
shutdown -h now
You should be back on the VirtualBox application, and you can choose your Time Capsule machine, and click settings.
Click storage, Controller: SATA and then the most right icon, it should say “Add Hard Disk” when hovering over. Then choose:
1. Create new disk
2. VDI (VirtualBox Disk Image)
3. Dynamically allocated
4. Name it “Storage”, and choose a size. It should be larger than your Macs hard drives
5. Click “Create”.
I choose a 15GB disk for this test, but it would more likely be 1-2TB in a normal Time Capsule setup.
After this you can start the virtual machine again.
When booted, login again, and write:
as you did earlier in the install. Enter password when prompted and you should be back at root.
We now have to mount the hard drive, and make sure it remounts when rebooted. This is the same procedure as for a physical machine.
Write “fdisk /dev/sd” and click tab. You now get a list over all valid commands. As you might see, you have sda, sda1, sda2, sda5 and sdb.
Sda and sdb are the two drives. S-ATA drive A and S-ATA drive B. 1,2 and 5 are partition numbers (these were created automatically during install. sda refers to the whole drive.
You can also list them all by writing “fdisk -l” when root.
We want to concentrate on sdb which doesn’t have any partitions, and is therefore likely to be our new harddrive.
PS! If you are on a physical computer, you might have different drive names, but in any case, it will most likely be sdb if you have two drives, and also the one without a number behind. If you are in doubt, you can turn off the computer, remove the drive you want to use, and boot up again and check which are available. This could help you identify the drive easily.
So, as we want to use the sdb drive, we write the following command:
You will get a warning stating that the drive doesn’t contain any valid partition table, this is normal, as the drive is empty.
We will continue with creating a primary partition, which is fairly easy. Follow these steps:
n (enter) p (enter) Click enter until you're back to (m for help) w (enter)
You have now successfully created a New Primary partition with the partition number 1 which is using all the sectors on the hard drive, and Written the changes.
Now the drive is configured with a partition, and we have to format it. Write the following command to format our partition with ext4:
The next thing to do is make sure it is automatically mounted. We will mount it at “/mnt/TimeCapsuleData”
mkdir /mnt/TimeCapsuleData chmod 777 /mnt/TimeCapsuleData echo /dev/sdb1 /mnt/TimeCapsuleData ext4 defaults 0 0 >> /etc/fstab mount /mnt/TimeCapsuleData
And there you go! Your drive has been partitioned, formatted and will now be mounted at every boot.
The last thing we will do is to set this as our Time Capsule storage:
Scroll all the way down with Ctrl + V, and go a couple of lines up. You’ll see “~/ “Home Directory “”. Put a “#” sign in front of it, which will disable the line.
Go to the line under, and write:
/mnt/TimeCapsuleData "TimeCapsule" cnidscheme:dbd options:usedots,upriv,tm allow:timecapsule
The first setting is the path to the backup location, the next, “TimeCapsule” is the name of the server. This could be anything, “My Ubuntu Time Capsule” etc. With both hostname and storage being called “TimeCapsule”, you will in Time Machine on your Mac see “TimeCapsule on TimeCapsule”.
Alternatively, if you want to limit how much of the drive that could be used, you can set it like this:
/mnt/TimeCapsuleData "TimeCapsule" cnidscheme:dbd options:usedots,upriv,tm volsizelimit:100000 allow:timecapsule
Notice the “volsizelimit:100000” setting. This means that the volume limit is 100.000MB, or 100GB. The last parameter “allow:timecapsule” this is the username for the user who will administrate the Time Capsule. Just use the user you set during Ubuntu install. Also notice the “tm” option, this is the only thing separating this from a normal AFP-share.
When you have set your options, exit and save with “Ctrl + X” ,then “Y” then enter to overwrite.
service netatalk restart
You could also restart the whole server.
shutdown -r now
If you need to access the server later, you could either go through VirtualBox, or use ssh, as we installed earlier. Open terminal on your mac, then write your username and IP-address. Not sure of your IP? Write “ifconfig” in the VirtualBox console. You should either set the IP to be static in Linux, or better just reserve the IP-address on your router.
Then enter password when prompted. You will be in the same shell as available through VirtualBox.
On your Mac:
Open the Time Machine preference pane, and click “choose disk”. You should now see your available Time Machine backup shares.
Hope this guide could help you!
If you experience problems, please leave a comment!