Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've just installed the new version of Ubuntu, Karmic Koala, in my laptop. Everything is fine, except for the fact the system identified about 300 bad sectors in my 1TB external hard drive. I'd like to recover or just mark then. Is there any free utility, that I can run on Linux, to accomplish this?

Update:

The partition is formatted in NTFS.

Thanks in advance

share|improve this question

5 Answers 5

up vote 6 down vote accepted

If the OS itself is showing bad sectors, then your drive is going downhill. The hardware should be removing bad sectors from service transparently, and it may have run out of spare sectors to remap to. If this is the case, your data is very much at risk.

I'd take David's suggestion to heart and migrate your data ASAP. You may want to install "smartmontools" and run smartctl to see what the device itself reports.

You can try using the "badblocks" utility on the raw device which houses your NTFS drive, since it works on the device and is not filesystem dependent. Make sure you read the man pages CAREFULLY and use the non-destructive mode. It should be able to read each sector, then re-write each sector. Doing this should force the drive itself to remap any problematic sectors. Test this procedure on a USB stick or some other media first.

I recommend you tell badblocks to process a large number of sectors at a time, since a 1TB drive will take a very long time to scan.

Again... make sure you know what you are doing. One slip and your data is toast.

If the data is valuable to you and you're not confident in your abilities, you may wish to use a commercial solution such as SpinRite (though, it's pricey and will require a Windows machinie). Note, I've never used SpinRite, but I've heard good things about it online.

share|improve this answer
1  
For link purposes, as this answer may be of equal interest to Mac users who wish to check blocks of a volume that uses NTFS: Fix bad blocks on Mac hard disk and in Ask Different, What free or open source software can I use with Mac hardware to verify integrity of every block of a disk where Core Storage is used? –  Graham Perrin Jul 27 '12 at 18:06

It depends on the filesystem you are using. If you are using ext2, etx3 or ext4 (IIRC Ubuntu 9.10 defaults to ext4 for new installs, earlier versions default to ext3) then you can run

e2fsck -c -c -k -C 0 /dev/device

i.e.

e2fsck -c -c -k -C 0 /dev/sdc1

for the filesystem on the first partition of drive sdc. The filesystem should not be mounted while this takes place, so if it is needed for your normal running system you will need to run e2fsck while booted from a "live CD" or similar.

The -c option is what causes the surface scan to be added to what the checker does, then second -c makes it do a non-destructive write+read test, -k tells it to keep any existing list of badblocks instead of retesting them and -C 0 just makes e2fsck output more progress information as it does its work. See man e2fsck for more detail.

The above will mark the bad blocks so that are not used in future. You will need to rerun it if you ever reformat the drive or that individual partition. You should also rerun it occasionally anyway, in case there are any "almost bad" sectors that degrade further. There is no way of "recovering" bad sectors.

I recommend you consider migrating your data onto another drive instead though, unless there is nothing of any real importance on there (i.e. it wouldn't inconvenience you overly if the drive suddenly got much worse and the data became practically unreadable or corrupt). If you don't replace the drive, make sure you have good backups in place for anything you do care about (though you should have a good backup regime in place anyway).

share|improve this answer
1  
Thanks but I'm using the NTFS filesystem in my external hard drive. Does this command apply to this situation, too? –  user19920 Dec 2 '09 at 14:27
    
To my knowledge there is no standard Linux command/utility to check/repair NTFS volumes, with or without a surface scan. You'll need to try from a Windows machine. –  David Spillett Dec 2 '09 at 18:01

Not sure if NTFS-related:

Bad block HOWTO for smartmontools

share|improve this answer
    
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Tom Wijsman Aug 11 '12 at 14:46
# ntfsresize -i /dev/sdb3

Device name        : /dev/sdb3
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 287967052288 bytes (287968 MB)
Current device size: 287967052800 bytes (287968 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 178645 MB (62.0%)
Collecting resizing constraints ...
You might resize at 178644316160 bytes or 178645 MB (freeing 109323 MB).
Please make a test run using both the -n and -s options before real resizing!

# ntfsresize -ns  /dev/sdb3

Non-destructive resize

# ntfsresize -s  /dev/sdb3

Real resize! careful...
share|improve this answer
1  
It would probably be useful to give a little context to the code block you've posted. Those that know will I'm sure, have no trouble understanding. But if your answer is to be useful for others as well, you should describe here what the commands actually do. –  JoshP Sep 27 '12 at 12:57

Your Answer

 
discard

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