Get to the Source
Plenty of us Stone-age tech geeks (The Over 30s) remember the days when you would shut down your machine with everything working normally, only to start work the next day with an utterly ruined hard drive. Ah, the good old days!
Modern hard drives, however, die a bit more slowly. Divided into sectors as they are, they are designed to go down little by little as the ''friction'' of daily operation begins to tell. Ubuntu fixes most small bad sectors automatically, but if it's a big problem (a whole file system is down), or you have Ubuntu installed on an old machine with the goal of extending its life, you will have to recover your data manually.
How to recover bad sector for Ubuntu is a simple procedure from the start. The tools you need are easily accessible through the ''Applications'' tab. There is no need to add any programs or scripts. Click through to ''Accessories'' and select ''Terminal''. Uh ohh, that's right. Command line stuff. Don't panic, breathe deep; you got through the age of DOS, right? In the command line, type ''mount'' and press the enter key. Next you must select the directory you want Ubuntu to try to repair. Filepath is everything when dealing with command lines. If you're not sure, just look for the file you want recovered in the GUI, and the filepath should be displayed on top of the window. Now, before Ubuntu tries to repair the system, it must be unmounted, so type the command ''unmount" with the filepath of the bad sector. For example, if your home directory is bad, you would enter ''sudo unmount /home''
How to Fsck Your Hard Drive
Next you type in the fsck command. Calm down you dirty-minded hacks out there, it's not named for any sort of depraved act; it's merely shorthand for "File System Check," although I cannot say with certainty the original programmer did not get in a laugh or two.
What the command will do is search for bad sectors in the specified files and attempt to repair them. You can only run fsck on an unmounted file system. Trying to run this command on a mounted file system would only corrupt it beyond repair, so if in your eagerness you miss one of the steps and get a warning that the file is still mounted, go back and get it unmounted before proceeding with the process, otherwise your valuable data like your business documents or high school picture collection will be lost for good. To run fsck on your home folder, you would enter ''"sudo fsck /dev/mapper/vg0-home". Then you might want to go fishing or to the park or something, as this tool was designed in the 1980s; and while it was probably quite snappy on the 500 kilobyte hard drives of the day, it will take the whole afternoon to check and repair a modern hard drive. Once fsck does its thing, remount the repaired file system.
The Limits of Running Fsck: What to Do When It Can’t Help You Anymore
If you have a bad sector that cannot be unmounted while Ubuntu is running, such as ''root'', you will not be able to run fsck. Don't panic. You can always run fsck normally on root through a live Ubuntu disk (just load your install CD, restart, select ''test Ubuntu'' and proceed with ''root'' the same way as directed with ''home''.
This tool is great for extending the file of older machines, but remember that when it comes to magnetic hard drives, you're fighting a losing battle against time. The need to repair bad sectors is minimal in Ubuntu due to the very tough architecture of the ext3 and ext4 folders where most data is stored. If you need to run this command regularly, chances are that your hard drive is failing and has to be replaced.
If fsck is able to restore your data, the wisest thing to do is to back up everything you want to keep. You should also do this if fsck is unable to restore the corrupted drive. If you have a persistently irreparable sector, then its time to enter emergency data-rescue mode. Disk failure spreads like a cancer: It will spread bit by bit throughout the sectors until your system won't even have enough good memory to boot anymore. There is no reliable fix for hard drive failure. Programs that claim to ''isolate'' bad sectors generally only buy you time.
To avoid a loss of data, today's modern PC users simply need to follow the same backup practices we did in the days of the old black-and-yellow screens, which is to keep a copy of everything worth keeping. After all, if you take precautions to secure your computer against theft, it only makes sense to secure yourself against data loss–not as difficult a task as it used to be. With my first computer, in the old cave-dwelling days, I needed a stack of floppy disks that reached to the roof to back up what today would fit in a bog-standard usb drive!
- Author's Knowlege
- Screenshot created by the Author.