

Partition Drives with diskutil $ diskutil partitionDisk It rewrites the same file system that the volume started with, resetting the volume to a blank state. The reformat verb will erase a single volume on the disk while keeping the same name and format. The new disk will have one volume named $ diskutil reformat disk4s2 This example will erase disk2 and reformat it as journaled HFS+. The verb takes as inputs the format, new disk name and disk identifier, in that order. The eraseDisk verb handles reformatting disks, which erases all data and volumes on a single disk.
#HOW TO INITIALIZE DRIVE MAC VERIFICATION#
This will run a repair pass on the volume and attempt to fix any problems found in the verification process.įormat and Erase Drives with diskutil $ diskutil eraseDisk JHFS+ NewDiskName disk4 If it turns out that your volume needs to be repaired after you’ve verified it, you can run the repairVolume verb. If any mismatches are found, the disk will be identified as in need of repair. Verification involves checking the contents of the disk against the expected values. The verifyVolume verb will run a verification pass on a specific volume. Fixing Problems with diskutil $ diskutil verifyVolume disk1s2 To mount all volumes on a disk, use diskutil mountDisk disk1, for example. Only unmounted volumes can be mounted, obviously. It mounts volumes on internal disks manually. The mount verb is the inverse of the umount verb. Once a drive is ejected, it won’t appear in Finder or diskutil list until it’s physically unplugged and plugged in to its interface again. If it connects through an interface on the outside of your computer, it qualifies as a removable drive. Removable disks are things like USB hard drives and flash drives. The eject verb is a lot like unmounting a drive, but only for removable disks. You can’t unmount your boot disk or volume, and you’ll get an error if you try to unmount a disk or drive that’s currently in use. Disks are specified with their mount point, as seen above. The unmountDisk verb is similar to umount, but it unmounts an entire disk instead of one volume. Also, note the command is umount, with no “n”.

Unmounted disks become inaccessible via Finder, but they can still be seen via diskutil list and manipulated with other diskutil commands. You can also specify the volume using the partition name. In this example, I’ve specified the volume I want to unmount with the disk identifier. Unmounting is just like ejecting a volume from Finder, but it can be done to internal disks. The umount verb unmounts a specified volume. Unmounting and Ejecting with diskutil $ diskutil umount disk1s2 This is the most information you can get about your disk in one place, and it’s helpful when troubleshooting drive problems. You’ll see tons of stuff you might care about and a lot of stuff you won’t. Use the mount point to specify the target disk to grab information on. The info verb gets more information about a specific disk (disk1, in this case). We can use the other verbs to get more information about our drives and run specific operations. Partitions (called “volumes” in diskutil parlance) are specified by their identifier on the right.ĭisk identifiers follow the format disk_s_, where the underscores are replaced with identifying numbers. The mount points start with /dev/disk and are used to specify disk operations in diskutil. It indicates information like partitions, format and, importantly, mount points. This command will list all the disks attached to your machine. Just like in the English language, these verbs are things that diskutil can accomplish. The most basic verb for diskutil is list, which you’ll enter like so: $ diskutil list If you simply type diskutil into the command line and press Enter, you’ll receive a list of “verbs” that diskutil can operate on. Once you’re familiar with it, you’ll find that the command is often more powerful and faster than Disk Utility, with more features to boot. Just like Disk Utility, you can use the command to format disks, erase drives and more. Diskutil is the command line version of Disk Utility, the macOS application used to manage hard drives.
