LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Creating device files is /dev (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/creating-device-files-is-dev-744376/)

zvivered 08-01-2009 11:39 AM

Creating device files is /dev
 
I want to build a root file system from scratch for an x86 embedded target.
What is the best way of creating the files in /dev (e.g tty0,console) ?
My target has one compact flash disk (hda ?) which is divided into 2 partitions.
Should I manually create hda, hda1, hda2 ?

Thanks.

GrapefruiTgirl 08-01-2009 12:19 PM

busybox mdev command
 
I started by Googling for populating /dev embedded and followed a couple links, and ended up at the busybox website (HERE). Based on my reading, it looks like busybox's mdev command is a popular method for creating the /dev nodes during boot of an embedded device. I haven't done this myself; I just did a bit of searching to try to help you out, so I don't know that this is the *best* way, but it's *one* way; my apologies if this is not what you're looking for ;)

from the busybox command help page:
Quote:

mdev
mdev [-s]

-s Scan /sys and populate /dev during system boot

Called with no options (via hotplug) it uses environment variables to determine which device to add/remove.

The mdev config file contains lines that look like:
hd[a-z][0-9]* 0:3 660

That's device name (with regex match), uid:gid, and permissions.

Optionally, that can be followed (on the same line) by a special character and a command line to run after creating/before deleting the corresponding device(s). The environment variable $MDEV indicates the active device node (which is useful if it's a regex match). For example:

hdc root:cdrom 660 *ln -s $MDEV cdrom

The special characters are @ (run after creating), $ (run before deleting), and * (run both after creating and before deleting). The commands run in the /dev directory, and use system() which calls /bin/sh.

Config file parsing stops on the first matching line. If no config entry is matched, devices are created with default 0:0 660. (Make the last line match .* to override this.)


All times are GMT -5. The time now is 01:07 PM.