Why does the file system have to be unmounted when fsck is run?

Why does the file system have to be unmounted when fsck is run?

The filesystem will change under fsck, and in-memory data that fsck caches from the filesystem will become invalid (and thus fsck will see inconsistency). You can run fsck on a read-only mounted filesystem in read-only mode and get valid results.

What is the purpose of fsck and e2fsck in Linux?

fsck is just the original name. When they came out with new file systems they would need a specific tool for each one, efsck for ext, e2fsck for ext2, dosfsck, fsckvfat. So they made fsck the front end that just calls whichever is the appropriate tool. fsck is a wrapper for the filesystem-specific fsck.

Why do I get an e2fsck error message?

If the file system is mounted, you’ll get the error message shown below. #e2fsck /dev/sdb1 e2fsck 1.41.12 (17-May-2010) e2fsck: Device or resource busy while trying to open /dev/sdb1 Filesystem mounted or opened exclusively by another program?

Do you need root privileges to run e2fsck?

Even if you still choose to run it on safe file system, result produced by e2fsck still won’t be valid. You should have root privileges to run this command. If not, you’ll get the error message. File system need not to be mounted. If the file system is mounted, you’ll get the error message shown below.

Can you run fsck on a mounted file system?

A. No. Do not run fsck on a live or mounted file system. fsck is used to check and optionally repair one or more Linux file systems. Running fsck on a mounted filesystem can usually result in disk / data corruption. So please do not do it.

How to repair a corrupted file system using e2fsck?

Automatic repair using e2fsck. Using -p option, you can direct e2fsck to check and automatically repair all found problems without asking user for confirmation. #e2fsck -p /dev/sdb1. You can also use option -y, which will automatically answer “yes” to all the questions that will be asked by the e2fsck command. #e2fsck -y /dev/sdb1.