List Disks with lsblk
lsblk
lsblk reads the kernel's list of block devices and prints each disk with its partitions indented below it. It normally runs without root rights. A cloud server with one extra disk shows something similar to this:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
vda 253:0 0 40G 0 disk
├─vda1 253:1 0 39G 0 part /
└─vda2 253:2 0 1G 0 part /boot/efi
vdb 253:16 0 100G 0 disk
| Column | Meaning |
|---|---|
| NAME | Device name under /dev |
| SIZE | Size of the disk or partition |
| RO | 1 means read-only |
| TYPE | disk, part, lvm, raid1 |
| MOUNTPOINTS | Where it is mounted, if anywhere |
Show File Systems and UUIDs
lsblk -f
The columns are NAME, FSTYPE, FSVER, LABEL, UUID, FSAVAIL, FSUSE%, and MOUNTPOINTS. An empty FSTYPE means the device holds no file system yet. A value under MOUNTPOINTS means it is in use. Run lsblk -f before every change to a disk: it is the quickest way to make sure you have the right device.
Only the Disks, or Your Own Columns
lsblk -d -o NAME,SIZE,TYPE,MODEL
lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINTS
-d leaves out partitions, and -o picks the columns. On a virtual server the MODEL column is often empty.
Device Names: vda, sda, and nvme0n1
| Name | Kind of disk | Partitions |
|---|---|---|
vda | virtio disk on a virtual server | vda1, vda2 |
sda | SATA, SAS, or SCSI disk | sda1, sda2 |
nvme0n1 | NVMe drive | nvme0n1p1 |
md0 | Software RAID array | md0p1 |
The kernel hands out these names in the order it finds the disks, so they can change between boots or after adding a disk. For anything permanent, such as /etc/fstab, use the UUID instead.
More Detail with fdisk and blkid
sudo fdisk -l
sudo fdisk -l /dev/vdb
sudo blkid
fdisk -l prints each disk's exact size in bytes and sectors, the sector size, the partition table type (shown as gpt or dos), and every partition with its start and end sector. blkid prints the UUID and file system type of each partition. sudo parted -l gives a similar overview.
Stable Names under /dev/disk
ls -l /dev/disk/by-uuid/
ls -l /dev/disk/by-id/
These folders hold links named after the UUID or the drive's model and serial number, each pointing to the current device name. On a dedicated server, by-id tells you which physical drive is which.
lsblk vs df
| lsblk | df | |
|---|---|---|
| Shows | Devices | Mounted file systems |
| Unmounted disks | Yes | No |
| Space used | Only with -f | Yes |
After a disk upgrade, lsblk shows the larger disk while df still shows the old file system size, until you follow how to grow a partition after a disk upgrade. For space per folder, see how to check disk space in Linux.
A New Disk Does Not Appear
A virtio disk added to a running virtual server usually shows up at once. For SCSI disks, including sda disks on a virtio-scsi controller, ask the kernel to scan every SCSI host for new devices:
for h in /sys/class/scsi_host/host*; do echo '- - -' | sudo tee "$h/scan"; done
Then check the kernel log for the new device, as in the dmesg command. If it still does not appear, reboot the server. A disk that shows up but holds nothing needs a partition and a file system: see how to partition a disk and how to format a disk in Linux.