Guide

How to diagnose a Linux filesystem read-only

Reading-only editing can be a protective measure after a storage error or filesystem.

⌚ About 2 min read
View my favorites
Linux Advanced. 20 min

Reading-only editing can be a protective measure after a storage error or filesystem.

Avant de commencer : adaptez toujours les commandes et manipulations à votre environnement. Sur un système de production, prévoyez une backup ou un retour arrière lorsque l’action peut modifier la configuration.

Étapes à suivre

  1. 1

    Read dmesg

    Search for I/O error, ext4/xfs/vs.

  2. 2

    Identify Mount

    Note that and options.

  3. 3

    Check storage

    SMART/RAID depending on environment.

  4. 4

    Plan repair

    fsck often has to be done offline according to the filesystem.

Commands utiles

Mount
dmesg,UK -100
df -h

À retenir

  • Priority is given to backups if storage appears to be defective.
  • Do not force remount rw without understanding the, error.
Technical deep dive

Linux storage: distinguish blocks, inodes and deleted-but-open files

Technical checkpoints

  • df measures filesystem space while du measures visible files; a large gap can come from deleted files still held open.
  • df -i detects inode exhaustion, which can prevent file creation even with GBs free.
  • A filesystem remounted read-only may be kernel protection after I/O/filesystem errors; remounting rw without understanding the cause is risky.

Storage triage

Compare blocks, inodes, large directories and deleted files still open.

df -hT
df -i
du -xhd1 /var | sort -h
lsof +L1

Topic-specific pitfalls

  • Running rm under /var/lib or Docker without identifying data ownership can break services.
  • fsck should not be run on a filesystem mounted read-write except in specific documented cases.

How to validate

  • The cause of consumption or read-only transition is identified in logs/kernel.
  • After remediation, blocks and inodes have headroom and no new I/O errors appear.
♡ 0