Device file - ArchWiki

# Device file

From ArchWiki

From Wikipedia:

  In Unix-like operating systems, a device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file.

On Linux they are in the `/dev` directory, according to the Filesystem Hierarchy Standard.

On Arch Linux the device nodes are managed by udev.

## Block devices

This article or section needs expansion.

Reason: `mmcblk` and `nvme` block devices and their partitions have a slightly different format than scsi's `/dev/sda1`. Explain those formats. (Discuss in Talk:Device file#)

Block devices provide buffered access to hardware devices and allow reading and writing blocks of any size and alignment.

The beginning of the device name specifies the type of block device. Most modern storage devices (e.g. hard disks, SSDs and USB flash drives) are recognised as SCSI disks (`sd`). The type is followed by a lower-case letter starting from `a` for the first device (`sda`), `b` for the second device (`sdb`), and so on. Existing partitions on each device will be listed with a number starting from `1` for the first partition (`sda1`), `2` for the second (`sda2`), and so on. Other common block device types include for example `mmcblk` for memory cards and `nvme` for NVMe devices.

See also Persistent block device naming.

### lsblk

The util-linux package provides the lsblk(8) utility which lists block devices, for example:

    $ lsblk -f

    NAME   FSTYPE   LABEL       UUID                                 MOUNTPOINT
    sda
    ├─sda1 vfat                 C4DA-2C4D                            /boot
    ├─sda2 swap                 5b1564b2-2e2c-452c-bcfa-d1f572ae99f2 [SWAP]
    └─sda3 ext4                 56adc99b-a61e-46af-aab7-a6d07e504652 /

In the example above, only one device is available (`sda`), and that device has three partitions (`sda1` to `sda3`), each with a different file system.

### wipefs

This article or section needs expansion.

Reason: Why would you want to make signatures invisible for libblkid? (Discuss in Talk:Device file#)

wipefs can list or erase file system, RAID or partition-table signatures (magic strings) from the specified device to make the signatures invisible for libblkid(3). It does not erase the file systems themselves nor any other data from the device.

See wipefs(8) for more information.

For example, to erase all signatures from the device `/dev/sdb` and create a signature backup `~/wipefs-sdb-offset.bak` file for each signature:

    # wipefs --all --backup /dev/sdb

## Pseudo-devices

Device nodes that do not have a physical device.

- /dev/random, see random(4)
- /dev/shm
- /dev/null, /dev/zero, see null(4)
- /dev/full, see full(4)
- /dev/ttyX, where X is a number

## See also

- Linux allocated devices — The Linux Kernel documentation
- Gentoo:Device file

Category:

- System administration

Hidden category:

- Pages or sections flagged with Template:Expansion