{
  "slug": "block-device-read-only",
  "term": "Linux block-device read-only flag",
  "aliases": [
    "Block-device read-only state"
  ],
  "definition": "The Linux block-device read-only flag is a software-controlled device state exposed through block-device ioctls to restrict write access.",
  "note": "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. [blockdev] In Linux v7.3, BLKROSET and BLKROGET are ioctl numbers 93 and 94, and BLKROSET without CAP_SYS_ADMIN returns EACCES. [linux-blk-ioctl] A device also counts as read-only when the whole-disk flag is set or the driver reports write protection. [linux-blkdev-h] 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. [write-block-testing]",
  "limitations": [
    {
      "text": "Device state, filesystem state and subvolume properties have distinct scopes.",
      "citationIds": [
        "blockdev",
        "mount-scope"
      ]
    },
    {
      "text": "The flag is a kernel software state and does not by itself prove that the drive firmware rejects write commands.",
      "citationIds": [
        "linux-blk-ioctl",
        "linux-blkdev-h"
      ]
    }
  ],
  "related": [
    "read-only-mount",
    "btrfs-read-only-subvolume",
    "dm-integrity-recovery-mode",
    "block-device"
  ],
  "citations": [
    {
      "id": "blockdev",
      "title": "util-linux v2.41.1: blockdev(8), read-only flag and active-access caveat",
      "url": "https://kernel.googlesource.com/pub/scm/utils/util-linux/util-linux/+/refs/tags/v2.41.1/disk-utils/blockdev.8.adoc",
      "accessed": "2026-10-23"
    },
    {
      "id": "mount-scope",
      "title": "util-linux v2.41.1: mount(8), Read-only Setting Notes",
      "url": "https://kernel.googlesource.com/pub/scm/utils/util-linux/util-linux/+/refs/tags/v2.41.1/sys-utils/mount.8.adoc",
      "accessed": "2026-10-15"
    },
    {
      "id": "write-block-testing",
      "title": "NIST CFTT: Software Write Block testing resources",
      "url": "https://www.nist.gov/itl/csd/secure-systems-and-applications/computer-forensics-tool-testing-program-cftt/cftt-9",
      "accessed": "2026-10-15"
    },
    {
      "id": "hesela",
      "title": "Hesela: Btrfs tree logs and read-only scope boundaries",
      "url": "https://hesela.com/analyses/btrfs-tree-log-read-only-replay/#read-only-scopes",
      "accessed": "2026-10-15"
    },
    {
      "id": "linux-blk-ioctl",
      "title": "Linux v7.3 block/ioctl.c: BLKROSET permission check and read-only flag",
      "url": "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/block/ioctl.c?h=v7.3",
      "accessed": "2026-10-23"
    },
    {
      "id": "linux-blkdev-h",
      "title": "Linux v7.3 include/linux/blkdev.h: per-device and whole-disk read-only tests",
      "url": "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blkdev.h?h=v7.3",
      "accessed": "2026-10-23"
    }
  ],
  "status": "shipping",
  "advantages": [
    {
      "text": "blockdev --getro prints 1 or 0, so the state can be checked from a shell without a custom ioctl program.",
      "citationIds": [
        "blockdev"
      ]
    },
    {
      "text": "A driver hook can refuse the change before the flag is set, so a device that cannot honor the request can reject it.",
      "citationIds": [
        "linux-blk-ioctl"
      ]
    },
    {
      "text": "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.",
      "citationIds": [
        "blockdev",
        "linux-blkdev-h"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-15",
  "provenance": [
    "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."
  ]
}
