Linux 2.6.26.5 embedded. I need manually mount the root file system from busybox shell (initramfs). Because this Linux kernel not use devtmpfs, I have to create the basic device nodes manually, use mknod (/dev/null
, /dev/zero
, dev/mtdblock
{0-10}, ttys
). I'm not sure about correct format for /dev/mtdblock
and ttys
. Should I create nodes for both /dev/mtdblock and /dev/mtd? The device creates 11 MTD partitions on nand0.
Where to find the major and minor numbers assigned for a devices?
The same question for ttys: what is correct mknod command for 5 /dev/tty
and 4 tty
– are they in different places?
mknod -m 666 tty c 4 0
mknod -m 666 /dev/tty c 5 0
Edit: partitions, devices and filesystems
# cat /proc/partitions
major minor #blocks name
31 0 384 mtdblock0
31 1 128 mtdblock1
31 2 20352 mtdblock2
31 3 7168 mtdblock3
31 4 18816 mtdblock4
31 5 2048 mtdblock5
31 6 1024 mtdblock6
31 7 512 mtdblock7
31 8 128 mtdblock8
31 9 512 mtdblock9
31 10 512 mtdblock10
# cat /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
7 vcs
10 misc
13 input
89 i2c
90 mtd
108 ppp
128 ptm
136 pts
153 spi
204 ttyJ
254 cordless
Block devices:
1 ramdisk
31 mtdblock
93 nftl
Best Answer
Device files are essentially a table in the kernel. A C array.
More exactly, a two-level tree structure of C arrays: the upper level for the major numbers and the lower for the minors.
Drivers (and the kernel core), can register driver handlers for them. A driver uses always a major number. For example, the software raid ("md") users the block major 9.
You can get the list of the currently registered block- and char devices in the
/proc/devices
files.The final answer is in the kernel source, there are "(un)register_block_device" or similar calls of the kernel core. Find them,
grep
for them, and so you can get a full list.