There is a special nomenclature that linux uses to refer to mass storage that must be understood.
Linux used to deal with two kind of drives, depending of the electronic interface (controller), IDE and SCSI. Oldtimers remember the day where cdwriters where acccessed through "SCSI emulation". In fact IDE and SCSI use mostly the same low level commands and for 2007 up, with the new "SATA" interface, the naming was unified and, in new ditributions, all the drives have the same naming. For this part, CD or DVD readers/writers are seen like Hard Drives.
By convention, IDE drives where given device names /dev/hdato /dev/hdd. Hard Drive A( /dev/hda) is the first drive and Hard Drive C( /dev/hdc) is the third.
A typical PC has two IDE controllers, each of which can have two drives connected to it. For example, /dev/hdais the first drive (master) on the first IDE controller and /dev/hddis the second (slave) drive on the second controller (the fourth IDE drive in the computer).
So, typically, a computer with IDE controller can accomodate 4 drives: /dev/hda (primary master), /dev/hdb (primary slave), /dev/hdc (secondary master), /dev/hdd (secondary slave). Some (rare) Mother Boards have more than two controllers, some addition cards can also have controllers, these are numbered following the alphabet, but one have to figure out what real names are given for his particular hardware.
You can have drives where ever you want, it's not mandatory to fill the gaps. You may have interest to read about what drive/cdrom connect to what place, but it's out of this document scope.
Now all the rotating hard drives uses the same names as the old SCSI controllers, that is "s" in place of "h", so /dev/sda, and so on. The number of drives depends on the number of controllers on the Mother Board or the extended boards. Usually 4 are available. What will be the number of a drive is up to the controller card and the way it's read by the kernel, so difficult to say at first.
Flash drives are usually not connected through IDE or SATA interfaces and so don't uses the same names. Several interfaces are used with each different names. The kernel documentations gives the names.
You will find in some apps references to lowlevel SCSI devices and various naming conventions, for example (wodim is the command line cd burner):
wodim --scanbus scsibus1: 1,0,0 100) * 1,1,0 101) 'TSSTcorp' 'CD/DVDW TS-L632D' 'ac00' Removable CD-ROM 1,2,0 102) * 1,3,0 103) * 1,4,0 104) * 1,5,0 105) * 1,6,0 106) * 1,7,0 107) *
And you may have to use some sort of SCSI:1,1,0option to access the CDROM. try to avoid using this as much as possible, as it's very error prone and should be let to programmers only. I only mention it because you can't always avoid it.
If you do "cat /dev/ | more", you can see:
lrwxrwxrwx 1 root root 3 mars 9 07:56 scd0 -> sr0 (...) crw-r----- 1 root disk 21, 0 mars 9 07:56 sg0 crw-rw----+ 1 root disk 21, 1 mars 9 07:56 sg1
These scd, sr, sg devices are lowlevel interface (notice the "c" for "character"). Try not using them. dmesgand more /var/log/boot.msgshould give you the usable sdxx device, like (short summary):
<5>sd 0:0:0:0: [sda] 976773168 512-byte hardware sectors: (500GB/465GiB) <5>sd 0:0:0:0: [sda] Write Protect is off <7>sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
This mean the drive is /dev/sda.
However these files (given by dmesgand more /var/log/boot.msg) used to be easy to read but are no more. Now the kernel starts in parallel several drivers, so the messages are mixed, you can have
<6> sda:<6>USB Universal Host Contr'ller Interface driver v3.0
This don't mean that your sda drive is an usb one, but the usb module was started at the same time as the drive one and send it's messages simultaneously. You still have a /dev/sdadrive.
Here the dmesg content for inserting an USB key:
scsi7 : SCSI emulation for USB Mass Storage devices usb 5-3: New USB device found, idVendor=0951, idProduct=160e usb 5-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 5-3: Product: DataTraveler 2.0 usb 5-3: Manufacturer: Kingston usb 5-3: SerialNumber: 200706200000000059188185 usb-storage: device found at 9 usb-storage: waiting for device to settle before scanning scsi 7:0:0:0: Direct-Access Kingston DataTraveler 2.0 1.00 PQ: 0 ANSI: 2 sd 7:0:0:0: [sdb] 3930112 512-byte hardware sectors: (2.01GB/1.87GiB) sd 7:0:0:0: [sdb] Write Protect is off sd 7:0:0:0: [sdb] Mode Sense: 23 00 00 00 sd 7:0:0:0: [sdb] Assuming drive cache: write through sd 7:0:0:0: [sdb] 3930112 512-byte hardware sectors: (2.01GB/1.87GiB) sd 7:0:0:0: [sdb] Write Protect is off sd 7:0:0:0: [sdb] Mode Sense: 23 00 00 00 sd 7:0:0:0: [sdb] Assuming drive cache: write through sdb: sdb1 sd 7:0:0:0: [sdb] Attached SCSI removable disk sd 7:0:0:0: Attached scsi generic sg2 type 0 usb-storage: device scan complete
You see there all what we where speaking about right now! SCSI emulation, scsi, sd and sg names, but also the sdb that is most important for us.
Here are the messages for a high speed SDHC card:
tifm_core: MMC/SD card detected in socket 0:1 mmc1: new SDHC card at address d555 mmcblk0: mmc1:d555 SD04G 3.79GiB mmcblk0: p1 /dev/mmcblk0p1 on /media/H2SD type vfat (rw,nosuid,nodev,noatime,flush,uid=1000,utf8,shortname=lower)
When the two cards are probably the same flash memory chip, the USB key uses the USB interface and SCSI emulation, the SDHC card uses the PCMCIA slot of the laptop, with a special device naming (/dev/mmcblk0). The use, as far as partitionning is involved is the same.
In a world where disks are many and removable, it's impossible to track what device is used by what disk. So there are now many way of using a disk name. This makes it extremely difficult to work with basic tools. These are "Disk labels" and "Disk UUID", also "Partition Labels". See fstab man page for details.