How do I fix the Gparted message : Error while reading block at sector xxx?
When I tried to move one of my partitions, I got some error messages. Here are some extracts:
Move /dev/sda7 to the left 00:05:09 ( ERROR )
(...)
check file system on /dev/sda7 for errors and (if possible) fix them 00:00:10 ( SUCCESS )
e2fsck -f -y -v /dev/sda7
(...)
move file system to the left 00:04:52 ( ERROR )
perform read-only test 00:04:52 ( ERROR )
using internal algorithm
read 114013242 sectors
finding optimal blocksize
(...)
read 113357882 sectors using a blocksize of 1024 sectors 00:04:36 ( ERROR )
22527034 of 113357882 read
Error while reading block at sector 385849832
23182394 sectors read ( ERROR )
(...)
libparted messages ( INFO )
Input/output error during read on /dev/sda
What should I do to effectively move my partition?
Solution 1:
You have bad sectors on your hard disk. Back up any important data NOW. Then run the disk utility and click the SMART diagnostics. Run the long self test, and when that finishes, look at the values of the following attributes:
Offline_Uncorrectable Current_Pending_Sector Reallocated_Sector_Ct
If the uncorrectable count is non zero, or the reallocated or pending counts are more than a few, you need to replace the drive. If there are only a few pending, then you can attempt to repair them. First you need to identify the number of the bad sector. The badblocks utility can be used for this. Then you can use hdparm --read-sector to try reading from it to make sure you have the right one, and then hdparm --write-sector to try and rewrite the sector with zeros. That will force the drive to try to correct the sector, or if it can not, will reallocate it from the spare pool, moving a count from the pending_sectors to reallocated. Repeat for all bad sectors.
Solution 2:
This is what actually made me solve my problem. The response of psusi really helped, however it was really too rough for me and I spent something like three hours to get it all and to extract what would be interesting for me from his post. I had to search in Wikipedia, the official Ubuntu Forums and Ask Ubuntu. As a consequence I consider his post as a welcomed hint but not as the right answer.
- Run Ubuntu on a Live-CD.
- Using System -> Administration -> Gparted, disable the eventual swap partition (in other words, "swapoff"). Besides, note down the name of your corrupted drive, in my case "sda"
- In a terminal, run the command
sudo badblocks -sv -b 512 <device-name>
, where in my case is to be replaced by/dev/sda
. After a long time waiting, the result is a list of numbers which are the corrupted sectors. - Run the command
sudo dd if=<device-name> of=/dev/null bs=512 count=1 skip=<sector>
, where I replaced bydev/sda
and by385850816
, the first number given by the previous command. - Repeat the previous point for each number.
- To check if your rescue succeeded, run again the command
sudo badblocks -sv -b 512 <device-name>
. It should give (after a long while) no number.
As far as I am concerned, it solved my problem, and I was able again to move my partition. I have to admit I don't really know why, since the commands here-upon seem to be only read and to write commands. But whatever, I encounter no problem any more.