-->

Previous | Table of Contents | Next

Page 210

Device Name Disk Partition Filesystem Mounted At
/dev/hda1 1 1 ext2 /
/dev/hda3 1 3 ext2 /usr
/dev/hdb1 2 1 ext2 /usr/sr
/dev/hdb5 2 5 ext2 /home

Note that the partitions on the first disk have names starting with /dev/hda, and those on the second have names starting with /dev/hdb. These prefixes are followed by the number of the partition.

NOTE
All is not quite as simple as it could be in the partition table, however. Early hard disk drives on PCs were quite small (about 10MB), so there was a need for only a small number of partitions and the format of the partition table originally allowed for only four partitions. Later on, this became a restriction, and the extended partition was introduced as a workaround.

Inside each extended partition is another partition table. This enables this extended partition to be divided, in the same way, into four logical partitions. Partitions that aren't inside an extended partition are sometimes referred to as primary partitions.

Running fdisk -l shows that my first hard disk is divided up like this:

Device Begin Start End Blocks ID System
/dev/hda1 1 1 244 122944 83 Linux native
/dev/hda2 245 245 375 66024 82 Linux swap
/dev/hda3 376 376 1060 345240 83 Linux native

In this case, there are three primary partitions, of which one is a swap partition.

Disk Geometry

The units of the table in the last section are cylinders. The partition table allocates a consecutive block of cylinders to each partition. The term cylinder itself dates from the days when it was possible to remove a disk pack from a UNIX machine and point to the various parts. That can't be done here, so here's another way of looking at it.

Imagine that a hard disk is in fact a stack of pizzas. Each of the pizzas is a platter, a disk-shaped surface with a magnetic coating designed to hold magnetic encodings. Both sides of these platters are used. These rotate around the spindle, like the spindle in a record player. (Don't put pizzas on a record player!) The hard disk has a movable arm containing several disk heads. Each

Page 211

side of each platter has a separate disk head. If you were to put your fingers between the pizzas while keeping them straight, this would be the same as the arrangement of the heads on the arm. All the parts of the platters that the heads pass over in one rotation of the disk is called a cylinder. The parts of a single platter that one head passes over in one rotation is called a track. Each track is divided into sectors, as if the pizzas had been already sliced for you. The layout of a disk, its geometry, is described by the number of cylinders, heads, and sectors comprising the disk. Another important feature is the rotational speed of the disk—generally, the faster this is, the faster the hard disk can read or write data.

You can discover the geometry of one of your hard disks by using the hdparm command, and typical output might look like this:




# /sbin/hdparm -g /dev/hdc



/dev/hdc:

 geometry     = 6232/16/63, sectors = 6281856, start = 0



NOTE
IBM PCs with older BIOSes can have difficulty with large disks; see the Linux Large-Disk mini-HOWTO.

Floppy Disks

Floppy disks are removable low-capacity storage media. As storage devices, they are far slower than hard disks, but they have the advantage that they are removable and make good media for transporting modest amounts of data.

The block devices corresponding to the floppy disks begin with the letters fd; /dev/fd0 is the first, and any additional ones have increasing numbers. There are many possible formats for a floppy disk, and the kernel needs to know the format (geometry) of a disk to read it properly. Linux can usually work out the correct format so the automatic devices /dev/fd0 (plus /dev/fd1 and so on for extra floppy drives) are usually sufficient, but if for some reason it is necessary to specify the exact format, further device names are provided for indicating this. The device /dev/fd0H1440, for example, denotes a 1.44MB high-density floppy. There are many more devices indicating obscure formats, both older lower-capacity formats and other nonstandard extra_high-capacity formats. You can even create your own floppy disk formats, using the serfdprm program.

The most common reason to use the specific-format device names is that you are formatting a floppy for the first time. In this situation, the disk is not yet readable, so the kernel will not be able to autoprobe an existing format. You need to use the name /dev/fd0H1440, for example, to

Page 212

denote a high-density 3.5-inch disk in the first floppy drive. For device names representing other formats, refer to the fd manual page. Section 4 of the manual is the section devoted to devices and so on.

The process of formatting a floppy is completely destructive to the data on it, and because it requires writing to the actual device itself, it requires root privileges. It is done like this:


# fdformat /dev/fd0H1440

Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.

Formatting ... done

Verifying ... done

After you have formatted a floppy, please don't forget to use mkfs to build a filesystem on it (see the section "Creating New Filesystems," earlier in this chapter).

Another popular way of accessing floppy disks is to use the mtools package, which is a suite of programs designed to enable the user to manipulate DOS-format disks without needing to mount them. The commands are designed specifically to be similar to MS-DOS commands. Windows 95 filesystems are also supported. You will find an introduction to the use of mtools in the mtools manual page. mtools can also be used to access hard disks and disk image files, and it supports many nonstandard disk formats.

CD-ROM Drives

The CD-ROM drive is fundamentally just another kind of read-only block device. These are mounted in just the same way as other block devices. CD-ROMs almost always contain standard ISO 9660 filesystems, often with some optional extensions. There is no reason, however, why any other filesystem should not be used. Once you have mounted your CD-ROM, it behaves like any other read-only filesystem.

You can set up and mount your CD-ROM drive using the Red Hat File System Manager, as explained previously, or by using the following mount command:


# mount /dev/cdrom -t iso9660 /mnt/cdrom

The directory /mnt/cdrom is a very common place to mount one's CD-ROM drive under Red Hat Linux, because this is where the graphical package manager Glint expects to find the contents of the Red Hat installation CD-ROM, for example.

The device name /dev/cdrom is commonly used as a symbolic link to the actual device name corresponding to the CD-ROM, because at the time the CD-ROM drive became available for the PC, there was no cheap standard interface for these devices. Each manufacturer chose or invented an interfacing scheme that was incompatible with everyone else's. For this reason, there are about a dozen different drivers for CD-ROM drives available in the Linux kernel. SCSI would have been a sensible standard to have been used, but although SCSI CD-ROM drives are available, they're not particularly popular.

Previous | Table of Contents | Next