Name
diskutil — stdin stdout - file -- opt --help --version
Synopsis
diskutilaction[options]
The diskutil command operates
on disk partitions: mounting and unmounting, getting information,
renaming, erasing, and more. Read-only operations can be done by any
user, but writing and mounting require an administrator. For example,
if you have a portable USB drive mounted:
➜ df -h /Volumes/MyUSB
Filesystem Size Used Avail Capacity Mounted on
/dev/disk1s2 1.8Ti 813Mi 1.8Ti 1% /Volumes/MyUSByou can unmount it with either of these diskutil commands, by providing the
directory where it’s mounted:
➜ sudo diskutil unmount /Volumes/MyUSB
Volume MyUSB on disk1s2 unmountedor the associated device in the /dev directory:
➜ sudo diskutil unmount /dev/disk1s2
Volume MyUSB on disk1s2 unmountedand since it’s a portable drive, even eject it for safe unplugging from the Mac:
➜ sudo diskutil eject /dev/disk1s2
Disk /dev/disk1s2 ejectedThen you can remount it by its device name:
➜ sudo diskutil mount /dev/disk1s2
Volume MyUSB on /dev/disk1s2 mounteddiskutil does many other
tricks, such as getting information about a partition:
➜ diskutil info /Volumes/MyUSB
Device Node: /dev/disk1s2
File System: HFS+
Name: Mac OS Extended
Bootable: Is bootable
Protocol: USB
Total Size: 2.0 TB (2000054960128 Bytes)
Ejectable: Yes
...renaming a partition:
➜ sudo diskutil rename /dev/disk1s2 OtherName
Volume on disk1s2 renamed to OtherNameand checking its internal structure for errors:[16]
➜ sudo diskutil verifyVolume /dev/disk1s2 ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access