A bad sector on a drive is a sign of permanent damage to the drive. Unless you have reason to believe that your drive marked these sectors as bad incorrectly, you cannot "fix" them.
It means that a part of your drive is damaged to the extent that it can no longer reliably be read from and/or written to.
Your system can continue to use the drive by marking that sector as unusable, but you might consider a drive replacement anyway, as a bad sector can be a sign that more sectors, or the whole drive, might fail soon.
While there may be ways to force the drive to un-mark a sector as bad, allowing you to use it again, this is likely not a good idea. The sector may stay good, but it will just as likely become bad again. Some data may be lost or corrupted depending on how it fails.
Now, as for the error message you've pasted in your question (as of my writing this), that error has nothing to do with bad sectors. It means that you don't have access to the drive. Being sudo
can give you access, so:
sudo fsck /dev/sdb
However, this is still probably not what you want, because /dev/sdb refers to the entire drive, whereas fsck
is designed to work on filesystems, which are usually (but not always, and you may have an exception here) placed in partitions. If the above didn't work, you may instead have wanted to do this to the 1st partition on that drive:
sudo fsck /dev/sdb1
You can get a list of partitions per drive with:
sudo fdisk -l
Before you can make a file system you have to create a partition.
sudo fdisk /dev/sdX
Where "X" is the drive letter (like sda or sdb depending on the drive).
n => Create new Partition (Then create what you need)
t => Specify type (NTFS is 07 I think, but you can take a look at the list with L)
w => Write the changes to disk and exit
Now you can make your file system with sudo mkfs.ntfs /dev/sdX1
where "x" is the drive letter from above. Add the configuration paramaters you need.
Best Answer
After writing the digression below, it occurred to me that I should probably also mention why I wrote it.
Any form of sector write or read error on a drive should be viewed as a potential warning. The drive could be failing. Certainly if a drive is reporting as many as 500 bad blocks, I would dig deeper into this before installing anything on the drive.
As I mentioned below, you can use Ubuntu
Disk Utility
from a Live CD/USB to examine the drive's SMART attributes. If the drive only has few pending reads, you can fill the drive with zeros to force the sectors to be remapped and then do another Ubuntu install.But watch the drive carefully for further signs of failure and don't save anything critical on it unless it is also backed up. If the drive continues to show sector errors, consider shopping for a replacement drive. Soon.
Just my opinion of course, for whatever it's worth.
These days it is hard to be certain what the phrase
bad blocks
actually means. In the pre-deluvian days of computing ... say 15 years or more ago ... it could refer to a list the operating system kept of sectors on a hard drive which the drive reported to be, well,bad
.All relatively recent drives now do this sort of tracking internally in their firmware and operating systems no longer need to track such things.
This Wikipedia article on Bad Sectors seems to be a reasonable overview. The key points being:
0x05 Reallocated Sectors Count
(How many sectors were remapped)0xC5 Current Pending Sector Count
(How many sectors waiting to be remapped)You can use an Ubuntu Live CD or USB to do these things.
After booting the Live CD/USB, open the
Disk Utility
application either with the GUI by searching for it withDash
or by running the commandpalimpsest &
in a terminal. Select the disk in the left sidebar and then use theSMART Status
function to retrieve and view the drive's S.M.A.R.T. attributes.The
dd
command command can be used from a terminal window in a Live CD/USB session to fill a drive with zeros. For example, the command below will write0x00
to every sector on drive/dev/sda
Of course, depending on the size of the drive this could take many hours to complete.
If you are curious, there are many more "tricks" one can use with
dd
. Have a look at the answers to this question on serverfault. I especially like this trick for periodically displaying the progress of add
command.