Skip to content

Instantly share code, notes, and snippets.

@neklaf
Last active August 30, 2020 19:21
Show Gist options
  • Save neklaf/9833e20795e6726f998db9f5e0a2cc8a to your computer and use it in GitHub Desktop.
Save neklaf/9833e20795e6726f998db9f5e0a2cc8a to your computer and use it in GitHub Desktop.
How to format a disk to write content on macOS from command line

Format an external hard drive from command line on macOS

Using the following command you're able to share the content inside the external disk with other Operating Systems, because we are going to create a partition with ExFAT (better write performance on macOS than NTFS):

$ diskutil eraseDisk ExFAT CleanDrive /dev/disk2
Started erase on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk2s2 as ExFAT with name CleanDrive
Volume name      : CleanDrive
Partition offset : 411648 sectors (210763776 bytes)
Volume size      : 234029056 sectors (119822876672 bytes)
Bytes per sector : 512
Bytes per cluster: 131072
FAT offset       : 2048 sectors (1048576 bytes)
# FAT sectors    : 8192
Number of FATs   : 1
Cluster offset   : 10240 sectors (5242880 bytes)
# Clusters       : 914136
Volume Serial #  : 5f4bfa84
Bitmap start     : 2
Bitmap file size : 114267
Upcase start     : 3
Upcase file size : 5836
Root start       : 4
Mounting disk
Finished erase on disk2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment