Help

Disk Device Information: df, lsblk, parted, fdisk

On virtual servers, disk names usually have the format vd* or xvd*, where the * character is replaced by a letter from a to z. The letter depends on the disk's number in the system.

The primary (first) disk always contains the operating system and is named vda or xvda. Additional disks can be added at any time and used for data storage.

To view information about disks and related details, you can use various commands such as df -h, lsblk, parted -l and fdisk -l.

df -h

The df -h command shows information only about mounted file systems, including those that are not disks.

The output shows the total size, used and available space, usage percentage and mount points.

df -h
Filesystem   Size  Used Avail Use% Mounted on
udev         210M     0  210M   0% /dev
tmpfs         51M  1.2M   50M   3% /run
/dev/xvda1      3.9G  1.2G  2.6G  32% /
tmpfs        255M     0  255M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs        255M     0  255M   0% /sys/fs/cgroup
/dev/xvdb1      4.8G   10M  4.6G   1% /mnt/disk2
tmpfs         51M     0   51M   0% /run/user/0

lsblk

The lsblk command shows information about disks and the partitions created on them, as well as their sizes and mount points.

lsblk
NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda    202:0    0    5G  0 disk
|-xvda1 202:1    0    4G  0 part /
|-xvda2 202:2    0    1K  0 part
`-xvda5 202:5    0 1022M  0 part [SWAP]
xvdb    202:16   0    5G  0 disk
`-xvdb1 202:17   0    5G  0 part /mnt/disk2

parted -l

The parted -l command provides information about disks and partitions, their sizes in a human-readable format, and their file systems. This tool is also useful for detecting mounted disk snapshots. In the following example, the snapshot appears as the /dev/xvdc disk and has the same structure as the /dev/xvda disk.

parted -l
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvda: 5369MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

  Number  Start   End  Size Type   File system  Flags
 1      1049kB  4295MB  4294MB  primary   ext4
 2      4296MB  5368MB  1072MB  extended
 2      4296MB  5368MB  1072MB  extended
 2      4296MB  5368MB  1072MB  extended

Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdb: 5369MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

 Number  Start   End  Size Type  File system  Flags
 1      1049kB  5369MB  5368MB  primary  ext4

Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdc: 5369MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End  Size Type   File system  Flags
 1      1049kB  4295MB  4294MB  primary   ext4
 2      4296MB  5368MB  1072MB  extended
 5      4296MB  5368MB  1072MB  logical   linux-swap(v1)

fdisk -l

The fdisk -l command is similar to parted -l, but provides more detailed information about partitions, including /dev/ram* disks, which can make the output harder to read. This command also lets you view disk and partition sizes.

fdisk -l
Disk /dev/xvda: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfb148422

Device  Boot   Start   End Sectors  Size Id Type
/dev/xvda1         2048  8388607 8386560    4G 83 Linux
/dev/xvda2      8390654 10483711 2093058 1022M  5 Extended
/dev/xvda5      8390656 10483711 2093056 1022M 82 Linux swap / Solaris

Disk /dev/xvdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6b14d070

Device  Boot Start   End  Sectors Size Id Type
/dev/xvdb1       2048 10485759 10483712   5G 83 Linux

Have more questions about Hosting?