(Not a duplicate of Understanding /dev and its subdirs and files)

I was browsing around my filesystem and for the first time I took a second to analyze my /dev directory. I was surprised by the amount of devices files in it, and couldn't make sense of all of them:

max@linux-vwzy:/dev> ls
adsp             disk      fd0u1760  initctl  mem                 root  sg0       tty    tty21  tty35  tty49  tty62    vboxdrv     vcsa2
audio            dri       fd0u1840  input    mixer               rtc   sg1       tty0   tty22  tty36  tty5   tty63    vboxnetctl  vcsa3
autofs           dsp       fd0u1920  kmem     mixer1              rtc0  sg2       tty1   tty23  tty37  tty50  tty7     vboxusb     vcsa4
block            dvd       fd0u360   kmsg     net                 scd0  sg3       tty10  tty24  tty38  tty51  tty8     vcs         vcsa5
bootsplash       dvdrw     fd0u720   log      network_latency     sda   sg4       tty11  tty25  tty39  tty52  tty9     vcs1        vcsa6
bsg              fb0       fd0u800   loop0    network_throughput  sda1  sg5       tty12  tty26  tty4   tty53  ttyS0    vcs10       vcsa7
btrfs-control    fd        fd0u820   loop1    null                sda2  sg6       tty13  tty27  tty40  tty54  ttyS1    vcs2        vga_arbiter
bus              fd0       fd0u830   loop2    nvram               sda3  sg7       tty14  tty28  tty41  tty55  ttyS2    vcs3        xconsole
cdrom            fd0u1040  full      loop3    oldmem              sdb   shm       tty15  tty29  tty42  tty56  ttyS3    vcs4        zero
cdrw             fd0u1120  fuse      loop4    port                sdc   snapshot  tty16  tty3   tty43  tty57  ttyS4    vcs5
char             fd0u1440  fw0       loop5    ppp                 sdc1  snd       tty17  tty30  tty44  tty58  ttyS5    vcs6
console          fd0u1600  hidraw0   loop6    psaux               sdd   sr0       tty18  tty31  tty45  tty59  ttyS6    vcs7
core             fd0u1680  hidraw1   loop7    ptmx                sde   stderr    tty19  tty32  tty46  tty6   ttyS7    vcsa
cpu              fd0u1722  hidraw2   mapper   pts                 sdf   stdin     tty2   tty33  tty47  tty60  uinput   vcsa1
cpu_dma_latency  fd0u1743  hpet      mcelog   random              sdg   stdout    tty20  tty34  tty48  tty61  urandom  vcsa10

I know that the sd*'s are my disks and filesystems, but what are loopx, fd0uxxxx, sgx, vcsxxx and all the other single files. Most of them are device files according to ls.

I understand that fully answering this question would require a ton of information, so unless someone can provide a link with a great rundown of the different devices files in dev and what they are all used for, I propose we make a CW answer.

  • I'm tempted to say: you don't want to know (not about all this). I suggest rewriting your question as: What are those devices in /dev I should know about? (Maybe you'll have answers for all of them anyway, maybe not…) – Stéphane Gimenez Aug 29 '11 at 21:27
  • 1
    I've changed the title, good call. However, if possible I would LOVE to know what they all did, or have a way of finding out (reading the device file? If that makes sense). – n0pe Aug 29 '11 at 21:31
  • I don't think it would be useful to list the devices one by one. Future visitors are likely to have a slightly different list. Read the documentations I've indicated in my answer, and if you still can't figure out some of them, ask a specific question. – Gilles Aug 29 '11 at 22:21

Some of these have man pages (in section 4; leave out the final digit(s) and in a few cases such as sda the final letter).

For a more definitive, but usually less easy to read answer, look in the kernel documentation. First determine whether the device is a block device or a character device, and its major and minor number. For example

$ ls -l /dev/sda
brw-rw---- 1 root disk 8, 0 Jul 12 15:54 /dev/sda

so sda is a block device (b) with major:minor = 8:0. Now look it up in devices.txt: 8 block is SCSI disk devices, which are most disks nowadays (most IDE and SATA disks are seen through the SCSI interface too, though this depends on kernel compilation options). Block device 8:1 (/dev/sda1) is the first partition of /dev/sda.

There may be a few oddball devices that aren't documented. You can look on your system at e.g. /sys/dev/block/8:0: this is a symbolic link to a directory under /sys that provides various pieces of information about the device. You can follow more links, and in particular (in this case) /sys/dev/block/8:0/device/driver lands you to a directory that corresponds with the driver. Another source of information is /proc/devices, which indicates what driver claims each major device number.

Most Linux systems use udev to populate /dev based on available drivers and hardware. You can browse the rules to create device files, typically in /lib/udev/rules.d and /etc/udev/rules.d (the exact locations are distribution-dependant).

A few of the files aren't devices. lsof /dev/NAME (as root) will tell you to what process is using them and thus give you a hint at what they are for. For the directories, look at the files in them.

This answer is specific to Linux, but other unices follow the same principles. Check the man pages (in section 4 on most variants, but a few use section 7), or other system or kernel documentation. The relevant information is the block/character bit and the major:minor numbers.

  • Wow amazing, you've detailed several points of interest that I'm currently reading. Thanks for this. – n0pe Aug 29 '11 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.