Skip to main content

Filesystem Forced fsck all disks.

TheΒ script does:

  • Detects all ext4 filesystems (including LVM volumes)
  • Forces a one-time filesystem check at next boot using tune2fs -c 1
  • Ensures /etc/fstab stays exactly like it was, without changing anything
  • Reboots the system with fsck forced

βœ… Final Script β€” force_fsck_all.sh

#!/bin/bash

echo "πŸ” Detecting all ext4 filesystems..."
FILESYSTEMS=$(lsblk -pn -o FSTYPE,NAME | awk '$1 == "ext4" { print $2 }')

echo
echo "πŸ› οΈ  Forcing fsck on next boot for these filesystems:"
echo "$FILESYSTEMS"
echo

for FS in $FILESYSTEMS; do
    echo "β†’ Setting fsck trigger for $FS"
    tune2fs -c 1 "$FS"
done

echo
echo "βœ… Done. /etc/fstab was not modified."

echo
read -p "⚠️  Reboot now to run fsck on next boot? (y/N): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
    echo "πŸ” Rebooting with forced fsck..."
    shutdown -rF now
else
    echo "❌ Reboot skipped. Run 'shutdown -rF now' manually when ready."
fi

πŸš€ How to Use

  1. Create the script:
nano force_fsck_all.sh

Paste the script above. Save (Ctrl+O, Enter) and exit (Ctrl+X).

  1. Make it executable:
chmod +x force_fsck_all.sh
  1. Run it as root:
./force_fsck_all.sh

πŸ”’ Why /etc/fstab is not modified

This version:

  • Does not touch or modify /etc/fstab at all
  • Assumes that your current /etc/fstab is correctly set (which it is)

That way, nothing will break, and the root fs stays set to 1, exactly as Proxmox originally configured it.

Β