3

So, lately I've been having issues booting up Ubuntu and having to go into grub and do a recovery boot and I'll have issues saying "i/o errors in dev/sda" or something along those lines and I noticed I have 113 have bad sectors in my HDD when I just recently started the Disks setting. Isn't there a way to block out those bad sectors or something? What should I do? Thank you!

durango
  • 33
  • 1
    Make a backup and ensure you can restore from it. Then you can start playing games with the disk. – ubfan1 Nov 17 '14 at 01:07
  • As funny as that is, I just bought this hard drive like 3 months ago and I just recently built this computer. So, it's sort of a bumber. – durango Nov 17 '14 at 02:11
  • I understand that. Same thing has happened to me before. It's not fun. – Kaz Wolfe Nov 17 '14 at 05:27

1 Answers1

9

With bad sectors, you should always immediately backup all important information and get a new hard drive. You can theoretically mark these sectors as "bad" and tell the computer not to use them. However, this is not at all recommended as bad sectors like spreading like a fungus.

If you want to try this, instructions are below.

  1. Find your hard drive with lsblk. Find the EXT partition mounted at /.
  2. Remember the code. It should look something like /dev/sda1.
  3. Strip the number off the code you got earlier. If you had /dev/sda1, your code is now /dev/sda.
  4. Run this command: sudo badblocks /dev/sdc > /home/$USER/bad-blocks
  5. Run this command: sudo fsck -l bad-blocks /dev/sdc
  6. While running the above commands, go take a walk. Do not touch your computer.

Disclaimer: I am not responsible for any loss of data or system damage that has resulted from the above commands, both instant and in the future. I hold no responsibility for what you type into your terminal. You have been warned.

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172
  • This is exactly what I wanted to hear. Thank you very much! I have a backup already,so I should be good. Thank you! – durango Nov 17 '14 at 02:05
  • @durango If this solved your problem, please hit that green checkmark. It helps the community, you, and me. Everyone wins! – Kaz Wolfe Nov 17 '14 at 02:07
  • 1
    You should not be using the bad blocks list on modern hard disks. These days the disk itself internally remaps bad sectors to a pool of spare good sectors. – psusi Nov 17 '14 at 02:46
  • @psusi That forces the process to take place. I recommend not even working with a bad HDD in the first place. – Kaz Wolfe Nov 17 '14 at 05:21
  • What forces what process to take place? – psusi Nov 17 '14 at 14:16
  • @psusi IIRC, this command tells the disk that these sectors are bad and to mark them as unusable. – Kaz Wolfe Nov 17 '14 at 17:55
  • 1
    No... badblocks just tries to read each sector and writes a list of which ones failed to stdout. fsck -l creates an invisible "bad blocks" file uses those bad blocks so that no other file will use them. – psusi Nov 17 '14 at 18:11
  • Really? I have no idea where I read that.... – Kaz Wolfe Nov 17 '14 at 18:35
  • Reading the documentation of fsck.ext3, the -c option runs badblocks internally while at the same time avoiding inconsistent block sizes... I'm not expert on this, but it makes me wonder whether that would be the better option? – FriendFX Apr 29 '16 at 11:05
  • @KazWolfe do you mean "sda" instead of "sdc"? If it's supposed to be "sdc" then why do we need to note the code? – user87317 Nov 05 '18 at 22:33