Hi, I have an issue with my filesystem that might be caused by damaged HDD. Sometimes during normal work, when I, for example, try to install new package using pacman I get an error: could not lock database: root file system read-only. When I reboot Arch, filesystem is beeing repaired (recovering from journal for most of the time but some time I need to manually run fsck because it won't start). I tried to boot arch from live CD and run fsck -fpv (there was one more option but i can't remeber) it was supposed to fix bad sectors and according to messages I got, it did. But that didn't solve my problem. Is there any way I can fix it for good?
First, I would make sure you have a full backup.
You can check for bad sectors using badblocks. `man badblocks` for more information. Make sure you are doing a non-destructive test if there is data on the drive.
badblocks -v /dev/sda
If I remember correctly, there is a way to pipe the output from badblocks to mkfs to ignore those sectors during filesystem creation, but if there are many bad sectors your best bet is to get a new drive. It's probably a sign of one on the way out.
I always prefer to run hard drive diagnostics offline (i.e. from a live CD). I keep a copy of Parted Magic around for just such occasions. It's full of great tools, and includes gsmartcontrol. Use this to check your SMART data (check for re-allocated sectors, etc) and then run the "short" drive test. If your drive passes the short test, run the long test next (can take a few hours). If the drive fails either (usually with a "read error"), I would replace it soon, before it fails completely. There is no real need to run the long test if the drive fails the short test first.
You can also usually download diag tools from your drive manufacturer's website. For instance, Seagate has Seatools (I uasually boot Seatools for DOS from a CD or PXE). Western Digital and Hitachi have similar products.
If the drive is dying, ddrescue (also on the Parted Magic live CD) is a great tool to clone a failing drive to a new one.