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".

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay