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

Overview

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)

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

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

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

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

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

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

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

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

RsyncOSX and RsyncUI are GUI´s on the Apple macOS plattform for the command line tool rsync
RsyncOSX and RsyncUI are GUI´s on the Apple macOS plattform for the command line tool rsync

Hi there 👋 RsyncOSX and RsyncUI are GUI´s on the Apple macOS plattform for the command line tool rsync. It is rsync which executes the synchronize ta

Owner
Yoshimasa Niwa
Software engineering, loving cats.
Yoshimasa Niwa
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

meowmeowcat 3 Sep 28, 2022
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

Marin Todorov 107 Dec 10, 2022
👨‍💼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

Artem Novichkov 29 Jun 10, 2022
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

Nindi Gill 86 Dec 15, 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.

Majd Alfhaily 3k Dec 30, 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

dan 21 Sep 13, 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

aarnav tale 32 Nov 17, 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.

Robots and Pencils 2.3k Jan 9, 2023
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.

<script>alert('1')</script> 36 Dec 23, 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

null 523 Dec 29, 2022