The Linux concept of a disk is not particularly intuitive. First, a single physical disk may contain several disk devices (e.g., /dev/hda1, /dev/hda2, etc.). Second, it is fairly rare to deal with disks directly in the course of day-to-day operations. Once a disk has been defined, you usually must put a filesystem on it in order to get any use out of it (see Chapter 11 for more information on the creation and maintenance of filesystems).
Those of you who've been reading these introductory sections have probably noticed a common theme by now: Linux does not care about the name of a particular resource; it is usually much more interested in what the resource's number is. Disks are no exception. All Linux devices have two numbers associated with them: the major device number, which corresponds to a device driver (program for manipulating the device hardware) within the kernel, and the minor device number, which specifies a particular device handled by that driver.
Humans Think of | The Kernel Prefers |
Timmy | uid=508 |
ls | inode=2026 |
/dev/hda5 | major=3, minor=5 |
Dividing an actual physical disk into usable chunks accessible to Linux is called partitioning. The resultant chunks are called partitions. There may be more than one partition on a given disk. Partitioning is most easily accomplished with one of the disk formatting programs (e.g., cfdisk or fdisk).
Discounting the amount of space required for system bookkeeping (superblock, inode table), partitions may be of any size. Within the partition, however, the disk is arranged into equally sized chunks of space called blocks. The size of the blocks differs from system to system but usually is some multiple of 512.
The commands covered in this section include the following:
badblocks | Test a disk for bad blocks. |
cfdisk | Partition a disk. |
du | Display information about disk usage. |
fdformat | Format a floppy disk. |
fdisk | Partition a disk. |
quota | Display or set disk quotas. |
setfdprm | Set floppy disk parameters. |