Device file
On Linux they are in the /dev
directory, according to the Filesystem Hierarchy Standard.
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 Arch Linux the device nodes are managed by udev.
Block devices
A block device is a special file that provides buffered access to a hardware device. For a detailed description and comparison of virtual file system devices, see Wikipedia:Device file#Block devices.
Block device names
The beginning of the device name specifies the kernel's used driver subsystem to operate the block device.
SCSI
Storage devices, like hard disks, SSDs and flash drives, that support the SCSI command (SCSI, SAS, UASP), ATA (PATA, SATA) or USB mass storage connection are handled by the kernel's SCSI driver subsystem. They all share the same naming scheme.
The name of these devices starts with sd
. It is then followed by a lower-case letter starting from a
for the first discovered device (sda
), b
for the second discovered device (sdb
), and so on.
Examples:
- - device
a
, the first discovered device. - - device , the fifth discovered device.
NVMe
The name of storage devices, like SSDs, that are attached via NVM Express (NVMe) starts with . It is then followed by a number starting from 0
for the device controller, nvme0
for the first discovered NVMe controller, for the second, and so on. Next is the letter "n" and a number starting from expressing the device on a controller, i.e. for first discovered device on first discovered controller, for second discovered device on first discovered controller, and so on.
Examples:
- - device on controller
0
, the first discovered device on the first discovered controller. - - device on controller , the fifth discovered device on the third discovered controller.
MMC
SD cards, MMC cards and eMMC storage devices are handled by the kernel's mmc
driver and name of those devices start with . It is then followed by a number starting from 0
for the device, i.e. for first discovered device, for second discovered device and so on.
Examples:
- - device
0
, the first discovered device. - - device , the fifth discovered device.
SCSI optical disc drive
The name of optical disc drives (ODDs), that are attached using one of the interfaces supported by the SCSI driver subsystem, start with . The name is then followed by a number starting from 0
for the device, ie. for the first discovered device, for the second discovered device, and so on.
Udev also provides /dev/cdrom
that is a symbolic link to . The name will always be regardless of the drive's supported disc types or the inserted media.
Examples:
- - optical disc drive
0
, the first discovered optical disc drive. /dev/sr4
- optical disc drive , the fifth discovered optical disc drive./dev/cdrom
- a symbolic link to .
virtio-blk
The name of drives attached to a virtio block device (virtio-blk) interface start with . It is then followed by a lower-case letter starting from a
for the first discovered device (), b
for the second discovered device (), and so on.
Examples:
- - device
a
, the first discovered device. - - device , the fifth discovered device.
Partition
Partition device names are a combination of the drive's device name and the partition number assigned to them in the partition table, i.e. /dev/drivepartition
. For drives whose device name ends with a number, the drive name and partition number is separated with the letter "p", i.e. .
Examples:
- - partition on .
- - partition
3
on . - - partition on .
- - partition on .
- - partition on .
lsblk
The package provides the lsblk(8) utility which lists block devices, for example:
In the example above, only one device is available (sda
), and that device has three partitions ( to ), each with a different file system.
wipefs
wipefs can list or erase file system, RAID or partition-table signatures (magic strings) from the specified device to make the signatures invisible for . It does not erase the file systems themselves nor any other data from the device.
See for more information.
For example, to erase all signatures from the device 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
- /dev/shm
- /dev/null, /dev/zero, see null(4)
- /dev/full, see
- /dev/ttyX, where X is a number