Device file - ArchWiki
Device file - ArchWiki
org/title/Device_file#Block_devices
Device file
(Redirected from Block device)
From Wikipedia: Related articles
In Unix-like operating systems, a device file or special file is an interface to a device driver that Persistent block device
appears in a file system as if it were an ordinary file. naming
On Linux they are in the /dev directory, according to the Filesystem Hierarchy Standard.
1 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.
Warning: Kernel name descriptors for block devices are not persistent and can change each boot, they should not be used in
configuration files.
1.1.1 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:
1.1.2 NVMe
The name of storage devices, like SSDs, that are attached via NVM Express (NVMe) starts with nvme . It is then followed by a
number starting from 0 for the device controller, nvme0 for the first discovered NVMe controller, nvme1 for the second, and so
on. Next is the letter "n" and a number starting from 1 expressing the namespace on a controller, i.e. nvme0n1 for first discovered
namespace on first discovered controller, nvme0n2 for second discovered namespace on first discovered controller, and so on.
Note: The kernel's assigned namespace number is not guaranteed to match the NVMe namespace ID (NSID).
Examples:
▪ /dev/nvme0n1 - device 1 on controller 0 , the first discovered device on the first discovered controller.
▪ /dev/nvme2n5 - device 5 on controller 2 , the fifth discovered device on the third discovered controller.
1.1.3 MMC
SD cards, MMC cards and eMMC storage devices are handled by the kernel's mmc driver and name of those devices start with
mmcblk . It is then followed by a number starting from 0 for the device, i.e. mmcblk0 for first discovered device, mmcblk1 for
second discovered device and so on.
Note: If an SD/MMC card reader uses the USB interface, the block devices will be handled by the SCSI driver subsystem and
follow its naming scheme.
Examples:
1 of 3 2/13/25, 2:57 PM
Device file - ArchWiki https://wiki.archlinux.org/title/Device_file#Block_devices
with sr . The name is then followed by a number starting from 0 for the device, ie. sr0 for the first discovered device, sr1 for
the second discovered device, and so on.
Udev also provides /dev/cdrom that is a symbolic link to /dev/sr0 . The name will always be cdrom regardless of the drive's
supported disc types or the inserted media.
Examples:
▪ /dev/sr0 - optical disc drive 0 , the first discovered optical disc drive.
▪ /dev/sr4 - optical disc drive 4 , the fifth discovered optical disc drive.
▪ /dev/cdrom - a symbolic link to /dev/sr0 .
1.1.5 virtio-blk
The name of drives attached to a virtio block device (virtio-blk) interface start with vd . It is then followed by a lower-case letter
starting from a for the first discovered device ( vda ), b for the second discovered device ( vdb ), and so on.
Note: Do no confuse virtio-blk with virtio-scsi which emulates a SCSI controller and thus follows the SCSI naming convention.
Examples:
1.1.6 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. /dev/driveppartition .
Examples:
1.2 Utilities
1.2.1 lsblk
The util-linux (https://archlinux.org/packages/?name=util-linux) package provides the lsblk(8) (https://man.a
rchlinux.org/man/lsblk.8) utility which lists block devices, for example:
$ lsblk --fs
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.
You can use the -o / --output option to enable a specific list of output columns:
NAME PTTYPE PARTLABEL FSTYPE FSVER LABEL FSSIZE FSAVAIL FSUSE% MOUNTPOINTS
sda gpt
└─sda1 gpt cryptdata1 crypto_LUKS 2
└─data1 btrfs data1 7.3T 2.3T 68% /mnt/data
sdb gpt
└─sdb1 gpt cryptdata2 crypto_LUKS 2
└─data2 btrfs data1
sdc gpt
└─sdc1 gpt cappdata crypto_LUKS 2
└─appdata ext4 1.0 appdata 3.6T 3.4T 0% /mnt/appdata
sdd gpt
└─sdd1 gpt cappdata_backup crypto_LUKS 2
└─appdata_back ext4 1.0 appdata_backup
nvme1n1 gpt
├─nvme1n1p1 gpt BACKUP_EFI vfat FAT32 EFI 4G 3.9G 2% /boot
├─nvme1n1p2 gpt backup_swap
├─nvme1n1p3 gpt csys1 crypto_LUKS 2
2 of 3 2/13/25, 2:57 PM
Device file - ArchWiki https://wiki.archlinux.org/title/Device_file#Block_devices
The above is based on the options provided by the -f / --fs argument with removal of UUID and addition of partition label and
disk size, which are useful when identifying multiple disks. See lsblk --help for a full list of supported columns.
1.2.2 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 libblkid(3) (https://man.archlinux.org/man/libblkid.3). It does not erase the file systems
themselves nor any other data from the device.
For example, to erase all signatures from the device /dev/sdb and create a signature backup ~/wipefs-sdb-offset.bak file
for each signature:
2 Pseudo-devices
Device nodes that do not have a physical device.
3 See also
▪ Linux allocated devices — The Linux Kernel documentation (https://docs.kernel.org/admin-guide/devices.html)
▪ Gentoo:Device file
3 of 3 2/13/25, 2:57 PM