Linux 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
  • 2
    I'm voting to keep this question open as questions about official documentation are explicitly on-topic. Dec 4, 2017 at 12:36
  • mknod /dev/mtdblock0 b 31 0 will create the mtdblock0 for you. Tricky question: what do you think, what could mean the "major" and "minor" columns in /proc/partitions? :-)
    – peterh
    Dec 5, 2017 at 21:20
  • @peterh yes, I know that the "major" and "minor" numbers is specified in columns in /proc/partitions. What's not clear: I have 11 partitions, but I want access only root (mtd4), so would be the mtd4/mtdblock4 device node pair sufficient here? Or I have to create all device nodes mtdx and mtdblockx for each partition?(even if I want accees only root)
    – Lexx Luxx
    Dec 6, 2017 at 14:04
  • @triwo Then ask this in a new question. You've got your answer for your problem, now you can have your next question.
    – peterh
    Dec 6, 2017 at 14:06

2 Answers 2


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.

  • Should be created nodes for both mtdblockX and mtdX devices? Also, not clear about TTY devices.
    – Lexx Luxx
    Dec 4, 2017 at 13:00
  • @triwo tty is only a character device, in its functionality is it essentially a socket, extended with some terminal-controlling ioctl()-s. There is a "tty driver" in the kernel, it registers the ttys with a register_char_device(4) (or similar, check the source) call. From that point, the open/close/read/write/ioctl and similar calls to character device files with major number 4 will be implemented by the tty driver. The tty driver handles the character console of the Linux kernel. There is also a pts driver, its major number is 136, it is mainly for the daemons, like sshd.
    – peterh
    Dec 4, 2017 at 13:08
  • @triwo From the ttys I wrote more here. | mtd & mtdblock: I don't know the details. But: It is quite possible that a driver registers multiple block major numbers. Typically they mean different functionality: for example, in kernels until ca. 2.2, /dev/sr0 (block major 11) meaned an scsi cdrom, while /dev/sg0(block major 21) was a generic scsi device. The scsi cdrom driver used both. I think some similar could happen also in the mtd / mtdblock line.
    – peterh
    Dec 4, 2017 at 13:14
  • @triwo The kernel core doesn't know anything about the path/filename of the device files, it see only block/char and major/minor numbers. The device files below /dev are normally created by the userspace tool named udev, but from the view of the kernel, it is not a requirement. The kernel can see a table of major numbers and that which driver belongs to them.
    – peterh
    Dec 4, 2017 at 13:19
  • I added mtd & mtdblock commands to the topic. Which version for mtd chars should I use?
    – Lexx Luxx
    Dec 5, 2017 at 11:12

From devices.txt in the kernel documentation.

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.