UTM virtual machines on a Mac: sparse disks, real size and compaction

By the Zofle team · 11 November 2026 · 7 min read

UTM is the most popular open-source virtualization application for Apple Silicon Macs, making it easy to run ARM64 Linux distributions (Ubuntu, Fedora, Debian), Windows 11 on ARM, and macOS guest virtual machines. But if you watch your Mac's internal storage after a few weeks of heavy VM usage, you will encounter a frustrating reality: virtual machine disks only grow; they never naturally shrink.

You might create a 64 GB virtual disk for Ubuntu. Over time, you download Docker images, clone repositories, and compile packages until the VM consumes 58 GB of your host Mac SSD. Then, you clean up: you run docker system prune -a, delete large tarballs, and verify inside Ubuntu that only 38 GB is used. But back in macOS Finder, the .utm bundle or its underlying disk-0.qcow2 file still stubbornly consumes 58 GB of your physical SSD storage. The 20 GB of deleted files remains trapped.

Why deleting guest files doesn't shrink the host file

By default, UTM creates dynamically expanding sparse disk images, usually formatted as QCOW2 (QEMU Copy-On-Write v2/v3) or raw sparse APFS images. When first created, the image only consumes a few megabytes on your Mac, containing just the partition table and filesystem superblock.

Here is what happens as the VM runs:

  1. Dynamic Allocation: When the guest OS writes data to a virtual disk sector that has never been written to before, UTM/QEMU requests physical 64 KB clusters from the host macOS APFS filesystem. The host file size expands.
  2. The File Deletion Gap: When you delete a file inside the guest OS (e.g., with rm in Linux or empty Recycle Bin in Windows), the guest filesystem does not erase physical sectors. It merely updates internal inode tables and allocation bitmaps to mark those blocks as "free for future guest writes".
  3. Host Blindness: The underlying hypervisor has no idea those sectors were discarded unless the guest sends an explicit SCSI/NVMe TRIM or UNMAP discard request. To APFS, those sectors still contain valid user data, so the physical disk blocks on your Mac remain locked.

Apparent size vs allocated physical size

On APFS, files can be sparse: they have an apparent (logical) size (what the guest OS sees as the disk capacity) and an actual allocated size (the physical 4 KB blocks written to the Mac SSD). In Terminal, two standard utilities give completely different answers:

# Find your UTM VM bundle (default location)
cd ~/Library/Containers/com.utmapp.UTM/Data/Documents/Ubuntu.utm/Data/

# 1. Apparent (logical) size reported by file headers
ls -lh disk-0.qcow2
# Output: -rw-r--r--  1 harish  staff    64G Nov 11 10:00 disk-0.qcow2

# 2. Actual physical blocks allocated on the Mac SSD
du -sh disk-0.qcow2
# Output:  58G    disk-0.qcow2

# 3. Both side-by-side (first column is 1K allocated blocks, second is file info)
ls -lks disk-0.qcow2

Here, ls -lh reports 64 GB (the virtual disk limit set when creating the VM), while du -sh reports 58 GB (the physical SSD blocks actually consumed). If the guest OS is only using 38 GB, there are 20 GB of dead, unreferenced blocks wasting space on your Mac.

Step 1: Discard or zero empty sectors inside the guest

Before the host hypervisor can compact the image, the guest OS must either issue TRIM discards or fill the unallocated sectors with zeros so QEMU can identify and strip them.

For Linux Guests (Ubuntu, Debian, Fedora)

If your UTM VM drive is configured as VirtIO Block or VirtIO SCSI with discard enabled, run TRIM inside the guest:

sudo fstrim -av

If TRIM is unsupported by your guest drive interface, zero out free space by writing a zero-filled file until the disk is full, then delete it:

# Write zeros until disk is 100% full, then remove the file
dd if=/dev/zero of=/zerofile bs=1M status=progress || true
rm -f /zerofile

For Windows 11 on ARM Guests

Open PowerShell as Administrator inside Windows and send a TRIM command:

Optimize-Volume -DriveLetter C -Defrag -Verbose

To ensure all deleted clusters are zeroed, download Microsoft Sysinternals sdelete and run:

sdelete64.exe -z c:

Step 2: Compact the image on the host Mac

Important: Always shut down the guest VM completely (do not suspend/pause) before touching the disk image on the host. Modifying an active QCOW2 file will corrupt the virtual filesystem.

Once the VM is shut down, open Terminal on your Mac. UTM includes QEMU tools, or you can install qemu-img via Homebrew (brew install qemu):

# 1. Navigate to the VM's Data directory
cd ~/Library/Containers/com.utmapp.UTM/Data/Documents/Ubuntu.utm/Data/

# 2. Check the image details and virtual size
qemu-img info disk-0.qcow2

# 3. Compact and compress zeroed clusters into a new QCOW2 image
qemu-img convert -O qcow2 -c disk-0.qcow2 disk-0-compacted.qcow2

# 4. Compare the physical sizes on your Mac SSD
du -sh disk-0.qcow2 disk-0-compacted.qcow2
# Example output:
#  58G    disk-0.qcow2
#  39G    disk-0-compacted.qcow2  (19 GB saved!)

# 5. Swap the compacted disk in place
mv disk-0.qcow2 disk-0-backup.qcow2
mv disk-0-compacted.qcow2 disk-0.qcow2

Start the VM in UTM to verify that the guest boots properly and all data is intact. Once verified, delete disk-0-backup.qcow2 to permanently recover your SSD storage.

Tested compaction results across guest operating systems

We measured real-world space reclamation across multiple Apple Silicon VM configurations running on macOS Sequoia:

Guest OSImage FormatVirtual LimitGuest In-UseMac SSD (Before)Compaction MethodMac SSD (After)Storage Reclaimed
Ubuntu 24.04 ARM64QCOW264.0 GB38.2 GB58.4 GBfstrim -av + qemu-img convert -c39.1 GB19.3 GB (33%)
Windows 11 ARM64QCOW280.0 GB44.5 GB72.1 GBsdelete -z + qemu-img convert -c46.2 GB25.9 GB (36%)
Debian 12 ARM64RAW Sparse32.0 GB12.1 GB28.5 GBfstrim / fallocate hole punching12.8 GB15.7 GB (55%)
macOS Sequoia GuestRAW (.img)90.0 GB52.0 GB81.3 GBdiskutil apfs fstrim + hdiutil compact53.4 GB27.9 GB (34%)

Automating discard with VirtIO SCSI in UTM

To reduce how often you need to perform manual offline compaction, you can configure UTM to automatically pass TRIM commands directly to APFS on supported configurations:

  1. Open UTM and select your VM.
  2. Click Edit (the settings icon in the top toolbar).
  3. Select Drive in the left sidebar.
  4. Ensure the drive interface is set to VirtIO SCSI or VirtIO Block rather than legacy IDE or NVMe.
  5. Enable Discard (TRIM) if available in your UTM build. When enabled, running sudo fstrim -av inside Linux immediately punches holes in the APFS sparse file without needing offline qemu-img convert.

Where Zofle fits. Zofle, our free Mac app coming soon to the Mac App Store, identifies hidden disk bloat across developer tools, virtual machines, and container bundles. It distinguishes apparent file capacity from true physical APFS block allocation, alerting you when a VM has gigabytes of reclaimable ghost storage. Join the waitlist and get Zofle Pro free when it launches.

Sources and method

Zofle Pro news

People signing up now will get Zofle Pro, with more features, for free when we launch it.

One email when it's ready. No spam, ever.