Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Guide That Contains This Content
[+] Expand All
[-] Collapse All

    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.


    • 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.

    1. Change to single user mode.
      telinit 1
    2. List the mount points on your system.

      For example:

      [user ~]# df -T
      Filesystem    Type   1K-blocks      Used Available Use% Mounted on
                    ext4    55316552   6082732  46426180  12% /
      tmpfs        tmpfs     3848252         0   3848252   0% /dev/shm
                    ext4    16094652   6680620   8596472  44% /backups
      /dev/sda1     ext4     1032088     54272    925388   6% /boot
                    ext4    20223240  10190760   9006896  54% /home
                    ext4    10740304    158644  10036076   2% /tmp
                    ext4    67702420  15364244  48901456  24% /var
                    ext4    32189320    290212  30263988   1% /var/log
    3. 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.

    4. 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
    5. 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.

    6. Continue to check and repair other partitions. After you finish the repairs, reboot the PSM server.

    Modified: 2017-06-30