104.2 Maintain integrity of Filesystem

  • Verify the integrity of the filesystems
  • Verify free space and inodes
  • Repair simple filesystem problems

Commands: du, df , fsck, e2fsck, mke2fs , debugfs, dumpe2fs, tune2fs, xfs_metadump, xfs_info

Filesystems may become corrupted due to misuse, power loss, or other issues.

The ‘fsck’ utility is primary usest to check and repair filesystem integrity.

  • Separate fsck commands exist for each filesystem type
  • Xfs_repair
  • May be run at boot, depending on configuration in /etc/fstab
  • Filesystems usually are unmounted
    • Fsck -y /dev/sdc1
    • Fsck -A
  • The ‘tune2fs’ utility is used to adjust ext filesystems
    • Tune2fs -l /dev/sdb1

-p                   Automatic repair (no questions)

 -n                   Make no changes to the filesystem

 -y                   Assume “yes” to all questions

 -c                   Check for bad blocks and add them to the badblock list

 -f                   Force checking even if filesystem is marked clean

 -v                   Be verbose

 -b superblock        Use alternative superblock

 -B blocksize         Force blocksize when looking for superblock

 -j external_journal  Set location of the external journal

 -l bad_blocks_file   Add to badblocks list

 -L bad_blocks_file   Set badblocks list

 -z undo_file         Create an undo file

To view filesystems of devices

df -Th

The disk usage (du) command shows storage stats for files and directories

  • du -a /usr
  • du -inodes /usr
  • du -h /sbin/* | sort -n
    • -h Digs deeper into directories
  • du -s /sbin/*

The disk free (df) command shows filesytems information

  • df -a
  • df -h
    • Size – appropriate size
  • df -H
    • size multiplies by 1000(aka marketing size)
  • df -i
    • Inodes described
  • df -t ext2
  • df -T

Show me the largest file underneath this directory

du -ah ~/Downloads/* | sort -n

Leave a comment

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