[Sderby] What does dev mean (/dev/hda1) ?

David Jolley djolley at gmail.com
Sun Oct 31 18:49:21 GMT 2004


/dev in it's simplest sense is a plain, honest to goodness directory.

However, by convention (and now with kernel 2.[4|6]'s devfs it's
becoming legacy) it's used as storage for the device nodes.
A device node is a special type of file which is either block or char
type (see man mknod) and has major and minor numbers associated with
it.  The major and minor numbers are an interface into the kernel for
sending requests to the device associated with that major number.
The major numbers are an offset into a structure in the kernel, which
the kernel uses to map to a device driver.  So, device number 22 (for
instance) is *always* (on any system) the second IDE disk controller
in the system.  The minor number is used to communicate to this device
driver the particular device on that driver.  So, for major 22, minor
== 0 is the first (master) hard disk, and minor == 64 is the second
(slave).  A list of numbers can be found on the web somewhere (I'm
sure; but I haven't looked for a while, I use the shell script
MAKEDEV, which is in the /dev directory on a debian machine, as a
reference).
Your /dev/null is major number 1 and minor number 3.

ls -l /dev will show all the devices your distro created for you.  My
debian machine lists 1399, and my Suse box lists 3917, so there is
variance between systems.  The names in the directory are named by
convention, so that all sorts of different programs can find the
device they may want to interact with.

Note that the name is completely arbitrary, it is only the device
major and minor that the kernel pays any attention to.  You could, for
instance have another node in your /dev directory (or even in your
home directory - position in the FS is by convention only) called
secondary_IDE_master_disk with major 22 and minor 0, and it would work
as /dev/hdc does.

devfs is something new that hasn't "caught on" yet, and is different
to the /dev directory in that only devices that are loaded in the
system are present in the devfs listing (the filesystem is generated
by the kernel, rather than having a bunch of inodes permanently
allocated on disk).  But, AIUI, the major and minor numbers still
hold.

On Fri, 29 Oct 2004 17:32:23 +0100, Russ <russhallam at ntlworld.com> wrote:
>  
> hi all, 
>   
> Just a simple daft question, as a total low level new comer to cmd line
> stuff sort of bloke, what does "/dev" mean and do when in a line like this -
> "mount /dev/hda1/ mnt" ? 
>   
> From looking on the net i found this /dev/null - a virtual device, is that
> what /dev is. 
>   
> Thanks Russ.



More information about the Sderby mailing list