How to setup TimeMachine on a network drive with disk quota
Well, once you bought your NAS or configured a dedicated PC with network drive you’ll obviously want to setup Time Machine. The problem is, once configured to backup to a networked drive your TimeMachine will eat all available space.
For those lucky ones, who shared a dedicated disk partition on their drive — there’s no problem at all. But I was not one of them. Recently, I’ve purchased a used Buffalo LS-WXL Linkstation duo inserted two new 1TB drives and configured it as a RAID0 array. As a result, almost whole 2Tb partition became available for sharing — despite how hard I tried to figure out xfs quotas on target partition, no success.
Well, there are bad and good news.
- The good news is that you may limit your Time Machine disk quota by using something called sparse disk bundles.
- The bad news is that you’ll need root access to your NAS in order to apply permissions hack to make it work with latest versions of Time Machine
Let’s proceed!
Create sparse bundle on your mac
Open terminal, and create 1024g sparse disk:
# Get the MACADDR of network port $ MAC=$(ifconfig en0 | perl -ne 's/.*ether (\w+:\w+:\w+:\w+:\w+:\w+).*/$1/ && s/://g && print;') $ echo $MAC 001122334455 # Create name of sparsebundle $ SBNAME=$(hostname)_$MAC.sparsebundle $ echo $SBNAME amber_001122334455.sparsebundle # Create sparse image # You should modify 1024g to the size of your maximum Time Machine backup size. $ hdiutil create -fs HFS+J -size 1024g -type SPARSEBUNDLE -volname "Time Machine" $SBNAME $ ls $SBNAME Info.bckup Info.plist bands token
Once this is done, copy sparse bundle directory into your network volume:
# mine network disk is called /Volume/tm $ cp -R $SBNAME /Volumes/tm
Create a separate user for TimeMachine
It is a good practice to create a special user specifically for network drives that will be used for TimeMachine backup.
I called mine tm:
Apply hack with access rights
On MacOS X versions prior to 10.6.3, this step would be not necessary, but on latest versions TimeMachine automatically resizes your sparse bundle to occupy the whole space. We’ll deny it using access rights hack.
To be able to continue, you should access your NAS using root credentials.
# login to your NAS via ssh $ ssh -i ~/.ssh/my.key root@nas Warning: Permanently added 'nas,192.168.1.227' (RSA) to the list of known hosts. Last login: Wed Oct 17 19:35:37 2012 from amber # go to the destination of your shared network volume root@NAS:~$ cd /mnt/array1/tm/ # check out that sparse bundle has been successfully copied root@NAS:/mnt/array1/tm$ ls -l drwxrwsrwx 4 tm hdusers 4096 Oct 17 19:08 amber_001122334455.sparsebundle/
The main idea behind access right hack is pretty simple: deny TimeMachine user from write access to specific files:
Page 1 of 3 | Next page