# [[Mac diskutil]] _Created: 2025-07-31_ | #osx #mac | [[Mac OSX System Administration]] ## List of disks in the system ```bash diskutil list ``` ## Information on a disk NOTE: just the name, not the whole path used. ```shell-session $ diskutil info disk4 Device Identifier: disk4 Device Node: /dev/disk4 Whole: Yes Part of Whole: disk4 Device / Media Name: SanDisk 3.2Gen1 ... Content (IOContent): FDisk_partition_scheme Protocol: USB SMART Status: Not Supported Disk Size: 30.8 GB (30784094208 Bytes) (exactly 60125184 512-Byte-Units) Device Block Size: 512 Bytes Device Location: External Removable Media: Removable Media Removal: Software-Activated Solid State: Info not available Virtual: No ``` ## Unmounting Single volume `diskutil umount VOLNAME.` NOTE: `umount`, not `unmount` ```shell-session $ diskutil info disk4s1 Device Identifier: disk4s1 Device Node: /dev/disk4s1 Whole: No Part of Whole: disk4 Volume Name: system-boot Mounted: Yes <------- Mount Point: /Volumes/system-boot ... $ diskutil umount disk4s1 Volume system-boot on disk4s1 unmounted $ diskutil info disk4s1 Device Identifier: disk4s1 Device Node: /dev/disk4s1 Whole: No Part of Whole: disk4 Volume Name: system-boot Mounted: No ``` For whole disk `diskutil unmountDisk disk4` ```shell-session $ diskutil unmountDisk disk4 Unmount of all volumes on disk4 was successful ``` >[!note] Disk will be invisible to Finder but visible to diskutil ## Ejecting removable disks `diskutil eject disk4` >[!note] Disk will be invisible to diskutil and Finder till physically re-inserted. ```shell-session $ diskutil eject disk4 Disk disk4 ejected $ diskutil info disk4 Could not find disk: disk4 ``` ## Mounting `diskutil mount VOL` for a single volume ```shell-session $ diskutil mount disk4s1 Volume system-boot on disk4s1 mounted ``` `diskutil mountDisk DISK` for all volumes on a disk ```shell-session $ diskutil mountDisk disk4 Volume(s) mounted successfully ``` ## Checking disk `diskutil verifyVolume VOLNAME` ```shell-session $ diskutil verifyVolume disk4s1 # FAT32 Started file system verification on disk4s1 (system-boot) Verifying file system Volume is already unmounted Performing fsck_msdos -n /dev/rdisk4s1 ** /dev/rdisk4s1 ** Phase 1 - Preparing FAT ** Phase 2 - Checking Directories ** Phase 3 - Checking for Orphan Clusters 689 files, 103693 KiB free (207387 clusters) File system check exit code is 0 Restoring the original state found as unmounted Finished file system verification on disk4s1 (system-boot) $ diskutil verifyVolume disk4s2 # ext4 Error starting file system verification for disk4s2: Unrecognized file system (-69846) ``` >[!note] Verifying mounted volumes >diskutil will unmount volume, verify and mount it back again ## Repairing Disk `diskutil repairVolume VOLNAME` ```shell-session $ diskutil repairVolume disk4s1 Started file system repair on disk4s1 (system-boot) Checking file system and repairing if necessary and if possible Volume was successfully unmounted Performing fsck_msdos -y /dev/rdisk4s1 ** /dev/rdisk4s1 ** Phase 1 - Preparing FAT ** Phase 2 - Checking Directories ** Phase 3 - Checking for Orphan Clusters 687 files, 103695 KiB free (207390 clusters) File system check exit code is 0 Restoring the original state found as mounted Finished file system repair on disk4s1 (system-boot) ``` >[!note] Repairing mounted volumes >diskutil will unmount volume, attempt repair and mount it back again ## Filesystem formats supported ```shell-session $ diskutil listFilesystems Formattable file systems These file system personalities can be used for erasing and partitioning. When specifying a personality as a parameter to a verb, case is not considered. Certain common aliases (also case-insensitive) are listed below as well. ------------------------------------------------------------------------------- PERSONALITY USER VISIBLE NAME ------------------------------------------------------------------------------- Case-sensitive APFS APFS (Case-sensitive) (or) APFSX APFS APFS (or) APFSI ExFAT ExFAT Free Space Free Space (or) FREE MS-DOS MS-DOS (FAT) MS-DOS FAT12 MS-DOS (FAT12) MS-DOS FAT16 MS-DOS (FAT16) MS-DOS FAT32 MS-DOS (FAT32) (or) FAT32 HFS+ Mac OS Extended Case-sensitive HFS+ Mac OS Extended (Case-sensitive) (or) HFSX Case-sensitive Journaled HFS+ Mac OS Extended (Case-sensitive, Journaled) (or) JHFSX Journaled HFS+ Mac OS Extended (Journaled) (or) JHFS+ ``` ## Erasing disk Will re-partition a whole disk, in new format with volume name. ``` Usage: diskutil eraseDisk format name [APM[Format]|MBR[Format]|GPT[Format]] MountPoint|DiskIdentifier|DeviceNode (Re)-partition a whole disk (create a new partition map). ``` > - This completely erases any existing data on the given whole disk; all volumes on this disk will be destroyed. > - Format is the specific file system name you want to erase it as (HFS+, etc.). > - Name is the (new) volume name (subject to file system naming restrictions), or can be specified as %noformat% to skip initialization (newfs). > - You cannot erase the boot disk. >[!note] Use `partitionDisk` for more control of partitioning ## Articles - [Pro Terminal Commands: Using diskutil](https://www.applegazette.com/mac/pro-terminal-commands-using-diskutil/) (applegazette.com)