Intro [^]
This page is intended to help new Linux users and Windows users identify their hard disks / CD ROMs in a Linux box.
Linux disks and partition names may be different from other operating systems. You need to know the names that Linux uses when you format, mount or select partitions or disks.
Linux uses the so called device name to access disks and partitions. You can think of it as a link to the actual driver of the disk. All available devices have a corresponding file in /dev (e.g. /dev/hda1).
In general, each disk / CD-ROM has a three letter name, for example hda. Each partition in such a disk has a number associated with it, starting from 1. So the first partition of disk hda would be hda1, the second hda2 and so on.
Depending on the device type, Linux gives the following names to devices:
- IDE (ATA) floppies
The first floppy drive is named /dev/fd0.
The second floppy drive is named /dev/fd1. - IDE (ATA) disks /CD-ROMs
The master disk on IDE primary controller is named /dev/hda.
The slave disk on IDE primary controller is named /dev/hdb.
The master and slave disks of the secondary controller can be called /dev/hdc and /dev/hdd, respectively.
Linux represents the primary partitions as the drive name, plus the numbers 1 through 4. For example, the first primary partition on the first IDE drive is /dev/hda1. The logical partitions are numbered starting at 5, so the first logical partition on that same drive is /dev/hda5. Remember that the extended partition, that is, the primary partition holding the logical partitions, is not usable by itself. This applies to SCSI disks as well as IDE disks. - SCSI disks
The first SCSI disk (SCSI ID address-wise) is named /dev/sda.
The second SCSI disk (address-wise) is named /dev/sdb, and so on. - SCSI CD-ROMs
The first SCSI CD-ROM is named /dev/scd0, also known as /dev/sr0.
The second SCSI CD-ROM is named /dev/scd1, also known as /dev/sr1, and so on. - USB disks
They are named just like SCSI disks. The only difference is that the partition number has to do with the file system on the disk. If it's /dev/sdx4, then it's a VFAT file system and if it's /dev/sdx1 it's probably a linux (ext2, ext3) file system.
Examples [^]
In order to identify the disks of a system you have to work with, a basic knowledge of its configuration (how many disks it has, whether it's a dual-boot system etc.) is welcomed but not required. A more experienced user will not have to worry about it, though.
Linux systems based on a 2.6.x kernel (like Clonezilla Live and SystemRescueCD) provide all the necessary support to identify a system's disk configuration, with just a couple of commands.
Example 1 [^]
The first system I have to work with is a dual-boot system (Windows - Linux), with two disks and two DVD-ROMs.
The first command will tell me what disks and partitions exist in the system. So here it is:
# cat /proc/partitions
major minor #blocks name
3 0 312571224 hda
3 1 23446836 hda1
3 2 40957717 hda2
3 3 245240257 hda3
3 4 2923830 hda4
3 64 244198584 hdb
3 65 41945683 hdb1
3 66 2104515 hdb2
3 67 1 hdb3
3 68 125909437 hdb4
3 69 74236333 hdb5
The output of this command tells me that the system has two disks (hda and hdb) which are the primary master and slave devices.
The first disk contains four primary partitions (hda1-hda4) and the second one four primary partitions (hdb1-hdb4) and a logical one (hdb5). Wait a minute!!! this can't be right... In order to have a logical partition, I must have a primary that contains it, which means that in this case I can't have four primary partitions. So what is really happening here is that I have two primary and two logical, plus an extended primary which contains them.
What remains to be found is what type of partitions they are. I will find that out by executing the following commands:
# fdisk -l /dev/hda
Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 2919 23446836 7 HPFS/NTFS
/dev/hda2 2920 8018 40957717+ 7 HPFS/NTFS
/dev/hda3 8019 38549 245240257+ 7 HPFS/NTFS
/dev/hda4 38550 38913 2923830 82 Linux swap / Solaris
# fdisk -l /dev/hdb
Disk /dev/hdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 * 1 5222 41945683+ 83 Linux
/dev/hdb2 5223 5484 2104515 82 Linux swap / Solaris
/dev/hdb3 5485 14726 74236365 f W95 Ext'd (LBA)
/dev/hdb4 14727 30401 125909437+ 83 Linux
/dev/hdb5 5485 14726 74236333+ 83 Linux
Ok, this clears things up. The first disk contains three Windows XP partitions (NTFS) and a Linux Swap partition. In fact, /dev/hda1 is the system "disk" for Windows, since Windows will always be installed in the first partition of the primary master disk.
The second disk, on the other hand, contains a Linux partition (/dev/hdb1), a Linux Swap partition /dev/hdb2, and an extended partition /dev/hdb3 which contains two more Linux partitions (/dev/hdb4 and /dev/hdb5).
The final thing we need to know about this system is what CD/DVD-ROMs it has. So I execute the command:
# cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.20 2003/12/17
drive name: hdd hdc
drive speed: 0 126
drive # of slots: 1 1
Can close tray: 1 1
Can open tray: 1 1
Can lock tray: 1 1
Can change speed: 1 1
Can select disk: 0 0
Can read multisession: 1 1
Can read MCN: 1 1
Reports media changed: 1 1
Can play audio: 1 1
Can write CD-R: 0 1
Can write CD-RW: 0 1
Can read DVD: 1 1
Can write DVD-R: 0 1
Can write DVD-RAM: 0 1
Can read MRW: 1 0
Can write MRW: 1 0
Can write RAM: 0 1
The system has two DVD-ROMs, hdc which is the secondary master and is a DVD writer, and hdd which is the secondary slave and is a DVD reader.
At this point I will connect my USB stick, wait for a while and execute the command:
# cat /proc/partitions
major minor #blocks name
3 0 312571224 hda
3 1 23446836 hda1
3 2 40957717 hda2
3 3 245240257 hda3
3 4 2923830 hda4
3 64 244198584 hdb
3 65 41945683 hdb1
3 66 2104515 hdb2
3 67 1 hdb3
3 68 125909437 hdb4
3 69 74236333 hdb5
8 0 1007615 sda
8 4 1006576 sda4
As you can see, we have two more lines here, that reflect the changes to our system (the connection of the USB device). So my USB stick is recognized by the system as sda, and the disk itself contains a VFAT file system.
Example 2 [^]
The second system is a Linux box with one SCSI disk and a CD-ROM. Again I issue the command:
# cat /proc/partitions
major minor #blocks name
8 0 156290904 sda
8 1 64228 sda1
8 2 15735667 sda2
8 3 15735667 sda3
8 4 124744725 sda4
From its output I see I only have one disk sda, which contains four partitions.
Then I execute fdisk, which shows me that the disk contains one DOS and three Linux partitions.
# fdisk -l /dev/sda
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 8 64228+ 6 FAT16
/dev/sda2 9 1967 15735667+ 83 Linux
/dev/sda3 1968 3926 15735667+ 83 Linux
/dev/sda4 3927 19456 124744725 83 Linux
Finally I query its CD-ROMs, by executing the command:
# cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.20 2003/12/17
drive name: hda
drive speed: 0
drive # of slots: 1
Can close tray: 1
Can open tray: 1
Can lock tray: 1
Can change speed: 1
Can select disk: 0
Can read multisession: 1
Can read MCN: 1
Reports media changed: 1
Can play audio: 1
Can write CD-R: 1
Can write CD-RW: 1
Can read DVD: 1
Can write DVD-R: 0
Can write DVD-RAM: 0
Can read MRW: 1
Can write MRW: 1
Can write RAM: 0
Which tells me that I only have an IDE CD-ROM, (hda), which is actually a CD writer.
Then I connect my USB stick, and I get:
# cat /proc/partitions
major minor #blocks name
8 0 156290904 sda
8 1 64228 sda1
8 2 15735667 sda2
8 3 15735667 sda3
8 4 124744725 sda4
8 16 1007615 sdb
8 20 1006576 sdb4
Although it's the same stick I used with the previous system, which was recognized as sda there, now its name is sdb. So, its name depends on the system it is connected to, and will not always be the same.
SCSI disks when there are none!!! [^]
I am confused!!! I am on a disk with two ATA (PATA) disks, but when I query the partition list, this is what I get:
# cat /proc/partitions
major minor #blocks name
3 0 312571224 sda
3 1 23446836 sda1
3 2 40957717 sda2
3 3 245240257 sda3
3 4 2923830 sda4
3 64 244198584 sdb
3 65 41945683 sdb1
3 66 2104515 sdb2
3 67 1 sdb3
3 68 125909437 sdb4
3 69 74236333 sdb5
According to what's discussed up to now, the system seems to have two SCSI disks, but I know it actually has two ATA (PATA) disks. What's going on?.
What is really happening here is that you have one of the newest Linux kernels (using the libata disk driver), which shows ALL disks as SCSI. That does not mean that the system thinks it has SCSI disks, it just names them as such.
To make is clear, execute the commands:
# hdparm -i /dev/sda
/dev/sda:
Model=WDC WD3200AAJB-00TYA0, FwRev=00.02C01, SerialNo= WD-WCAPZ0648927
Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=50
BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=?16?
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=268435455
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=no WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-1,2,3,4,5,6,7
* signifies the current active mode
# hdparm -i /dev/sdb
/dev/sdb:
Model=WDC WD2500JB-00GVC0, FwRev=08.02D08, SerialNo= WD-WCAL76141931
Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
RawCHS=16383/16/63, TrkSize=57600, SectSize=600, ECCbytes=74
BuffType=DualPortCache, BuffSize=8192kB, MaxMultSect=16, MultSect=?16?
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=268435455
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=no WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-1,2,3,4,5,6
* signifies the current active mode
This is also valid for the CDs/DVDs of the system:
# cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.20 2003/12/17
drive name: sr1 sr0
drive speed: 0 126
drive # of slots: 1 1
Can close tray: 1 1
Can open tray: 1 1
Can lock tray: 1 1
Can change speed: 1 1
Can select disk: 0 0
Can read multisession: 1 1
Can read MCN: 1 1
Reports media changed: 1 1
Can play audio: 1 1
Can write CD-R: 0 1
Can write CD-RW: 0 1
Can read DVD: 1 1
Can write DVD-R: 0 1
Can write DVD-RAM: 0 1
Can read MRW: 1 0
Can write MRW: 1 0
Can write RAM: 0 1
While the hdparm shows they are ATA devices:
# hdparm -i /dev/sr0
/dev/sr0:
Model=HL-DT-ST DVDRAM GSA-H42L, FwRev=SL01 , SerialNo=K286CQF2231
Config={ Fixed Removeable DTR<=5Mbs DTR>10Mbs nonMagnetic }
RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=unknown, BuffSize=0kB, MaxMultSect=0
(maybe): CurCHS=0/0/0, CurSects=0, LBA=yes, LBAsects=0
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 *udma2 udma3 udma4
AdvancedPM=no
Drive conforms to: unknown: ATA/ATAPI-4,5,6,7
* signifies the current active mode