1 2 Previous Next 19 Replies Latest reply on Dec 16, 2019 11:00 AM by wigson

    Shrinking APFS?

    gringley Enthusiast

      So in the good old days before APFS I could shrink Mac virtually disks with this script inside the VM:



      sudo diskutil secureErase freespace 0 Macintosh\ HD

      sudo /Library/Application\ Support/VMware\ Tools/vmware-tools-cli disk shrinkonly

      sudo halt


      ...but now with APFS I have to write 0 to freespace then shut the VM down and do the shrink from the host terminal.  Is vmware-tools-cli going to gain the ability to shrink APFS?

        • 1. Re: Shrinking APFS?
          gringley Enthusiast

          ....and in Catalina Beta the freespace 0 command no longer works?

          • 2. Re: Shrinking APFS?
            haralds Enthusiast

            You need to check into snapshots or disable them.

            • 3. Re: Shrinking APFS?
              dlhotka Virtuoso

              Definitely disable snapshots.


              But, and more importantly, I'm thinking that secureerase freespace is depreciated for APFS drives.  Even on my host machine, when erasing an external drive, file still show up in recovery software. 

              • 4. Re: Shrinking APFS?
                gringley Enthusiast

                The VM does not have any snapshots.

                • 5. Re: Shrinking APFS?
                  TECH198 Enthusiast

                  No it's not.. you can still secureerase freespace on APFS drives.. i have done it several times from the on my Mac running Mojave from Terminal:-


                  Screen Shot 2019-09-25 at 6.05.21 pm.png


                  (Macbook Air 256GiG SSD). I guess this is the only way since Mac OS guest "Clean up after shutting down virtual machine" only deletes snapshots for MacOS VM's.


                  I guess you can always create AppleScript, then double click to run.

                  • 6. Re: Shrinking APFS?
                    wila Guru
                    User ModeratorsvExpertCommunity Warriors

                    I think they are talking about apfs snapshots..


                    and it looks like that you cannot disable it anymore in 10.13 and higher.


                    How to disable Local Snapshots - Apple Community

                    But you should still be able to remove local snapshots that have been made.


                    re. the original question.

                    Perhaps this thread helps:


                    Shrink an APFS virtual disk



                    | Author of Vimalin. The virtual machine Backup app for VMware Desktop Products
                    | Vimalin : Automated backups for VMware Fusion and VMware Workstation Professional
                    | More info at https://www.vimalin.com
                    | Twitter @wilva
                    | VMware Wiki at http://www.vi-toolkit.com
                    • 7. Re: Shrinking APFS?
                      gringley Enthusiast

                      I can do it in Mojave.  I am seeing I cannot do it in Catalina.

                      1 person found this helpful
                      • 8. Re: Shrinking APFS?
                        gringley Enthusiast

                        I had read that thread and have been using its correct answer to do my Mojave VMs.

                        • 9. Re: Shrinking APFS?
                          dlhotka Virtuoso

                          Yep, I've run that command many times.  Then I've run data recovery software and there's still many files available for recovery, so it's definitely not operating the same on an APFS SSD as it did on an HPFS+ SSD or metal disk.

                          1 person found this helpful
                          • 10. Re: Shrinking APFS?
                            gringley Enthusiast

                            I am seeing this is quite complicated.  In Catalina there are "Macintosh HD" and "Macintosh HD - Data" APFS volumes that are dynamically expanding and contracting in the existing free space of the disk.  The partition covers the whole disk.  If you have not been here before, Macintosh HD contains the OS, and Macintosh HD - Data contains home folders.


                            Screen Shot 2019-10-13 at 5.46.30 PM.png


                            Arguably shrinks could be easier if the VMware utility understood the new scheme and shrunk away the free space?  Maybe even automatic after shut down like the Windows VMs have? Otherwise how would one get into that free space to zero it if the partition already covers it?  Could the current VMware utility even see that?


                            In Mojave it is still a single APFS Volume and the old ways thus work.

                            Screen Shot 2019-10-13 at 5.52.48 PM.png

                            1 person found this helpful
                            • 11. Re: Shrinking APFS?
                              MichalKolar00 Lurker

                              Hello everybody,

                              did anybody figure out how to shrink Catalina VM? No luck for me... but after the VM upgraded from 10.15 to 10.15.1 it grew a lot so it would be great if she can lose some fat.

                              • 12. Re: Shrinking APFS?
                                persfu Lurker

                                This is what I did:

                                Clone to a new vmdk using CCC, it will shrink from 25GB to 15GB for a clean installed Catalina OS

                                • 13. Re: Shrinking APFS?
                                  AlessandroDN Novice

                                  This is what I did - essentially going back in the early Linux days :/


                                  - within the VM create a "zero" file in your home folder:

                                  dd if=/dev/zero of=/Users/alessandro/zero.bin bs=1m


                                  - after the dd completed (you receive a warning that disk is running out of space), delete the zero.bin file

                                  rm /Users/alessandro/zero.bin


                                  - shut down the VM and shrink the VMDK:

                                  /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k <VMDK_DISK>

                                  1 person found this helpful
                                  • 14. Re: Shrinking APFS?
                                    dlhotka Virtuoso

                                    You know, that's brilliant.  I use that to migrate physical to virtual, but didn't even think about it for shrinking.

                                    1 2 Previous Next