These commands aren't standardized though, and you should verify the filesystem type and compare documentation from that specific man page.ĭespite that, generally you can use -p to allow fsck to automatically apply repairs. There are also some option flags that we can add to allow some automated correction. If none displayed, check the exit code with echo $?. Now run the fsck command: sudo fsck /dev/sdbĬheck the output for any errors. Repair a USB disk and other removable devicesįor our purpose, let's assume that you have already identified the problematic device /dev/sdb.įirst, you need to make sure that the drive has been unmounted: sudo umount /dev/sdb Now that you are a tad bit familiar with the fsck command, let's see practical use cases of this command. You can check the exit code of the last run command using echo $? command. 4 - File system errors left uncorrected.If you are using fsck on multiple devices, it will return the bit-wise OR of the two sums. Your exit code will be a sum of these codes if you analyze one disk.
This is a list of the codes that may be returned from fsck after inspecting a disk. Understanding exit codes for the fsck command The UUID is a fixed value assigned to your device and will not be affected by these system changes. While fsck accepts a device name like /dev/sda, you may elect to enter the UUID to avoid confusion with mounting and unmounting devices. Running fsck on a normal, healthy drive looks like this: :~$ sudo fsck /dev/sda2 If you try running fsck on a mounted device, you should see an error like this: :~$ sudo fsck /dev/sda3 dev/nvme0n1p3 98564096 500117503 401553408 191.5G Linux filesystem Unmount the device before running fsckĭo not run fsck on a mounted device, you will need to unmount the target first to avoid damage to your files. Sector size (logical/physical): 512 bytes / 512 bytes This way, you can specify which device to be checked with fsck command. You can use fdisk or df command to list the hard drive in Linux. You will need to run the command either as root user or use it with sudo. If you do not specify a filesystem, the system will analyze your fstab file ( /etc/fstab) for the devices to scan. The fsck command follows a pattern similar to most Linux commands. These do not need to be specified, but you may be able to find more advanced options in the man pages of these more precise commands.
Typically, you would want to run this command if your system will not boot, a device (external drives or storage media) is not functioning properly, or if you have seen evidence of file corruption.įsck is a actually a "front-end" for a number of file system specific checkers like fsck.vfat, fsck.ext2, etc. There are several scenarios where you may want to use fsck. This utility is used for checking and (optionally) repairing the file system. dev/mapper/cachedev2 /share/CACHEDEV2_DATA ext4 rw,usrjquota=aquota.Sometimes bad things happen to good systems.įortunately, you're a Linux user and you have fsck (file system check) to help with a potentially corrupted filesystem. I have 7 /dev/mapper/cachedev# mount points and problem is with 3 of them. đ1:09:37 Systemđ27.0.0.1 Storage & Snapshots Volume Failed to check file system of volume "Vol_Qsync". đ0:48:02 Systemđ27.0.0.1 Storage & Snapshots Volume File system not clean. I have a problem with unhealthy state of file system :