Disks and Filesystems
df | Display available space on mounted filesystems. |
diskutil | Perform operations on disks and partitions: mounting, formatting, renaming, and more. |
mount | Mount remote (or local) disks and partitions. |
fsck_hfs | Check a Macintosh HFS disk partition for errors. |
hdiutil | Work with disk images, such as ISO and DMG files. |
tmutil | Perform Time Machine operations. |
sync | Flush all disk caches to disk. |
rsync | Mirror a set of files onto another device or host. |
Macs can have multiple disks or disk partitions. In casual conversation, these are variously called disks, partitions, filesystems, volumes, even directories. We’ll try to be more accurate.
A disk is a hardware device, which may be divided into partitions that act as independent storage devices. You might think of disks and partitions as icons on the desktop or in the /Volumes folder, but in fact OS X represents them as special files in the directory /dev. For example, a typical Mac could have its system disk partition on /dev/disk0s2, a DVD drive on /dev/disk1, and an ancient SCSI tape drive on /dev/st0.
Before a partition can hold files, it is “formatted” by a program that writes a filesystem on it. A filesystem defines how files are represented; examples are HFS Plus (the traditional OS X filesystem) and NTFS (Microsoft Windows NT filesystem). Formatting is done by applications like Disk Utility, in the Mac’s Utilities folder. We will examine several command-line tools that do disk operations.
Once a filesystem is created, you can make ...
Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.