This command is useful to see the APFS volumes, all of which share the same free space on the containing /dev/disk1 virtual disk: $ diskutil list virtualĠ: APFS Container Scheme - +500.0 GB disk1ġ: APFS Volume Macintosh HD 15.3 GB disk1s1Ģ: APFS Snapshot .update-. 15.3 GB disk1s1s1ģ: APFS Volume Macintosh HD - Data 48.7 GB disk1s2Ĥ: APFS Volume Preboot 591.0 MB disk1s3ĥ: APFS Volume Recovery 622.The df command lists several columns: Filesystem Size Used Avail Use% Mounted on Printf "Size: %.1f GB Free: %.1f GB\n", total_size_gb, total_avail_gb Total_size_gb = size_byte / 1000000000 # convert bytes to GB Size_byte = $2 * 512 # convert from 512 byte blocks # This works for a single internal disk that contains root FS # Only use macOS versions of df, awk, etc It works for a single internal SSD, but would need changes for external disks to check each one separately. The answer from was useful but didn't work for me on Big Sur - so here's an updated version of that script. How much space are on ALL disks (sum) on this host, and how much is available on ALL disks (sum) ? I just want to use one or more CLI commands, which somehow let me respond this question: I know somehow this behavior is related to APFS thing but again, I need some logic to filter out the duplicated entry. Map auto_home 0B 0B 0B 100% 0 0 100% /homeĪgain, there are 2 lines (for /dev/disk1s1 and /dev/disk1s4) showing: Volume Total Space and Volume Free Space it seems they both lists the same thing:įilesystem Size Used Avail Capacity iused ifree %iused Mounted on
So, my problem is how to correctly parse it to get:įrom the output, I can't simply sum all the lines starting with: Read-Only Volume: Not applicable (not mounted)
Volume Free Space: 0 B (0 Bytes) (exactly 0 512-Byte-Units) Volume Total Space: 0 B (0 Bytes) (exactly 0 512-Byte-Units) Read-Only Volume: Not applicable (no file system) Volume Name: Not applicable (no file system)Ĭontent (IOContent): GUID_partition_schemeĭisk Size: 500.3 GB (500277788672 Bytes) (exactly 977105056 512-Byte-Units) On macOS High Sierra, with SSD formatted with APFS, I've got: diskutil info -all