block-device-read-only · shipping · also Block-device read-only state

Linux block-device read-only flag

The Linux block-device read-only flag is a software-controlled device state exposed through block-device ioctls to restrict write access.

The util-linux v2.41.1 manual warns that changing the flag may leave existing active access unaffected, including a filesystem already in read-write use. [1] In Linux v7.3, BLKROSET and BLKROGET are ioctl numbers 93 and 94, and BLKROSET without CAP_SYS_ADMIN returns EACCES. [5] A device also counts as read-only when the whole-disk flag is set or the driver reports write protection. [6] A flag value alone is not evidence of a validated forensic write-blocking workflow; NIST publishes software write-blocker test resources, so software and unvalidated are not synonyms. [3]

Relations

related
Read-only mount, Btrfs read-only subvolume, dm-integrity recovery mode, Block device

Advantages

  • blockdev --getro prints 1 or 0, so the state can be checked from a shell without a custom ioctl program. [1]
  • A driver hook can refuse the change before the flag is set, so a device that cannot honor the request can reject it. [5]
  • Because the flag is kept per block device, one partition can be read-only while the whole disk stays writable. blockdev --report gives each partition start as StartSec in 512-byte sectors, which ties a read-only partition to its disk offset. [1, 6]

Limitations

  • Device state, filesystem state and subvolume properties have distinct scopes. [1, 2]
  • The flag is a kernel software state and does not by itself prove that the drive firmware rejects write commands. [5, 6]

Citations

  1. util-linux v2.41.1: blockdev(8), read-only flag and active-access caveat (accessed 2026-10-23)
  2. util-linux v2.41.1: mount(8), Read-only Setting Notes (accessed 2026-10-15)
  3. NIST CFTT: Software Write Block testing resources (accessed 2026-10-15)
  4. Linux v7.3 block/ioctl.c: BLKROSET permission check and read-only flag (accessed 2026-10-23)
  5. Linux v7.3 include/linux/blkdev.h: per-device and whole-disk read-only tests (accessed 2026-10-23)

Further reading

  1. Hesela: Btrfs tree logs and read-only scope boundaries (accessed 2026-10-15)
Sources & caveats
  • blockdev is the util-linux v2.41.1 blockdev(8) source at the cited tag, re-read for --setro, --getro, the active-access caveat and the 512-byte StartSec unit of --report.
  • linux-blk-ioctl is block/ioctl.c at v7.3, read for the CAP_SYS_ADMIN check, the driver hook and the flag update. The ioctl numbers were checked in include/uapi/linux/fs.h at v7.3.
  • linux-blkdev-h is include/linux/blkdev.h at v7.3, read for the combined per-device and whole-disk test. block/genhd.c at v7.3 was read for the sysfs ro attribute and driver write protection.
  • The btrfs-send-stream entry links here because send needs a read-only source subvolume, a scope distinct from this device-level state.

JSON: /data/terms/block-device-read-only.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. Linux block-device read-only flag. Hesela. 2026-11-15. https://hesela.dev/terms/block-device-read-only/