A Listing of the "/dev" Directory


Located here is a listing of the /dev directory. I have posted this information since you may not always have access to a functional Linux box, and you may need some of the values provided here.

ls -l /dev

ls -l /dev/rd

ls -l /dev/ida

Here is a short list of the most common of the /dev entries:
Floppy Drive: brw-rw---- 1 riblack floppy 2, 0 May 5 1998 fd0
IDE Drive (cdrom or hard drive): brw------- 1 riblack disk 3, 0 May 5 1998 hda
SCSI Drive: brw-rw---- 1 root disk 8, 0 May 5 1998 sda
SCSI Tape: crw-rw---- 1 root disk 9, 0 May 5 1998 st0
Modem - com1: crw------- 1 root root 5, 64 Dec 17 17:31 cua0
Modem - com1: crw------- 1 root root 4, 64 Mar 14 09:08 ttyS0
Common Links: lrwxrwxrwx 1 root root 3 Nov 11 12:05 cdrom -> hda
Common Links: lrwxrwxrwx 1 root root 8 Dec 29 16:02 tape -> /dev/st0
Common Links: lrwxrwxrwx 1 root root 5 Nov 11 12:05 mouse -> psaux
Common Links: lrwxrwxrwx 1 root root 10 Mar 10 15:59 /dev/fax -> /dev/ttyS2
Common Links: lrwxrwxrwx 1 root root 10 Mar 13 16:29 /dev/modem -> /dev/ttyS2
Loop Device: brw-rw---- 1 root disk 7, 0 May 5 1998 loop0
Printer: crw-rw---- 1 root daemon 6, 0 May 5 1998 lp0
Unknown (SCSI CD-Rom?): brw-rw---- 1 root disk 11, 0 May 5 1998 scd0
Generic SCSI Devices: crw------- 1 root sys 21, 0 May 5 1998 sga

Read on for more information.


Why would you need these values?
Loading the driver for a particular device is half the battle, the other half is having a "device node" which has correct values which will allow you to access that device. So a device driver without a correct device node doesn't do much good.

Gaining access:
Let's say you need to gain access to your Linux filesystem to make some repairs; however it's not booting, nor do you have a boot disk. Never fear, just boot up on the Linux installation media you have, load the driver like you did originally. Now switch over to the bash screen, create the necessary device nodes, and proceed to mount your Linux filesystems and make the necessary repairs to make it bootable again.

What do I do with a device node?
A device node consists of a name, a type (block, character, etc), and a major and minor number. Remember, you need to go through the device node in order to gain access to the particular device once you have the device driver loaded.

Device Node Name:
The name really doesn't matter; however, it's always best to use the correct name to prevent any confusion.

Device Node Type:
The type depends on the device you are using. Block devices are generally hard drives, cdrom's, etc. Character devices are generally terminal screens, tape drives, etc.

Device Node Major Number:
The major number basically represents which driver to call. The major and minor numbers can be compared to a standard computer Interrupt. Basically when you call on a particular major number, you get a response from the correct driver.

Device Node Minor Number:
The minor number represents which device you want in particular when speaking to a particular driver. For example when working with a SCSI bus, the minor number would determine which drive you wanted on the SCSI bus.

Here is an exampl of an entry from the /dev directory:
brw-rw---- 1 root disk 8, 0 May 5 1998 sda

This is for the first SCSI hard drive. "sd" stands for SCSI DISK, "a" represents the first SCSI disk - again, the name really doesn't determine anything. The "b" at the very beginning of the line states that this is a block device. The 8, 0 represents major number 8, and minor number 0. Major number 8 is the SCSI driver, minor number 0 represents the first SCSI device on the SCSI channel.

How do you create a device node?
If you know the type, major, and minor numbers, then you can create a device node. Lets say we want to create a device node for the Compaq array controller. That would be of type "block", it would have a major number of 72. If I wanted to specify the whole drive so that I can run fdisk on it, I would need the first entry which is the minor number 0. the name for this would be c0d0 which stands for controller 0 drive 0. Lets create this specific device node:

mkdir /test
cd /test
mknod /test/c0d0 b 72 0

This node is now referenced by calling upon /test/c0d0. If we wanted to get a partition listing on this from fdisk, we would type the following:
fdisk -l /test/c0d0

If I wanted access to any of the other partitions if I wanted to mount them or check them, I would need the other device nodes for those particular partitions I want access to. If the work you are putting forth is temporary (i.e. in a ramdisk), then you only need to create the specific device nodes for the specific partitions you need access to. If your results are going to be permanent then you should create device nodes for all the partitions.

The following is an example of creating device nodes for the 1st 2nd and 15th partitions for the Compaq array controller:
mknod /test/c0d0p1 b 72 1
mknod /test/c0d0p2 b 72 2
...
mknod /test/c0d0p15 b 72 15

Here is a script that will create device nodes for the Compaq Smart Array controller:
"/usr/src/linux/Documentation/mkdev.ida"



Change Log:
Last updated 03-23-2000 dev.html - Added a complete /dev, /dev/rd, /dev/ida listing for usage with the recovery document. Document created and released on http://www.cpqlinux.com.