Showing posts with label fsck. Show all posts
Showing posts with label fsck. Show all posts

Sunday, May 17, 2009

File System Check using fsck

I won't begin to claim I know everything in Linux, but I'm learning. In most Linux systems if there is a crash or the OS suspects disk failure, the utility fsck will run at boot automatically. You can however run it manually from the shell as root. Here is the syntax for fsck:

fsck 1.41.3 (12-Oct-2008)
Usage: fsck.ext3 [-panyrcdfvtDFV] [-b superblock] [-B blocksize]
[-I inode_buffer_blocks] [-P process_inode_size]
[-l|-L bad_blocks_file] [-C fd] [-j external_journal]
[-E extended-options] device

Emergency help:
-p Automatic repair (no questions)
-n Make no changes to the filesystem
-y Assume "yes" to all questions
-c Check for bad blocks and add them to the badblock list
-f Force checking even if filesystem is marked clean
-v Be verbose
-b superblock Use alternative superblock
-B blocksize Force blocksize when looking for superblock
-j external_journal Set location of the external journal
-l bad_blocks_file Add to badblocks list
-L bad_blocks_file Set badblocks list

Since my experience is limited with Linux, I will refer you to the fsck listing in Wikipedia and also the MAN pages for fsck. If the occasion arises and you need to run this tool manually, read these pages first. No one ever wants to have to run tools like these but they can and often will save the day when disk errors surface.

Saturday, May 16, 2009

File Recovery

Everyone has lost a file or two sometime in their life at the hands of an errant mouse click or a hard drive failure of some kind. But have you lost a file from a flash drive? Once in a while a flash drive will say a file is corrupted or otherwise won't open. Did you back it up? If you are like most of us we just assume these little drives will work forever. I have sent my fair share through the wash and they still work. But today I want to share a story of a file gone bad on a flash drive. The file was an ordinary Word document. Nothing fancy in it but it would have been disastrous to re-create for this person not to mention they were under a deadline. At first I wasn't too confident the file was still there. Other files were on the drive but had it been over-written was what I was worried about. I plugged the drive in and I ran chkdsk on it. This is a utility that ships with all Windows computers. The utility always states it will run at the next re-start which I did right then. This was a 1GB flash drive but the scan was quick and it saved the files it found as 000001.chk. and so on. When I came back to Windows I was able to open these files in Word and we went through them one by one. We had gone through nearly all of them when on the last one she screamed there's my file. We saved the file under a new name and all was good again. Chkdsk is one of those forgotten utilities that will save fragments of the drives it is run on. In this case it was able to find several Word documents and most importantly the one we wanted. Here is the syntax of the chkdsk utility:
CHKDSK [drive:][[path]filename] [/F] [/V]
To learn what each switch does and how to make the most of this utility type at a command prompt: chkdsk /? ...and this will give you the details you need to run this utility. You can then save the errors it finds and go through them one by one o determine if they are worth keeping. This command will work on any Windows machine. I will cover the Linux version of this type of tool and also other file recovery methods in a future post.