TimeCapsule: using disk images to store files
Perhaps sharing this could benefit someone.
I wanted to store files on a Time Capsule that is also a Time Machine target. Problem is that Time Machine eats up all the space with time.
Common workarounds are: a second USB drive attached to TC or open TC and re-partition the internal drive.
As a dirty hack, I created a disk image on TC's hard-disk and I mount it via an AppleScript. The concept is the same as Loopback devices in Linux or Solaris except for the fact that disk files cannot be shared among multiple users at the same time.
Steps are:
Create a zeroed disk image, this example has a size of 32GB, TC's disk is named Storage (default is Data, your name may vary):
hdiutil create -megabytes 32768 /Volumes/Storage/Sharedfiles.dmg -layout NONE
Retrieve device tag, in this example is device 2:
hdid -nomount /Volumes/Storage/Sharedfiles.dmg
/dev/disk2
Create filesystem and umount to flush journals:
newfs_hfs -v sharedfiles /dev/disk2
hdiutil eject /dev/disk2
The disk image is created, if one wants to mount it automagically here is a short simple Applescript, there is room to improve its sanity checks, contributions are welcome
Just modify the properties at will:
property TimeCapsule_IP : "192.168.1.10"
property UserID : "yourusername"
property Image_Name : "Sharedfiles.dmg"
property Image_Id : "sharedfiles"
property TimeCapsule_Disk_Name : "Storage"
set devname to do shell script "mount | grep Storage | cut -f3-4 -d / | cut -f1-1 -d \\"(\\""
tell application "Finder"
if not (exists the disk devname) then
mount volume "afp://" & UserID & "@" & TimeCapsule_IP & "/" & TimeCapsule_Disk_Name
delay 5
end if
if not (exists Image_Id) then
do shell script "hdiutil attach /Volumes/" & TimeCapsule_Disk_Name & "/" & Image_Name & " -mount required"
end if
end tell
You can read my original post on my blog too: http://www.kaukana.be/wp/?p=398
I wanted to store files on a Time Capsule that is also a Time Machine target. Problem is that Time Machine eats up all the space with time.
Common workarounds are: a second USB drive attached to TC or open TC and re-partition the internal drive.
As a dirty hack, I created a disk image on TC's hard-disk and I mount it via an AppleScript. The concept is the same as Loopback devices in Linux or Solaris except for the fact that disk files cannot be shared among multiple users at the same time.
Steps are:
Create a zeroed disk image, this example has a size of 32GB, TC's disk is named Storage (default is Data, your name may vary):
hdiutil create -megabytes 32768 /Volumes/Storage/Sharedfiles.dmg -layout NONE
Retrieve device tag, in this example is device 2:
hdid -nomount /Volumes/Storage/Sharedfiles.dmg
/dev/disk2
Create filesystem and umount to flush journals:
newfs_hfs -v sharedfiles /dev/disk2
hdiutil eject /dev/disk2
The disk image is created, if one wants to mount it automagically here is a short simple Applescript, there is room to improve its sanity checks, contributions are welcome
Just modify the properties at will:
property TimeCapsule_IP : "192.168.1.10"
property UserID : "yourusername"
property Image_Name : "Sharedfiles.dmg"
property Image_Id : "sharedfiles"
property TimeCapsule_Disk_Name : "Storage"
set devname to do shell script "mount | grep Storage | cut -f3-4 -d / | cut -f1-1 -d \\"(\\""
tell application "Finder"
if not (exists the disk devname) then
mount volume "afp://" & UserID & "@" & TimeCapsule_IP & "/" & TimeCapsule_Disk_Name
delay 5
end if
if not (exists Image_Id) then
do shell script "hdiutil attach /Volumes/" & TimeCapsule_Disk_Name & "/" & Image_Name & " -mount required"
end if
end tell
You can read my original post on my blog too: http://www.kaukana.be/wp/?p=398
Comments
Wouldn't partitioning the drive have been easier? (Unless, perhaps, you already had some TimeMachine data on it that you didn't want to lose.)
It depends. Formatting the drive cannot be done unless one extracts the HD from the case and connect it to another Mac with a SATA connector. Opening the case means ripping the rubber and invalidating the warranty.
After all I needed a fast hack to use TimeCapsule as a storage, nothing more.