Identifying Partitions

Linux identifies partitions using device files whose names are based on those for the low-level hardware devices. Specifically, Linux numbers its partitions: 1-4 for primary and extended partitions, and 5 and up for logical partitions within an extended partition. To access a particular partition, append its number to the device filename for a particular hard disk. For instance, if the hard disk is /dev/sda (the first SCSI hard disk), you'd use /dev/sda5 to access the first logical partition on that disk.

Removable media sometimes use partitions, but sometimes don't. You might access a removable SCSI disk through /dev/sda, /dev/sdal, /dev/sda4, or some other partition number. Zip disks come prepartitioned with a single partition: number 4. Magneto-optical discs and CD-ROMs are seldom partitioned.

Of course, you must first know the base name for the disk device. Two types of disk devices are common in Linux: EIDE and SCSI. Each type of device has its own identification rules. For EIDE, the device filenames all begin with /dev/hd, and continue with a letter to identify the specific device. EIDE devices can be classified according to two factors: The EIDE interface or chain (each chain has one physical connector on the motherboard or EIDE controller) and whether the drive is configured as a master or slave drive. Most x86 motherboards support two chains, and each chain supports one master and one slave drive. Linux labels these starting with a for the master on the primary chain, then b for the slave on the primary chain, c for the master on the secondary chain, and d for the slave on the secondary chain. If you add another chain, the letters continue to e and onward. Thus, almost all EIDE-based systems will have a /dev/hda, and additional drives may take other identifiers. A system might have /dev/hda and /dev/hdc, but no /dev/hdb, for instance. CD-ROM, Zip, and other removable-media devices use the same identification scheme.

SCSI works somewhat differently. With SCSI, the first physical disk is always /dev/sda, the second is always /dev/sdb, and so on. This is true no matter what the SCSI IDs of the specific drives, or if the drives are used from the same host adapter. Most removable-media disks (like Zip or magneto-optical disks) use these same identifiers, but CD-ROM drives are an exception. The first SCSI CD-ROM drive is called /dev/scd0, the second is /dev/ scdl, and so on.

Most systems create a link so that you can use /dev/cdrom to access your CD-ROM drive, no matter what it's called.

Linux also supports floppy disks, of course. On a one-floppy system, you'll most frequently use /dev/fd0 as the device filename. Higher numbers (/dev/fdl and above) refer to additional floppy drives. There are also device filenames that refer to a floppy of a specific capacity, such as /dev/ fd0H1440 for a 1440KB floppy.

If you don't remember what Linux called your partitions at system installation, you can use the fdisk program to find out. Pass it the -1 parameter (that's a lowercase L, not a number 1) and the name of a disk device (such as /dev/hdb or /dev/sda) to obtain a listing of the partitions on that disk, thus:

Disk /dev/hdb: 255 heads, 63 sectors, 1216 cylinders

Units = cylinders of 16065 * 512 bytes

Device Boot

Start

End

Blocks

Id

System

/dev/hdbl

257

1216

7711200

5

Extended

/dev/hdb2

1

192

1542208+

fb

Unknown

/dev/hdb3 ^NTFS

193

256

514080

17

Hidden HPFS/

/dev/hdb5

257

516

2088418+

6

FAT16

/dev/hdb6 *

517

668

1220908+

7

HPFS/NTFS

/dev/hdb7

669

1216

4401778+

83

Linux

This output shows the device name associated with the partition, the start and end cylinder numbers, the number of 1024-byte blocks in the partition, the partition's hexadecimal (base 16) ID code, and the partition or OS type associated with that code.

Linux ignores the partition ID code except during installation and to identify extended partitions, but some other OSs use it to determine which partitions they should try to mount. Therefore, it's important that you set any Linux partition's ID code to 0x83. (Linux swap partitions use 0x82.)

The Ultimate Computer Repair Guide

The Ultimate Computer Repair Guide

Read how to maintain and repair any desktop and laptop computer. This Ebook has articles with photos and videos that show detailed step by step pc repair and maintenance procedures. There are many links to online videos that explain how you can build, maintain, speed up, clean, and repair your computer yourself. Put the money that you were going to pay the PC Tech in your own pocket.

Get My Free Ebook


Post a comment