#!/usr/bin/env sh # For modern systemd-based systems (e.g., Ubuntu 15.04+). # 1. Identify the device name for your root partition using lsblk or df -h (it might look like /dev/sda1 or /dev/nvme0n1p2). # 2. Set the maximum mount count to 1 using tune2fs. This tells the system to check the filesystem on the next boot: # sudo tune2fs -c 1 /dev/sdXX # 3. Reboot the system. # The system will perform the fsck on the root filesystem during boot. After the check completes, the system will boot normally. # 4. Once the system is back up, you may want to reset the mount count to its default (usually -1, which disables count-based checks): # sudo tune2fs -c -1 /dev/sdXX sudo tune2fs -c 1 /dev/sda5 #sudo tune2fs -c -1 /dev/sda5