Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

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
ColumnMeaning
NAMEDevice name under /dev
SIZESize of the disk or partition
RO1 means read-only
TYPEdisk, part, lvm, raid1
MOUNTPOINTSWhere 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

NameKind of diskPartitions
vdavirtio disk on a virtual servervda1, vda2
sdaSATA, SAS, or SCSI disksda1, sda2
nvme0n1NVMe drivenvme0n1p1
md0Software RAID arraymd0p1

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

lsblkdf
ShowsDevicesMounted file systems
Unmounted disksYesNo
Space usedOnly with -fYes

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.

Was this answer helpful?
Loading...