Introduction
When operating Linux servers, there are many situations where knowledge of device management becomes essential, such as adding storage, configuring mounts, and troubleshooting hardware issues. In this article, we will explain the Linux device management mechanism in a practical and easy-to-understand way for infrastructure engineers, using real command examples.
Linux Device Management
Before discussing Linux device management, let’s first understand how Linux handles hardware internally.
When a new device is added to a server, Linux performs the following steps internally:
- Detects the device
- Assigns the appropriate device driver
- Creates a device file
- Makes the device available from user space
This series of processes is called device management.
Device Drivers
To use hardware in Linux, a device driver is required. A device driver is software that acts as a bridge between the operating system and the hardware.
For example, when an application writes data to a disk, the application itself does not directly control the disk. Internally, the hardware is accessed through the Linux kernel and the device driver.
The process flow can be simplified as follows:
Application
↓
System Call
↓
Linux Kernel
↓
Device Driver
↓
Hardware
Examples of device drivers include:
| Device Type | Driver Example |
|---|---|
| SATA/SCSI Disk | sd |
| NVMe SSD | nvme |
| USB Devices | usb |
| Network Cards | e1000, ixgbe |
Device Files
In Linux, hardware such as disks, USB devices, and keyboards are handled as device files. Applications access devices through standard file operations such as open, read, and write.
Device files are created under the /dev directory. Examples include:
- Storage devices (
/dev/sda,/dev/nvme0n1) - Terminals (
/dev/tty,/dev/pts) - Special devices (
/dev/null,/dev/zero) - Virtual/logical devices (
/dev/mapper) - Serial/external I/O (
/dev/ttyUSB0)
Linux follows the philosophy of “Everything is a file”, meaning that even hardware devices are accessed through file interfaces.
By treating hardware as files, applications can use a common interface without needing to handle device-specific complexities.
Let’s look at major device files such as /dev/sda and /dev/tty.
[root@quiz ~]# ll /dev/
~~
brw-rw---- 1 root disk 8, 0 Dec 19 08:55 sda
brw-rw---- 1 root disk 8, 1 Dec 19 08:55 sda1
brw-rw---- 1 root disk 8, 2 Dec 19 08:55 sda2
brw-rw---- 1 root disk 8, 3 Dec 19 08:55 sda3
~~
crw-rw-rw- 1 root tty 5, 0 Mar 1 06:50 tty
crw--w---- 1 root tty 4, 0 Dec 19 08:55 tty0
crw--w---- 1 root tty 4, 1 Dec 19 08:55 tty1
crw--w---- 1 root tty 4, 10 Dec 19 08:55 tty10There are three important points to check:
First Character
The first character indicates whether the device is:b = block device
Block devices refer to storage devices such as HDDs, SSDs, and USB storage. They perform read/write operations in blocks (typically 512 bytes or 4 KB).c = character device
Character devices handle data as streams or character-by-character input/output, such as keyboards and terminals.
Device Name
Names such as sda or tty indicate the type of device.
Major / Minor Numbers
These numbers identify which device driver the kernel should use.
For example:
brw-rw---- 1 root disk 8, 0 Dec 19 08:55 sda- Major number:
8- Indicates the driver type
- Minor number:
0- Identifies the individual device
Linux performs disk I/O internally as follows:
- The kernel checks the device file
- The major number is identified
- The corresponding driver is called
- The minor number identifies the target device
- Read/write operations are executed
Examples of common major numbers are shown below.
Major Numbers for Block Devices
| Major Number | Device / Driver | Purpose |
|---|---|---|
| 1 | RAM disk (ramdisk) | Virtual disk in memory |
| 7 | Loop device (loop) | ISO mount, image files |
| 8 | SCSI disk (sd) | SATA / SAS / USB storage |
| 9 | MD (md) | Software RAID |
| 11 | SCSI CD-ROM (sr) | CD/DVD |
| 65–71 | Additional SCSI disks | Multi-disk expansion |
| 253 | Device Mapper (dm) | LVM, multipath, LUKS |
| 259 | blkext | NVMe and extended block devices |
Major Numbers for Character Devices
| Major Number | Device / Driver | Purpose |
|---|---|---|
| 1 | Memory devices | /dev/null, /dev/zero, /dev/random |
| 4 | TTY devices | Virtual terminals |
| 5 | Console / PTY | /dev/tty, /dev/console |
| 10 | Misc devices | Miscellaneous control devices |
| 13 | Input devices | Keyboard, mouse |
| 136–143 | Pseudo terminals | SSH sessions |
You can check currently used device major numbers in /proc/devices.
[root@localhost ~]# cat /proc/devices
Character devices:
1 mem
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
7 vcs
10 misc
~~ Truncated ~~
Block devices:
8 sd
9 md
65 sd
66 sd
67 sd
68 sdDevice Management with udev
Older Linux systems managed device files statically, but modern Linux systems use udev for dynamic device management. udev monitors device connection events and automatically generates device files under /dev. The following sequence occurs internally when a device file is created.
- Hardware Connection
Hardware such as USB memory devices or disks are connected. - Linux Kernel Detects the Device
The kernel detects the hardware, and logs such as the following appear indmesg:
usb 2-1: new high-speed USB device
sd 6:0:0:0: Attached SCSI removable disk - Device Information is Created in sysfs (/sys)
The Linux kernel registers the detected device information in a virtual filesystem called sysfs*.
* sysfs is a virtual filesystem that exports information about devices, drivers, and kernel objects from kernel space to user space. - uevent (Event Notification)
The Linux kernel notifies udev of device events through netlink, which is a communication interface between kernel space and user space. - udevd Receives the Event
The daemon process that actually runs udev,udevd(systemd-udevd), receives the event. - udev References sysfs
udev reads device information stored under the/sysdirectory. - udev Rules are Evaluated
udev evaluates rules that define how devices should be handled. - Device Files are Created Under /dev
For example:
/dev/sdb, /dev/sdb1 are created.
udev also configures permissions and symbolic links according to udev rules.

When hardware is disconnected, the Linux kernel detects the removal event, and udev removes the corresponding device files.
References:
sysfs – _The_ filesystem for exporting kernel objects — The Linux Kernel documentation
udev
Summary
In Linux, hardware does not become usable simply by being connected. Instead, the Linux kernel, device drivers, sysfs, and udev work together to make devices available to the system.
Internally, device management works as follows:
- The Linux kernel detects the device
- The appropriate device driver is assigned
- Device information is published to sysfs (
/sys) - uevents are sent to user space
- udev (
systemd-udevd) receives the event - udev references sysfs
- Device files are created under
/dev
Linux follows the philosophy of “Everything is a file”, where even hardware devices are treated as files.
Understanding device files, major numbers, and minor numbers is essential for understanding Linux internals.
I hope this article helps you better understand Linux device management.


コメント