On Linux block devices represent an abstract interface to physical storage devices. User programs can use these block devices to interact with the storage device without worrying about whether the devices are SATA, SCSI, or something else. The program can simply address the storage on the device as a bunch of contiguous, randomly-accessible 4096-byte (4K) blocks.
SCSI and Serial ATA drives are both labeled under device handles such as: /dev/sda, /dev/sdb, /dev/sdc, etc. On more modern machines, PCI Express based NVMe solid state disks have device handles such as /dev/nvme0n1, /dev/nvme0n2, etc., while SD cards and MMCs have handles such as /dev/mmcblk0, /dev/mmcblk1, etc.
The following table will help to determine where to find a certain type of block device on the system:
|Type of device||Default device handle||Editorial notes and considerations|
|NVM Express (NVMe)||/dev/nvme0n1||The latest in solid state technology, NVMe drives are connected to the PCI Express bus and have the fastest transfer block speeds on the market. Systems from around 2014 and newer may have support for NVMe hardware.|
|SATA, SAS, SCSI, or USB flash||/dev/sda||Found on hardware from roughly 2007 until the present, this device handle is perhaps the most commonly used in Linux. These types of devices can be connected via the SATA bus, SCSI, USB bus as block storage.|
|MMC, eMMC, and SD||/dev/mmcblk0||embedded MMC devices, SD cards, and other types of memory cards can be useful for data storage. That said, some more traditional systems may not permit booting from these types of devices.|
|IDE/PATA||/dev/hda||Older Linux kernel drivers for IDE/Parallel ATA hardware displayed rotational block storage devices connected to the IDE bus starting at this location. Generally these types of devices has been phased out of personal computers since the year 2003, which is when the computer industry standard shifted to SATA. Most systems with one IDE controller could support four devices (hda-hdd). |
Alternative naming for these older interfaces include Extended IDE (EIDE) and Ultra ATA (UATA).
Although it is theoretically possible to use a raw, unpartitioned storage device to house a Linux system (when creating a btrfs RAID for example), this is almost never done in practice. Instead, block devices representing a physical device are split up into smaller, more manageable block devices. On most systems capable of running Linux, these are called partitions. The current standard partitioning technology is GPT, whereas older systems might still use MBR, sometimes also called DOS disklabel).
The GPT (GUID Partition Table) setup uses 64-bit identifiers for the partitions, which means there is practically no limit on the amount of partitions for a GPT disk. Also the size of a partition is bounded only by a quite big limit (almost 8 ZiB - yes, zebibytes).
GPT also takes advantage of checksumming and redundancy. It carries CRC32 checksums to detect errors in the header and partition tables and has a backup GPT at the end of the disk. This backup table can be used to recover damage of the primary GPT near the beginning of the disk.
The MBR (Master boot record) boot sector was first introduced in 1983 with PC DOS 2.x. MBR uses 32-bit identifiers for the start sector and length of the partitions, and supports three partition types: primary, extended, and logical. Primary partitions have their information stored in the master boot record itself - a very small (usually 512 bytes) location at the very beginning of a disk. Due to this small space, only four primary partitions are supported (for instance, /dev/sda1 to /dev/sda4).
In order to support more partitions, one of the primary partitions in the MBR can be marked as an extended partition. This partition can then contain additional logical partitions (partitions within a partition).
Although still supported by some manufacturers, MBR boot sectors and their associated partitioning limitations are considered legacy. Usually, it is best to partition a disk with GPT. Readers who must proceed with MBR setup type should knowingly acknowledge the following information:
- Using MBR boot sectors is considered a legacy (often unsupported and not ideal) boot mode.
- Due to using 32-bit identifiers, partition tables in the MBR cannot address storage space that is larger than 2 TiBs in size.
- Unless a extended partition is created, MBR supports a maximum of four partitions.
- This setup does not provide a backup boot sector, so if something overwrites the partition table, all partition information will be lost.
It is suggested to use GPT whenever possible for Gentoo installations.
Also, Linux allows to free the abstract interface to storage devices from its limitation to directly addressable (singular) physical devices. With the kernel's device mapper framework it is possible to have virtual block devices that are mapped to one or more physical devices. Those virtual devices can be addressed like regular block devices, the kernel takes care of relaying the data to the underlying hardware. The corresponding device handles are addressable under /dev/mapper/ and can be arbitrarily labeled, for example /dev/mapper/volume1, /dev/mapper/main_crypt, etc.
Utilizing the device mapper framework, it is, for example, possible to create a virtual device that receives data like a regular block device and forwards it in encrypted form to the real hardware (and vice versa) and thus transparently encrypts the data.
LUKS, the Linux Unified Key Setup, is used on top of the device mapper framework's crypt target (dm-crypt) to facilitate dealing with data encryption. To that end the cryptsetup application, which is the reference implementation of LUKS, offers a simple way of managing encrypted storage devices and associated passphrases and keys. As nowadays encrypting storage devices is widely regarded best practice to protect user data (for instance in case of theft) it is recommended to consider using LUKS for the installation.