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.
Partial answer:
how does Linux decide which video output will be used when creating a framebuffer device?
"Linux" doesn't, it's up to the driver. So the first step is to look into dmesg
and/or lsmod
and find out which driver gets loaded. Next step is to find the source code for the driver, read it and find out what options it understands. /dev/hdmi0
is a pretty unusual name for a framebuffer device, though it seems some sunxi-drivers use that. Did you try to write something into it (with dd
, or a small C program)? Does it behave like a framebuffer?
So edit the question with the relevant part of dmesg
, or edit it with a link to the complete dmesg
after boot in a pastebin etc.
how do I configure it to do what I want
See above: it completely depends on the driver. For example, the Intel framebuffer driver doesn't allow you to switch to HDMI (or didn't, the last time I looked).
Best Answer
ls -l /dev
will give you the major and minor numbers, e.g.has major number 4 and minor number 64.
Then you can look at
/proc/devices
to look up the major number. In this example we have a character device (c
at the start of the line) with major number4
, and in/proc/modules
we findAllocation of minor numbers is device-dependent.
Some devices are driven from core kernel code (e.g.
tty
), whereas others are managed by loadable modules (e.g.rfcomm
). You could try looking in/proc/modules
for a matching module; alternatively look in/proc/kallsyms
for the module name. You'll get lots of results, but the key thing to look for is the presence or absence of a string in square brackets. For example,grep tty /proc/kallsyms
giveswhereas
grep rfcomm /proc/kallsyms
gievs[rfcomm]
indicates that the code is in therfcomm
module, whereastty
is in the kernel itself and not in a module, so nothing appears in square brackets.This method is not definitive but should give you some idea as to where the controlling code lives.