Technology and troubleshooting.

Thursday, May 19, 2016

Troubleshoot linux Filesystem Issues

In this tutorial I am going to show you how to troubleshoot Filesystem Issues

Troubleshooting linux Filesystem Issues

Overview

When an operating system crashes, due for example to a power failure, improper shutdown,or other unexpected event, filesystems mounted on it can become corrupted. Generally filesystem corruption means the super block (the part of the filesystem that contain information about file system type, size, data blocks, free blocks, and inodes) is not updated and has incorrect information.

Key ideas

fsck: The fsck utility checks filesystems for inconsistencies and can also repair them. It can be used manually, but may also be run automatically if detection is detected during system boot, or if a value is set in the mount options of an fstab entry for a particular filesystem.Unmount a filesystem before using the fsck utility on it.
dd: The dd command is used to copy and optionally convert data. Used incorrectly, it can cause data loss.

My Scenario

To simulate an unexpected power outage that corrupts a filesystem, use the dd command to write random data to an empty filesystem. Then use the fsck command to repair the filesystem.

Now Do It
1. Use the dd command to copy random data over top of the the empty filesystem that you are corrupting on purpose.
# dd if=/dev/zero count=1 bs=4096 seek=0 of=/dev/PARTITION
Where PARTITION contains the filesystem you are corrupting on purpose. Don’t do this on a filesystem that contains important data.
2. Interactively check and repair the corrupted filesystem using the fsck command:
# fsck /dev/PARTITION
3. Confirm that the filesystem has been repaired using the fsck command.
# fsck /dev/PARTITION
4. Force a check on the clean partition, just to be sure using the fsck command with the -f argument.
# fsck -f /dev/PARTITION
5. Use the dd command to corrupt the filesystem again.
# dd if=/dev/zero count=1 bs=4096 seek=0 of=/dev/PARTITION
 6. Check and automatically repair the corrupted filesystem using the fsck command with the -y argument.
# fsck -y /dev/PARTITION

Note:-  Do not use fsck on a mounted filesystem.

 I hope you  this information is useful for you. Please forgive any typos or incomplete sentences.
Share:

0 comments:

Post a Comment

Contributors

Popular Posts