Skip to content

Instantly share code, notes, and snippets.

View elliotberry's full-sized avatar
🌍
online

ɛʟʟɨօȶ b =^._.^= ∫ elliotberry

🌍
online
View GitHub Profile

I ran in to a problem with a new Western Digital hard drive (2TB) for use as a Time Machine backup drive on High Sierra. After plugging it in, I kept getting errors like "MediaKit reports not enough space on device for requested operation." After some digging, it appeared that this is an issue in macOS with initializing APFS from an NTFS partition.

Pulling out some old utils, I used diskutil and dd to fix the issue:

$ disktuil list
...
/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk4
@elliotberry
elliotberry / apfs_allocation.txt
Created August 28, 2025 07:23 — forked from hakanai/apfs_allocation.txt
APFS allocation examples
For a 256-block image: (I see the same for 246-block images)
1 block for main (current checkpoint's) container superblock
8 blocks for previous checkpoints and container superblocks
52 blocks for space manager and related objects
16 blocks for future expansion?
6 blocks for allocation info file blocks
------
83
catie:/Projects/small (master) ✓ ⇢ sudo diskutil mount -mountPoint /usr/local /dev/disk1s9
Volume on disk1s9 failed to mount
Perhaps the operation is not allowed by the invoking user (kDAReturnNotPrivileged)
This appears to be an APFS Volume; note that locked APFS volumes
will not mount unless unlocked (e.g. "diskutil apfs unlockVolume")
catie:/Projects/small (master) ✓ ⇢ sudo diskutil apfs unlockVolume Local
Passphrase:
Unlocking any cryptographic user on APFS Volume disk1s9
Error unlocking APFS Volume: The given APFS Volume is not encrypted (-69593)
catie:/Projects/small (master) ✓ ⇢ sudo diskutil mount -mountPoint /usr/local /dev/disk1s9
@elliotberry
elliotberry / gist:5101978a81c057568746f5a5bb8124ff
Created August 28, 2025 07:23 — forked from rctphone/gist:62f75cf2f0293bdc9dd27eebac1d5c61
How to solve "APFS inverter failed to invert the volume" error
After cloning APFS drives using Disk Utility it usually ends with a volume containing ContainerToInvert file with the size of a cloned partition.
Don't be afraid, using the following steps you can mount this file as APFS container and get all partitions.
1. Requirements
We need FUSE and xmount installed
2. Terminal
Open Terminal app and type the following:
$ sudo mkdir /Volumes/apfs_image/
@elliotberry
elliotberry / gist:b061e545fde37e4ed87458365583d61b
Created August 28, 2025 07:23 — forked from varahash/gist:9fc02e5b88c3259796e7b740b1963202
Repair APFS 'warning: overallocation detected on Main device'
1. Boot into Recovery mode (by pressing CMD+R while boot macOS)
2. Unmount APFS volumes automaticaly mounted by Recovery (where /dev/disk2 is your APFS container)
$ diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
3. Unlock APFS volumes (in case FileVault enabled for this volume)
$ diskutil apfs unlockVolume /dev/disk2s1 -nomount
@elliotberry
elliotberry / apfs_cli_tools.txt
Created August 28, 2025 07:15 — forked from timsutton/apfs_cli_tools.txt
apfs tools in Sierra
➜ ~ sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.1
BuildVersion: 16B2333a
➜ ~ ls -l /System/Library/Filesystems/apfs.fs/Contents/Resources
total 2088
-rwxr-xr-x 1 root wheel 349760 22 Sep 03:48 apfs.util
-rwxr-xr-x 1 root wheel 352880 22 Sep 03:48 apfs_invert
@elliotberry
elliotberry / asr.md
Created August 28, 2025 07:15 — forked from jevinskie/asr.md
asr (8) man page version 615 macOS 14.3.1 23D60

ASR(8) - System Manager's Manual

NAME

asr - Apple Software Restore; copy volumes (e.g. from disk images)

SYNOPSIS

asr verb

@elliotberry
elliotberry / apfs recovery
Created August 28, 2025 07:13 — forked from mailinglists35/apfs recovery
apfs recovery
https://matt.sh/apfs-object-map-free-recovery
APFS Object Map Recovery (free)
APFS Object Map Recovery
I spent a day figuring out how to look into a corrupt encrypted APFS partition. Here’s the notes.
If you only care about the answer, jump to the last section.
Kernel Panic
macOS hard panicked on me with a graphics driver corruption error com.apple.iokit.IOAcceleratorFamily2 (which happened after seven “gpuRestart” logs were generated back-to-back).
@elliotberry
elliotberry / _verify-repair-permissions-disk.md
Created August 28, 2025 07:10 — forked from bzerangue/_verify-repair-permissions-disk.md
Mac OS X Utilities via Terminal: (Verify and Repair: Disk Permissions AND Disk / Software Update / TimeMachine)

Verify and Repair Disk Permissions via Terminal (Mac OS X)

Verify Permissions

diskutil verifyPermissions /

Repair Permissions

diskutil repairPermissions /

@elliotberry
elliotberry / _verify-repair-permissions-disk.md
Created August 28, 2025 07:10 — forked from bzerangue/_verify-repair-permissions-disk.md
Mac OS X Utilities via Terminal: (Verify and Repair: Disk Permissions AND Disk / Software Update / TimeMachine)

Verify and Repair Disk Permissions via Terminal (Mac OS X)

Verify Permissions

diskutil verifyPermissions /

Repair Permissions

diskutil repairPermissions /