Example: Using Fsck to Check and Repair a Filesystem
This procedure provides a basic example on how to use fsck and other Linux commands to check and repair a filesystem.
Pre-requisites:
You must be locally connected to the PSM server (rather than remotely using telnet or ssh).
The Linux fsck command can be used to check and repair a corrupted filesystem under some situations. This section contains one example of how to accomplish this for a non-root partition. Methods using other commands exist. Consult the Linux man pages for more complete coverage of the commands used in this example.
- Change to single user mode.
telinit 1
- List the mount points on your system.
For example:
[user ~]# df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/mapper/vg-lv_root ext4 55316552 6082732 46426180 12% / tmpfs tmpfs 3848252 0 3848252 0% /dev/shm /dev/mapper/vg-lv_backups ext4 16094652 6680620 8596472 44% /backups /dev/sda1 ext4 1032088 54272 925388 6% /boot /dev/mapper/vg-lv_home ext4 20223240 10190760 9006896 54% /home /dev/mapper/vg-lv_tmp ext4 10740304 158644 10036076 2% /tmp /dev/mapper/vg-lv_var ext4 67702420 15364244 48901456 24% /var /dev/mapper/vg-lv_log ext4 32189320 290212 30263988 1% /var/log
- Unmount all filesystems from
/etc/fstab
.[user ~]# umount -a
Caution To prevent data corruption, ensure that you unmount before running the fsck command on any filesystem.
Note Not all filesystems can be unmounted. You should not run fsck on any mounted filesystem.
- Find the logical volumes.
For example:
[root@mgtServ3 ~]# lvscan ACTIVE '/dev/vg/lv_var' [65.59 GiB] inherit ACTIVE '/dev/vg/lv_log' [31.19 GiB] inherit ACTIVE '/dev/vg/lv_tmp' [10.41 GiB] inherit ACTIVE '/dev/vg/lv_backups' [15.59 GiB] inherit ACTIVE '/dev/vg/lv_home' [19.59 GiB] inherit ACTIVE '/dev/vg/lv_root' [53.59 GiB] inherit
- Check and repair the filesystem.
For example, to check and repair the
/home
partition:[user ~]# fsck -yvfM /dev/vg/lv_home fsck from util-linux-ng 2.18 e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information 449 inodes used (0.04%) 10 non-contiguous files (2.2%) 1 non-contiguous directory (0.2%) # of inodes with ind/dind/tind blocks: 0/0/0 Extent depth histogram: 439 242020 blocks used (5.92%) 0 bad blocks 1 large file 423 regular files 17 directories 0 character device files 0 block device files 0 fifos 0 links 0 symbolic links (0 fast symbolic links) 0 sockets -------- 440 files
In the above output, there are no errors in the
/home
partition. - Continue to check and repair other partitions. After you
finish the repairs, reboot the PSM server.
reboot