Wednesday, February 29, 2012

How to Run Safely E2fsck on a Live, Mounted File System in your Linux system without Facing Data Loss

File system corruption is a common issue faced by Linux users over and over again. This problem usually results due to sudden power failures, bugs in the Linux code, hardware issues, etc. Linux has an inbuilt tool 'e2fsck' that is responsible for verifying and checking the consistency of the ext2/ext3/ext4 family of file systems. In case of ext3 and ext4 file systems that use journaling, this program generally replays the journal and then terminates. 

In a majority of cases, the file system is marked as clean after the application of journal. However, if the superblock shows that the file system needs repair, 'e2fsck' will carry out further processing. If the 'e2gsck' tool fails to repair corruption in the file system, you need to use advanced Linux Data Recovery software.

It is not safe or recommended to run 'e2fsck' on a mounted file system. This may lead to disk corruption and subsequent data loss. To do this, you can try the following two methods:

I)       Try to take your system to a single user mode and then unmount it:

·         Run 'init' (process control initialization) command to switch to runlevel 1, i.e. single user mode.
# init 1

·         Now, unmount '/home' file system with the help of 'umount' command.
# umount /home
# umount /dev/sda

·         Run the fsck or e2fsck tool
# fsck /home
# fsck /dev/sda3
# e2fsck -y /dev/sda3

II)    Boot your Linux computer using the installation CD and switch to rescue mode:

·         If you have Cent OS/Fedora Core/RHEL Linux, boot from the installation disc and run the following command at the boot prompt:
boot: linux rescue nomount
·         Create a new node for your hard disk and partition 3:
# mknod /dev/sda
# mknod /dev/sda3
# fsck /dev/sda3

You can also do the following:
# e2fsck -y /dev/sda3

If 'e2fsck' fails to resolve your file system issues, you should take help of a professional data recovery Linux utility. These third-party tools have a knack of recovering every bit of your lost, deleted, or formatted data from Linux hard drives and volumes. They support Ext4, Ext3, Ext2, FAT32, FAT16, and FAT12 file systems. 

Some of these utilities also provide an option to create an clone or exact replica of your hard drive. Moreover, they include support for all commonly-used Linux distributions, such as Red Hat, SUSE, Debian, Caldera, Mandrake, etc.