In embedded arm development, when making the root file system with BusyBox, one of the directories that must be built is the/dev directory. This directory is important to all users because the directory contains all the external devices used in all Linux systems, that is, all the device nodes.
When building the/dev directory, there are two approaches: static build and Mdev Device management tool building.
1. Static Construction:
The static method is used to build a variety of device nodes using the Mknod command, which is based on the prior knowledge of the drive to be mounted.
New/dev Directory, first create 5 device files (required):
Mkdir-p Root_fs/dev CD Root_fs/dev sudo mknod console C 5 1 sudo mknod null C 1 3 sudo mknod ttySAC0 C 204 64 sudo mknod mtdblock0 b 31 0 sudo mknod mtdblock1 b 31 1 sudo mknod Mtdblock2 b 31 2 |
Other device files: When the system starts, use the cat/proc/devices command to view the devices registered in the kernel, and then create the appropriate device files.
Disadvantages of using the static create dev directory: Hot-swappable devices are not supported
2. Mdev Dynamic creation:
Mdev is a simplified version of Udev that dynamically creates device files or device nodes by reading kernel-appropriate information. Its main uses are: initialization of the dev directory, dynamic update, support hot-swappable. To use the MDEV device management system, you need the kernel to support the Sysfs file system, to reduce flash read and write, but also to support the Tmpfs file system (in fact, the current dev directory is the Tmpfs file system directory). In general, the default kernel configuration already meets the requirements for using Mdev.
Modify the Etc/init.d/rcs file, as follows:
#!/bin/sh echo "Mount Pseudo filesystem ..." Mount-t tmpfs-o size=64k,mode=0755 tmpfs/dev/dev directory for Tmpfs file system directory Mkdir/dev/pts Mount-t devpts devpts/dev/pts Mount-t Sysfs Sysfs/sys Echo/sbin/mdev >/proc/sys/kernel/hotplug//Support hot swappable Mdev-s |
The statements are almost the same as those used by Mdev. Refer to the Busybox/doc/mdev.txt documentation.
In addition, Mdev is launched through the INIT process, and the INIT process uses at least/dev/console and/dev/null before using Mdev to construct the/dev directory, so build them first as you would with static methods. Execute under the/dev/
sudo mknod console c 5 1
sudo mknod null C 1 3
The proc mnt tmp sys root, and so on, builds an empty directory by the original method.
In this way, the device files with the dev directory of the file system are automatically generated when the system is started.