DEV Community

Frits Hoogland for YugabyteDB

Posted on

Lookup disk properties on linux

When using linux systems, there sometimes is a need to understand the exact disk properties. One reason is to be able to understand IO read and write size, and how it affects latency.

Linux uses buffered IO by default. That means that any read or write request will use the cache. The cache in linux is completely automatic, essentially consisting of non-allocated memory. However, in most cases buffered IO will also require memory when there is memory shortage.

To understand which block device a filesystem is using, use the lsblk command:

$ lsblk
NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                  8:0    0 39.1G  0 disk
├─sda1               8:1    0    1G  0 part /boot
└─sda2               8:2    0 38.1G  0 part
  ├─almalinux-root 253:0    0   36G  0 lvm  /
  └─almalinux-swap 253:1    0  2.1G  0 lvm  [SWAP]
Enter fullscreen mode Exit fullscreen mode

In this case the lsblk command tells me I got one disk (sda), with two partitions (sda1 and sda2). The disk here therefore is sda.

The disk exposes a lot of its properties via /sys/block/<DISK>/queue, such as:

  • The disk maximum IO size: max_hw_sectors_kb (readonly).
  • The disk current maximum IO size: max_sectors_kb (read-write).
  • The disk IO queue size: nr_requests (read-write).
  • The disk read-ahead size: read_ahead_kb (read-write).
  • The scheduler for the disk: scheduler (read-write).
  • Is the disk (set as/considered) to be on a rotating disk: `rotational' (readonly).
  • Is the disk (set as/considered) to be on dax (writeable persistent memory): dax (readonly).

Read-write and readonly:

  • 'read-write' means it's a setting that can be manipulated.
  • 'readonly' means it's a property read by the driver from the underlying "hardware".

Top comments (0)