Enhancing Skills

fsck: Disk usage and file integrity

fsck: File System Consistency Check and Repair

Description: Checks and repairs inconsistencies in file systems. Running fsck is essential for maintaining file system integrity, especially after improper shutdowns or if there are disk errors.

  • Basic Usage:
  sudo fsck /dev/sdX

Replace /dev/sdX with the specific device or partition you want to check.

  • Common Arguments:
  • -A: Check all file systems listed in /etc/fstab.
  • -C <fd>: Print progress information to the specified file descriptor.
  • -f: Force checking even if the file system seems clean.
  • -n: No changes will be made, useful for a read-only check.
  • -p: Automatically repair the file system without user intervention.
  • -y: Assume “yes” to all questions, making automatic repairs.
  • Sample Command and Output: Command:
  sudo fsck -f /dev/sda1

Output:

  fsck from util-linux 2.31.1
  e2fsck 1.44.1 (24-Mar-2019)
  /dev/sda1: recovering journal
  /dev/sda1: clean, 123456/7890123 files, 1234567/9876543 blocks

Using fsck with appropriate options helps ensure that your file system is free from errors and is functioning correctly.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.