Build the/dev directory of the root file system

Source: Internet
Author: User
Tags mkdir

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.