Time Machine is a backup program built into Mac OS 10.5, Leopard. It saves all files on the computer on a USB or network drive, which can be used for restoration of individual files or the whole computer.
The normal behavior of Time Machine is to keep
- hourly backups for the past 24 hours
- daily backups for the past month
- weekly backups until your backup disk is full
It is the last point that might cause some trouble for some people, since many people might share the drive with other type of data. There has to be some way to limit the size of the backup volume. This is my approach.
Preparing an image
The first step is to create an image to hold the backup filesystem. If you want this filesystem encrypted, have a look at Mounting encrypted volumes, otherwise just follow the following steps. The image will be created as /ext/timemeachine.img and it will be mounted in /ext/timemachine.mnt.
dd if=/dev/zero of=/ext/timemachine.bin bs=1G seek=250 count=1losetup /dev/loop1 /ext/timemachine.binmkfs.ext3 /dev/loop1tune2fs -c0 -i0 /dev/loop1losetup -d /dev/loop1mkdir /ext/timemachine.mnt
The first thing is to create an image file, and using the dd command we create an empty 250GB file, which will contain the backups. The next step is to setup the image as a loop device, which makes it possible to mount it as usual. loop1 is currently used, but if you know that it is occupied, feel free to choose another device.
The next step is to edit /etc/fstab and add a line which will automatically mount the filesystem when the computer boots.
/ext/timemachine.bin /ext/timemachine.mnt ext3 loop=/dev/loop1 0 0
Then we will mount all filesystems and verify that it has indeed been mounted.
df -h/ext/timemachine.bin 248G 188M 235G 1% /ext/timemachine.mnt
There should be a line like the above if everything is working correctly. The last step is to set the correct permissions for the directory for your user.
chown -R joch /ext/timemachine.mnt/
Setting up the Samba share
To connect to the server, it is necessary to setup the Samba server. Create a share like the following in /etc/samba/smb.conf.
[tmbup]comment = Time machine backupspath = /ext/timemachine.mntbrowseable = yesread only = Noinherit permissions = noguest ok = noprintable = no
Now just reload Samba and add a user if you have not done so before.
invoke-rc.d samba reloadsmbpasswd -a joch
Setting up Time Machine
Connect to the share in Finder as usual.
Open up the Time Machine preferences and click Change Disk. It should give you a dialog like this, and Time Machine should then be enabled.
If you get the error “Time Machine Error: The backup disk image could not be created.”, you will need to do some magic on the server.
You need to start the backup once again, but this time you will have to be quick and copy the directory it creates on the server. Once Time Machine has finished, the original directory will be deleted, so just copy the saved directory back to the same place.
Now run the backup again, and it should complete successfully!
This behaviour is very strange, but the above trick always solves the problem.





Thanks for the tip. It almost solved my problems…
Even after trying your trick I still got the message:
“Time Machine Error: The backup disk image could not be created.”
After a bit of Googling I found a ‘proper’ solution. It seems that
there is a bug that prevents the creation of the sparsebundle. The
solution is to create a sparsebundle first on your local drive, and
then move it to the Samba share. The details:
http://www.readynas.com/?p=253
And by the way, with the solution above it is also possible to limit
the size of the sparsebundle, so it’s not needed to create an image to
hold the filesystem.
[quote post="344"]And by the way, with the solution above it is also possible to limit
the size of the sparsebundle, so it’s not needed to create an image to
hold the filesystem.[/quote]
Great! Thanks for the tip!
Pingback: » Limit Time Machine disk usage on external drives Johnny Chadda .se