Monday 18 June 2018

macos - Shrink a .sparseimage


I have a .sparseimage that occupies 90GB of space on my hard drive despite only having 30GB of files in it. How can I reclaim the empty space used by the .sparseimage and compact the file?



Answer



After some cursory searching, I found a forum post pointing to hdiutil's compact verb. From the man page:



compact image


scans the bands of a sparse (SPARSE or SPARSEBUNDLE) disk image containing an HFS filesystem, removing those parts of the image which are no longer being used by the filesystem. Depending on the location of files in the hosted filesystem, compact may or may not shrink the image. For SPARSEBUNDLE images, completely unused band files are simply removed.



I ran hdiutil compact drive.sparseimage and it successfully reclaimed almost 98% of the space.


(I guess it's one of those days... I should really learn to Google stuff first).


Edit: I tested compact on a 1GB sparseimage with just a few text files, and it ran quite quickly, but my Mac is taking quite a while to compact the 90GB image. Be prepared to wait.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...