{
  "slug": "read-only-mount",
  "term": "Read-only mount",
  "aliases": [
    "Linux read-only mount"
  ],
  "definition": "A read-only mount restricts filesystem modification through Linux mount state, whose scope can be a VFS mount node, the filesystem superblock, or both.",
  "note": "The util-linux v2.41.1 manual separates two layers: a requested ro setting applies to both layers by default for standard mounts, while -o bind,remount,ro changes only the mount node and can leave the filesystem writable through another path. [mount-scope] Btrfs may still replay its recovery log during a read-only mount. [replay] Ext4 journal replay and XFS internal log recovery can also write during read-only mounting; suppressing recovery does not establish a consistent recovered view. [ext4-replay] [xfs-replay] [xfs-options]\n\nSince util-linux 2.41, optional ro=vfs and ro=fs arguments select one layer. The v2.41.1 manual marks them experimental and requires the file-descriptor-based mount API. The old mount(2) interface silently ignores the optional argument. [mount-scope]\n\nIn the kernel, MS_RDONLY can be set per mount point as well as on the superblock since Linux 2.6.16, and a mount is writable only when neither flag is set. Since Linux 2.6.26, MS_REMOUNT combined with MS_BIND changes only the per-mount flags. [mount2]\n\nmount_setattr, added in Linux 5.12 with a glibc 2.36 wrapper, sets MOUNT_ATTR_RDONLY on a mount without changing superblock parameters. Its struct mount_attr has a first published size of 32 bytes, four 64-bit fields. [setattr]",
  "limitations": [
    {
      "text": "Read-only access through one path does not establish that the underlying device was unchanged.",
      "citationIds": [
        "mount-scope",
        "replay"
      ]
    },
    {
      "text": "The requested option spelling alone does not verify the effective layer; findmnt can report VFS-OPTIONS and FS-OPTIONS separately, but those flags are not an audit of device writes.",
      "citationIds": [
        "mount-scope"
      ]
    }
  ],
  "related": [
    "mount-point",
    "mount-namespace",
    "bind-mount",
    "btrfs-read-only-subvolume",
    "block-device-read-only",
    "btrfs-tree-log",
    "erofs",
    "squashfs",
    "ext4",
    "xfs",
    "mount-propagation"
  ],
  "citations": [
    {
      "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-23"
    },
    {
      "id": "replay",
      "title": "Btrfs documentation: tree-log replay and rescue options",
      "url": "https://btrfs.readthedocs.io/en/latest/btrfs-man5.html",
      "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": "mount2",
      "title": "Linux man-pages: mount(2), per-mount MS_RDONLY and bind remount",
      "url": "https://man7.org/linux/man-pages/man2/mount.2.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "setattr",
      "title": "Linux man-pages: mount_setattr(2), MOUNT_ATTR_RDONLY and AT_RECURSIVE",
      "url": "https://man7.org/linux/man-pages/man2/mount_setattr.2.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "ext4-replay",
      "title": "Linux v6.16: ext4 read-only mounts, journal replay and noload",
      "url": "https://docs.kernel.org/6.16/admin-guide/ext4.html",
      "accessed": "2026-10-24"
    },
    {
      "id": "xfs-replay",
      "title": "Linux v6.16: xfs_log_writable permits internal recovery writes on read-only mounts",
      "url": "https://github.com/torvalds/linux/blob/v6.16/fs/xfs/xfs_log.c#L317-L335",
      "accessed": "2026-10-24"
    },
    {
      "id": "xfs-options",
      "title": "xfsprogs xfs(5): norecovery requires read-only mounting and can expose inconsistencies",
      "url": "https://man7.org/linux/man-pages/man5/xfs.5.html",
      "accessed": "2026-10-24"
    }
  ],
  "status": "shipping",
  "advantages": [
    {
      "text": "With AT_RECURSIVE, one mount_setattr call changes the entire mount tree, which the classic mount(2) call cannot do; libmount exposes this as ro=recursive since util-linux 2.39.",
      "citationIds": [
        "setattr",
        "mount-scope"
      ]
    },
    {
      "text": "The change fails with EBUSY while the mount still holds files open for writing, so a successful switch leaves no writer open through that mount.",
      "citationIds": [
        "setattr"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-15",
  "provenance": [
    "mount-scope is the util-linux v2.41.1 mount(8) source at the cited tag, re-read for the Read-only Setting Notes and the ro, vfs, fs and recursive arguments.",
    "mount2 is the Linux man-pages 6.19 mount(2) page, read for the per-mount MS_RDONLY history in 2.6.16 and bind remount in 2.6.26.",
    "setattr is the mount_setattr(2) page, read for MOUNT_ATTR_RDONLY, AT_RECURSIVE, EBUSY and the 5.12 and glibc 2.36 history. The 32-byte size was checked in include/uapi/linux/mount.h at v7.3.",
    "The btrfs-tree-log entry links here because its log replay can still write during a read-only mount.",
    "Ext4 and XFS recovery boundaries checked against Linux v6.16 and xfsprogs documentation; source review only, no mount or device-write experiment."
  ]
}
