cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

os:linux:command:fsck.html



Linux Commands Cheat Sheet

fsck - How to use fsck command on Linux

fsck options

# man fsck

OPTIONS
       -a     Automatically  repair  the  filesystem  without any questions (use this option with caution). 

       -n     For some filesystem-specific checkers, the -n option will cause the fs-specific fsck to avoid attempting 
              to repair any problems, but simply report such  problems  to stdout.   

       -y     For  some  filesystem-specific  checkers,  the  -y  option will cause the fs-specific fsck to always 
              attempt to fix any detected filesystem corruption automatically.
       -f     -f option to fsck (Force checking even if the file system seems clean.)


How to fsck

# cat /proc/partitions 
# fsck -nf /dev/sda3    <- check
# fsck -f /dev/sda3     <-  fix


How to force a fsck on server reboot

The -F flag means 'force fsck'.

# shutdown -rF now


How to fsck LVM Partition

# vgchange -ay VolGroup00
# fsck -f /dev/VolGroup00/LogVol00


How to check root partition with fsck?

  1. Booting into Single-User Mode
    1. At the GRUB splash screen at boot time, press any key to enter the GRUB interactive menu.
    2. Select Red Hat Enterprise Linux with the version of the kernel that you wish to boot and type a to append the line.
    3. Go to the end of the line and type single as a separate word (press the Spacebar and then type single). 
       Press Enter to exit edit mode.
    

    or

    # init 1
    
  2. check disk with mount command
    # mount
    
  3. umount root partision and fsck
    # umount /
    or
    # mount -o remount,ro /
    or
    # mount -o remount -rn /
    
  4. Check read only file system.
    touch /tmp/test.txt
    
  5. start fsck
    # fsck /dev/mapper/VolGroup-lv_root
    



os/linux/command/fsck.html.txt ยท Last modified: 2017/05/14 by admin

Page Tools