Digital Forensic Tools
Home / Software write blocking / Linux write blocker

Linux write blocker

by Maxim Suhanov

Open sourceNot maintainedAdvancedCLILinux
Get it

Not maintained No code changes since May 2020; test it on your kernel before use. Based on the last code update recorded on 24 Nov 2026.

Released 21 Feb 2017. Choose the file for your system on the release page.

Files come directly from github.com/msuhanov/Linux-write-blocker. Digital Forensic Tools does not host or modify them.

What it is

Software write blocking on Linux means telling the kernel to treat an evidence drive as read-only before anything can write to it. The Linux Write Blocker project adds a kernel patch and helper scripts for this, and the standard blockdev command and read-only mount options cover simpler cases.

Use it when
  • You work on Linux and need to read an evidence drive without changing it, and a software method fits your lab policy.
  • You want to learn how write blocking works inside the Linux kernel.
  • You need to mount a file system from evidence for a quick look, with the lowest chance of writes.

What it can do

Kernel patch

  • Changes the block layer so that write and discard requests to a device marked read-only are stopped
  • Works for requests from any kernel driver, without changing each storage driver
  • Does not need loop devices, which cannot easily stand in for devices that file systems use directly

Helper scripts

  • 01wrtblk_all marks all block devices except loop devices as read-only
  • wrtblk marks a named device and its parent as read-only, and wrtblk-disable sets them back to read-write
  • wrtblk-ioerr marks a device and its children as read-only, for faulty drives

udev rule

  • 01-forensic-readonly.rules marks new block devices read-only when they appear
  • It uses wrtblk, and wrtblk-ioerr for faulty drives
  • The paths in it are fixed, so review and adjust them before use

Standard Linux methods

  • blockdev --setro marks a device read-only, and blockdev --getro shows 1 for read-only
  • mount -o ro mounts a file system read-only
  • ro,noload stops ext3 and ext4 from replaying the journal at mount

Evidence it opens

What you need. A Linux computer and root rights. To use the project's patch you must apply it to a kernel source and compile your own kernel. The project says it was written for Linux 3.15.1 and works on some newer versions, and a version for Linux 4.10 exists. The blockdev command and mount options need no patch and are part of standard Linux.

How to use it

  1. 1

    Read the project warnings

    Read the project's README before you start. It lists races, live system issues and bypass risks. Plan your method on paper and check your lab policy on software blockers.

  2. 2

    Stop automatic mounting

    Turn off automatic mounting and the automatic start of RAID, fake RAID and LVM volumes before you connect evidence. The project warns that the system may write to a drive before you mark it read-only. On live systems, protect all devices early in the boot.

  3. 3

    Set up the udev rule (optional)

    Local udev rules go in /etc/udev/rules.d and files must end in .rules. They are read in name order, so a name starting with 01 runs early. The project's 01-forensic-readonly.rules uses its helper scripts. Check the paths in it first.

  4. 4

    Mark the whole drive read-only

    Connect the drive, find its device name, and set the parent device read-only. Marking only a partition is not enough, says the project. The device name below is only an example.

    sudo blockdev --setro /dev/sdb
  5. 5

    Check the flag

    Ask the system for the read-only status of the device. It prints 1 when the device is read-only. The manual notes that a file system that is already mounted read-write is not affected until it is remounted.

    sudo blockdev --getro /dev/sdb
  6. 6

    Test with a known drive

    Before real evidence, test your setup with a spare drive. Hash it, try to write to it as a test, and hash it again. The hash must not change. Record the test in your lab notes and repeat it when the system or kernel changes.

  7. 7

    Image or mount read-only

    Make the image from the whole device with an imaging tool. If you must mount, add the read-only options. For ext3 and ext4 add noload, so the journal is not replayed. For ntfs-3g the project gives the ro option.

    sudo mount -o ro,noload /dev/sdb1 /mnt/evidence

Useful options

blockdev --setro /dev/sdXMarks a device read-only. Use the parent device, not only a partition.
blockdev --getro /dev/sdXPrints 1 if the device is read-only, 0 if not.
blockdev --setrw /dev/sdXMarks the device read-write again.
mount -o ro,noloadMounts read-only and, for ext3 and ext4, skips the journal replay that would write to the device.
wrtblk-ioerrProject helper that marks a device and its child devices read-only, for faulty drives.

Cases where it helps

Labs without a hardware blocker

Where policy allows it, a tested software method lets you read a drive on a Linux computer.

Forensic live systems

Setting every device read-only early in the boot lowers the risk that the live system writes to evidence.

Mounting a file system for a quick look

Read-only mount options with the device flag reduce the chance of writes such as journal replay.

Research and teaching

The project includes discussion and validation work in its research and validation folders, so students can see how a blocker is tested.

Strengths and limits

Strengths

  • Free and open source, with code you can read.
  • Blocks at the block layer, so it does not rely on each file system driver to respect read-only.
  • The project reports no loss of speed after applying the patch.
  • The same ideas work in many Linux forensic tools and live systems.

Limits to know

  • Software blocking must be tested on your own system before you trust it. A passing test on one computer or kernel does not prove another one is safe.
  • It is not a substitute for a hardware write blocker where your policy, standards or court practice require one.
  • The project warns that any software blocker can be bypassed by another program. The patch does not cover SCSI commands sent through the SG_IO interface, which includes some hdparm and sg3_utils commands.
  • A race is possible: the system may write to a drive before you mark it read-only. Disable automatic mounting first.
  • A read-only mount is not enough on its own. For example, ext3 and ext4 still replay the journal unless you add noload.
  • The kernel patch needs a custom kernel build. The project's udev rule and scripts have fixed paths you must check.
  • Creating a partition can re-trigger the udev rule and mark the disk read-only again, which can disturb partitioning work.

Works well with

Learn more

Written in our own words from the Linux Write Blocker project's README and the Linux manual pages. Last reviewed 24 Nov 2026.

More in Software write blocking

util-linux (blockdev)

by util-linux project
Open source

The standard Linux utility set. Its blockdev command can mark a block device read-only before it is mounted.

IntermediateCLILinux

CAINE

by Nanni Bassetti
Open source

A live Linux distribution for forensics with write-blocking by default and a large tool set.

BeginnerGUILinux

See all tools in Software write blocking