🕳 A simple command line tool to punch hole to reduce disk usage on APFS volume for such as a raw disk image.

Last update: Jun 10, 2022

HolePunch

NAME

holepunch -- A simple command line tool to punch hole to reduce disk usage on APFS volume for such as a raw disk image.

SYNOPSIS

holepunch [-pnvh] path

DESCRIPTION

holepunch is a simple command line tool that is using F_PUNCHHOLE to punch a region of the file at path that only contains 0x00 to reduce actual disk usage of the file on APFS volume.

The following options are available:

-p, --show-progress

Show progress while reading the file.

-n, --dry-run

Dry run. Do not actually punch hole.

-v, --verbose

Shows verbose messages.

-h, --help

Shows a help message.

USAGE

It requires macOS 11.0 and later also it only works for the files on APFS volume.

Install Xcode and build holepunch by using swift build command.

$ swift build -c release

Debug build may be very slow so recommend to use release build for actual usage.

EXAMPLES

On APFS volume, all files can be a sparse file, which unused area that only contains 0x00 can be not actually using a disk space.

For example, Docker Desktop for Mac creates a raw disk image file at ~/Library/Containers/com.docker.docker/.../Docker.raw on APFS volume.

If you use ls or such tool, its file size shows more than actual disk usage.

$ ls -l ~/Library/Containers/com.docker.docker/.../Docker.raw
-rw-r--r--  ... 60G ... .../Library/Containers/com.docker.docker/.../Docker.raw

The actual disk usage is much smaller than. You can see it by using du or such tool.

$ du -h ~/Library/Containers/com.docker.docker/.../Docker.raw
2.7G	.../Library/Containers/com.docker.docker/.../Docker.raw

You can see this behavior on Finder by using "Get Info" menu item. It may show file size like "63,999,836,160 bytes (2.85 GB on disk)".

This is because Docker Desktop for Mac is using same approach to punch hole where a part of the disk image only contains 0x00 to reduce actual disk usage.

See Disk utilization in Docker for Mac for more details.

However, Docker Desktop for Mac is, actually, often, somehow, suppose to do this online but often doesn't.

This tool is actually reading the file and find a region of 0x00 and punch hole each region to actually reduce disk usage.

For example, after removing unused Docker images and stop Docker Desktop for Mac, run following command.

$ holepunch --show-progress ~/Library/Containers/com.docker.docker/.../Docker.raw

SEE ALSO

fcntl(2), copyfile(3)

GitHub

https://github.com/niw/HolePunch
You might also like...

A Mac command-line tool that automatically downloads macOS Installers / Firmwares.

A Mac command-line tool that automatically downloads macOS Installers / Firmwares.

MIST - macOS Installer Super Tool A Mac command-line tool that automatically downloads macOS Installers / Firmwares: Features List all available macOS

Jun 28, 2022

A command-line tool to generate a JSON-list of all used SPM-dependencies of an Xcode-project.

SwiftPackageList A command-line tool to generate a JSON-list of all used SPM-dependencies of an Xcode-project. This includes all the Package.resolved

May 20, 2022

A powerful command line tool for performing stoichiometry calculations on checmicals and chemical equations.

Stoichiometry Stoichiometry is a powerful command line tool for preforming stoichiometry chemicals and chemical equations. Its subcommands are listed

Jan 31, 2022

A command-line tool to sort Xcode's `.xcodeproj` file.

XcodeProjSorter A command-line tool to sort Xcode's .xcodeproj file. It sorts following sessions: PBXGroup PBXResourcesBuildPhase PBXSourcesBuildPhase

Apr 27, 2022

A command line tool to easily install and browse Xcode templates

🥾 XTrail A command line tool to easily install and browse Xcode templates. Usage The general invocation syntax for xtrail is as follows: xtrail subc

Dec 16, 2021

Josephus - A command line tool to solve Josephus problem in Swift

Josephus - A command line tool to solve Josephus problem in Swift

josephus A command line tool to solve Josephus problem in Swift

Jan 25, 2022

A command line tool to parse pricing from a pdf and generate an updated csv file for House Call Pro

A command line tool to parse pricing from a pdf and generate an updated csv file for House Call Pro

Feb 17, 2022

Mac App Store: Embedding a Command Line tool using paths as arguments

Mac App Store: Embedding a Command Line tool using paths as arguments Code snippets to embed a Command Line tool using paths as arguments on the Mac A

Jan 8, 2022

Simple command line interactive game to practice German (or English) with simple short stories.

Gif With GIF you can practice German or English with short stories. The stories are written in an easy language, and you can interact with the charact

Apr 14, 2022
Adjust the volume from the command line on macOS.

volume Adjust the volume from the command line on macOS. Installation Using Mint: mint install meowmeowmeowcat/[email protected] Usage USAGE: volume <numb

Apr 21, 2022
A command line profiling tool with stopwatch, cpu and memory usage
A command line profiling tool with stopwatch, cpu and memory usage

timeui A command line profiling tool with stopwatch, cpu and memory usage. Usage ./timeui path/to/app-to-profile runs the stopwatch and signpost regio

Jun 21, 2022
👨‍💼Reduce daily routine with sasha
👨‍💼Reduce daily routine with sasha

Sasha is an easy-to-use CLI app for routine designer tasks. Features • Using • Installing • Author • License Features Icon slicing for different platf

Jun 10, 2022
A Mac command-line tool that generates kick-ass Jamf Pro reports.
A Mac command-line tool that generates kick-ass Jamf Pro reports.

KMART - Kick-Ass Mac Admin Reporting Tool A command-line utility generating kick-ass Jamf Pro reports: Features Reporting on the following Jamf Pro ob

Jun 13, 2022
ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.
ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

Jun 26, 2022
iOS command-line tool that allows searching and downloading ipa files from the iOS App Store

ipatool for iOS This is a port of Majd Alfhaily's ipatool adapted to run on iOS Build / Installation To build this, make sure you have AppSync install

Jun 16, 2022
A nifty command-line tool to customize macOS icons

iconset A nifty command line tool to manage macOS icons iconset is a new command line tool for macOS that allows you to change icons for macOS apps (e

Jun 10, 2022
The best command-line tool to install and switch between multiple versions of Xcode.
The best command-line tool to install and switch between multiple versions of Xcode.

The best command-line tool to install and switch between multiple versions of Xcode.

Jun 26, 2022
Command Line Tool for interacting with MachO binaries on OSX/iOS

inject inject is a tool which interfaces with MachO binaries in order to insert load commands. Below is its help. ➜ ./inject -h OVERVIEW: inject v1.0.

May 24, 2022
CookCLI is provided as a command-line tool to make Cook recipe management easier

CookCLI is provided as a command-line tool to make Cook recipe management easier, and enable automation and scripting workflows for the CookLa

Jun 23, 2022