/dev/trouble
Eric Roller's Development Blog

APFS: Deleting Time Machine Snapshots without tmutil

- Posted in macOS by

Last night, I found myself in this endless loop:

  1. The Mac OS Catalina installer cancels with the message that "macOS could not be installed on your computer: There is not enough free space on your disk to install", offering me to quit the installation or to restart and try again. The only visible button is "Restart".
  2. Trying to delete files using the Terminal application from the installer is fruitless. It never is enough.
  3. Reboot always returns to the installer since the original start volume is no longer bootable. Back to square one.

Diagnosis

The only tools available from the installer are Disk Utility and Terminal. Opening Disk Utility reveals a mere 10 GB of space on my disk, where it should have been more than 30 GB.

Running "First Aid", and opening the disclosure triangle to get more information reveals that there are three Time Machine snapshots on my disk. Fine, let’s delete them, but how?

Disk Utility offers no commands to handle Time Machine snapshots.

Where is tmutil?

Numerous solutions articles on the web suggest to use tmutil to manage Time Machine snapshots and settings.

Back in the Terminal, I type tmutil, but all I get is:

-bash-3.2# tmutil
tmutil : command not found

It turns out, the installer image is not a complete macOS system and tmutil is not available.

I also searched the contents of my drive, but to no avail:

-bash-3.2# find /Volume/Dizzy -name tmutil -print

Not knowing which commands are available, I find myself typing a<TAB> to see commands starting with 'a', b<TAB>, then c<TAB>. For d<TAB>, I see diskutil, and this is where it the solution lies.

Solution: diskutil

All the steps in order:

  1. If the menu bar in your installer isn't visible, click on one of the icons in the top-right corner of the screen. The menu bar should become visible.
  2. From the menu bar, open the Terminal application.
  3. You can type diskutil to see the commands that are available:

    -bash-3.2# diskutil
    Disk Utility Tool
    Utility to manage local disks and volumes
    Most commands require an administrator or root user
    
    WARNING: Most destructive operations are not prompted
    
    Usage:  diskutil [quiet] <verb> <options>, where <verb> is as follows:
    
         list                 (List the partitions of a disk)
    [...]
         apfs <verb>          (Perform additional verbs related to APFS)
    
    diskutil <verb> with no options will provide help on that verb
    
  4. Note that there are additional "apfs" commands (verbs):

    -bash-3.2# diskutil apfs
    Usage:  diskutil [quiet] ap[fs] <verb> <options>
            where <verb> is as follows:
    
         list                (Show status of all current APFS Containers)
         listUsers           (List cryptographic users/keys of an APFS Volume)
         listSnapshots       (List APFS Snapshots in a mounted APFS Volume)
    [...]
         deleteSnapshot      (Remove an APFS Snapshot from an APFS Volume)
    [...]
    diskutil apfs <verb> with no options will provide help on that verb
    
  5. If you don't know the name of your hard disk, you can use diskutil apfs list to see all disks and their names.

  6. Use diskutil apfs listSnapshots to list the snapshots, e.g. for your disk named 'Dizzy':

    -bash-3.2# diskutil apfs listSnapshots Dizzy
    Snapshots for disk1s1 (3 found)
    |
    +-- F5D46466-3269-4480-BA1A-8BE23DF1800
    |   Name:        com.apple.TimeMachine.2019-10-07-205243
    |   XID:         2201791
    |   Purgeable:   Yes
    |
    [...]
    
  7. To delete a snapshop, use diskutil apfs deleteSnapshot with the UUID copied from the list above:

    -bash-3.2# diskutil apfs deleteSnapshot Dizzy -uuid F5D46466-3269-4480-BA1A-8BE23DF1800
    Deleting APFS Snapshot F5D46466-3269-4480-BA1A-8BE23DF1800 "com.apple.TimeMachine.2019-10-07-205243" from APFS Volume disk1s1
    Started APFS operation
    Finished APFS operation
    
  8. Repeat for the other snapshots.

In my case, that freed up 50 GB on my disk, allowing the macOS Catalina installer to continue.

[Update 2019-10-21: Corrected typo 'apgf' -> 'apfs']