Posts Tagged sparsebundle

Restore sparsebundle extended attributes after rsync

If you rsync a sparse bundle to another Mac without the -E flag (or if you copy it to a non Mac system), you will loose the ability to double click on it in the Finder to mount it. This is because the extended attributes telling the Finder the folder is actually a bundle are lost in the transfer.

The following piece of code I found here fixed the problem for me. Simply compile and run the code giving the path to the bundle in parameter and it will restore the attributes.

/*
 setxattrs - bubbaATbubba.org
 
 Properly sets sparse bundle extended attributes lost when rsyncing
 sparse bundle data to a platform that does not support extended
 attributes.  This is only need when restoring/retrieving the
 bundle.
 
 To use, sync/copy all bundle files, then run this tool on the
 sparse bundle:
 % gcc -o setxattrs setxattrs.c
 % ./setxattrs mybackup.sparsebundle
 % xattr -l mybackup.sparsebundle
 
*/
 
#include
#include 
 
int main (int argc, const char * argv[]) {
 
   if (argc != 2) {
        printf("Usage: %s [sparse bundle directory]\n", argv[0]);
        printf("Sets extended attributes for sparse bundle disk image\n");
        return 0;
   }
   int sxr;
   int options = XATTR_NOFOLLOW;
   char theValue1[] = { 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00};
  char theValue2[] = { 0x59, 0x48, 0x60, 0x38,
            0x65, 0x7C, 0x09, 0x22, 0x33, 0xAD, 0xA5, 0x73,
            0x12, 0xAD, 0xF3, 0x7F, 0xEE, 0x90, 0x5B, 0x92};
 
   size_t   theSize1 = sizeof(theValue1);
   size_t   theSize2 = sizeof(theValue2);
 
   sxr = setxattr(argv[1], "com.apple.FinderInfo", (void *)theValue1, theSize1, 0, options);
   sxr = setxattr(argv[1], "com.apple.diskimages.fsck", (void *)theValue2, theSize2, 0, options);
 
   return 0;
}

, , , ,

No Comments

Shrinking sparse bundle images

A sparse bundle image in Mac OS X will grow as you add files to it but never shrink if you remove files inside of it. To reclaim the disk space, you must run the following command :

hdiutil compact path/to/sparsebundle

If your account is protected with FileVault, this is done automatically for you when you logout of your account.

, , ,

3 Comments