Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
This question has been viewed more than 1,000 times, but has never been upvoted when I write those lines… Thank you community. ;-) –  Agmenor Oct 19 '11 at 2:33

3 Answers 3

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.

share|improve this answer
    
Running SMART (after making a backup) might be a good idea indeed. In any case, even if the sector can still be re-allocated, I would be suspicious of that disk... –  JanC Jan 11 '11 at 19:23
    
Thank you for answering! I failed running the self-test, because of a reading error. Could you please give more details about the steps to follow from the one about that Badblocks utility? –  Agmenor Jan 12 '11 at 13:13

It seems like there is a hardware issue with your hard disk, so I suggest you use something like ddrescue or gddrescue to make a copy of it on a different hard disk. Then try to fix the filesystem(s) (with fsck), and if that doesn't work use photorec or similar rescue tools.

Or just put a backup back to another disk, if you have one, of course...

share|improve this answer
up vote 2 down vote accepted

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 by dev/sda and by 385850816, 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.

share|improve this answer
1  
If the list of bad blocks is small ( say a dozen or less ) then this is a good way to fix them. After doing this though, you should run the SMART long selftest in the disk utility weekly for a few months and make sure no new bad sectors develop. If there are many bad sectors, then you just need to copy off what you can, and replace the drive. –  psusi Apr 12 '11 at 20:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.