Page 1 of 1
Reclaim disk space for OS X guest
Posted: 11. Oct 2018, 16:42
by tsp1965
Hi all
I regularly do the disk cleanup/sdelete/vboxmanage thing to compact my windows guest vdi files, but I can't find any info on doing the same to Mac OS or OS X guests on a High Sierra host machine. I keep an El Cap virtual machine for running non-64 bit legacy software and would like to delete the surplus stuff and get back the disk space. Can anyone advise how to do this please?
Re: Reclaim disk space for OS X guest
Posted: 11. Oct 2018, 17:22
by mpack
The process is exactly the same, except you need to use the OS X disk utility in the guest to erase unused sectors in the filesystem.
Re: Reclaim disk space for OS X guest
Posted: 11. Oct 2018, 17:54
by socratis
tsp1965 wrote:I can't find any info on doing the same to Mac OS or OS X guests on a High Sierra host machine
Tried the manual? See ch.
8.23 VBoxManage modifymedium at the "
--compact" option:
For Mac OS X guests, use the "diskutil secureErase freespace 0 /" command line from an elevated Terminal.
Re: Reclaim disk space for OS X guest
Posted: 11. Oct 2018, 18:03
by tsp1965
Thanks for the reply - only small snag is that Apple removed the Secure Erase function in the disk utility app for El Cap on the grounds that it wasn't relevant for SSDs. My VM is on a Mac Pro, which has an SSD so presumably the VM thinks its VHDD is SSD also. So do I use command line to do this?
If so syntax seems to be:
diskutil secureErase freespace 3 "/Volumes/Macintosh HD"
Replacing the HDD name if it's not the default Macintosh HD
Does that look right?
Re: Reclaim disk space for OS X guest
Posted: 11. Oct 2018, 18:16
by tsp1965
Sorry, that should be
diskutil secureErase freespace 0 "/Volumes/Macintosh HD"
not 3 - forgot to change is from my cut-and-paste before posting.
Re: Reclaim disk space for OS X guest
Posted: 11. Oct 2018, 19:24
by mpack
I can't see why a secure wipe isn't relevant to SSD. I can see why wear leveling would make it difficult.
If Apple has removed that feature then you need to find a third party tool. I've seen it done on Linux without a tool using file copy from null until space runs out.
Note that this is an OS X support problem: VirtualBox doesn't provide such a tool for any OS, even supported ones - which OS X is not.
Re: Reclaim disk space for OS X guest
Posted: 11. Oct 2018, 20:58
by socratis
tsp1965 wrote:Apple removed the Secure Erase function in the disk utility app for El Cap on the grounds that it wasn't relevant for SSDs
Not true. I can still use it on all my 10.5 through 10.13 VMs. So, I'm
not quite sure what exactly you're talking about. The only thing that changed in 10.11 is that Apple removed it from the "Disk Utility", not from the command line.
In fact, I had to re-open my original
ticket #11175 for 10.11, specifically to remove the reference to the "Disk Utility" that was in the manual, and change it to the equivalent command-line option.
And when given a specific command, I expect that command to be executed as is. I never mentioned the "/Volumes/Macintosh HD". I specifically said "/", without the quotes, i.e.:
mpack wrote:I've seen it done on Linux without a tool using file copy from null until space runs out.
That's right, you can always run:
It works on every filesystem, even the ones that other tools can't handle, like Btrfs, APFS, XFS, etc...