22

I would like to run a full, sector-by-sector, physical check on some external hard drives. As far as I know,chkdsk does not supply this option.

Is there a workaround under chkdsk, or a good replacement? I'm using Windows 7 on this machine, but Linux solutions applicable from a live CD are also welcome.

ᄂ ᄀ
  • 3,875
  • 1
  • 19
  • 18
Adam Matan
  • 8,090
  • 17
  • 59
  • 84
  • What OS are you running? Since you mentioned chkdsk, I assume it's Windows NT, XP, Vista, 7, Server 2003, or Server 2008. – rob Nov 06 '09 at 23:14

7 Answers7

34

In Windows NT/XP/Vista/7, you can open a CMD prompt and use

chkdsk /r x:

where x is the drive letter of your USB drive, assuming the drive is partitioned and has a drive letter assigned to it.

I'd suggest getting an Ubuntu live CD and booting into Linux, then using badblocks to scan for physical defects.

Use sudo fdisk -l to list all the drives and their partitions. For each drive:

sudo badblocks -nvs /dev/sdx

where your hard drive is /dev/sdx. This will perform a non-destructive read/write test on the disk without doing a filesystem check.

If you don't care about the data, you can do this instead, to do a more thorough scan:

sudo badblocks -wvs /dev/sdx

The -w option tells badblocks to write a known pattern, then read back the data to make sure it matches the pattern. It does this 4 times, using the patterns 0xaa, 0x55, 0xff, and 0x00 (alternating 0's and 1's, then all 1's, then all 0's). Note that this will overwrite all data on the drive and wipe out all the partitions, as well.

If you happen to have a Linux filesystem on the drive, you can check for filesystem errors and run badblocks at the same time. First, get the list of all the drives and their partitions:

sudo fdisk -l

Then for each partition:

sudo e2fsck -fcc /dev/sdx#

Again, /dev/sdx is the hard drive you want to scan. # is the number of the partition (e.g., /dev/sdb1). Specifying c twice will force fsck to run, and will use badblocks to do a non-destructive read-write test. If you just use the c option once, badblocks will do a read-only test.

I run badblocks -wvs on every new hard drive I purchase before putting it into service.

rob
  • 14,148
  • 5
  • 52
  • 85
  • 1
    I don't think chkdsk /r really scans every block...it runs much quicker than I'd expect for something reading every single block. Might want to note the non-destructive test option of badblocks, incase he already has data on the disks. – davr Nov 06 '09 at 23:29
  • @davr: Thanks; I already mentioned the badblocks non-destructive test in the fsck command, but I've added an explicit badblocks -vs to be thorough. chkdsk /r checks for bad blocks and takes quite a while when I run it, but probably isn't as thorough as badblocks -w. Are you sure you're not thinking of chkdsk /f or chkdsk /p, which will only fix filesystem errors but won't scan for bad blocks? – rob Nov 07 '09 at 00:30
  • @davr: I did think of one thing...chkdsk probably doesn't check the boot record or partition table. Since it only takes a volume name (i.e., drive letter, mount point, or volume name) as an argument, that suggests you can only check a logical volume for media errors, and everything outside of the specified volume (partition) is ignored. That shouldn't make much of a difference in terms of the scanning speed, though. Is that what you're talking about? – rob Nov 07 '09 at 00:45
  • 1
    Your use of fsck is actually a reference to e2fsck. The stock fsck doesn't include a `-c` command line arg. Other than, good answer. – DaveParillo Nov 07 '09 at 05:21
  • Right you are, Dave. Thanks; I've moved the badblocks instructions up front since he's running Windows, but fixed the e2fsck instructions and moved them to the end for anyone who runs across this and is running Linux. – rob Nov 09 '09 at 18:44
  • For completeness, the `-n` flag to `badblocks` will do a non-destructive read-write without having to use e2fsck. – SabreWolfy Jun 22 '12 at 13:56
  • Thanks; I actually intended to use that in my first badblocks example but forgot to include the flag! Fixed now. :) – rob Jun 22 '12 at 16:20
5

I would like to run a full, sector-by-sector, physical check on some external hard drives.

Download and run HD Tune, pick the drive you want to scan from the drop down menu, click the tab Error Scan (make sure the box Quick Scan is clear) and hit Start.

enter image description here

HD Tune is free for personal use and portable (no installation required).

Gaff
  • 18,569
  • 15
  • 57
  • 68
  • 1
    Freeware?? 15-day trial! It's just HD Tune that's freeware. – Loren Pechtel Nov 06 '09 at 22:40
  • apologies, edited the post ... doesn't make much of a difference though because the feature i'm referring to is available in the free version, as you can tell from the screenshot. –  Nov 07 '09 at 00:56
1

Many drive manufactureers like Western Digital and Seagate provide tools that will do this kind of check. Usually a Windows tool.

Dave M
  • 13,138
  • 25
  • 36
  • 47
1

Any modern drive will automatically remap unreadable/iffy blocks. An OS will normally not get a read failure for a block unless the block is really unreadable, and writing over that block will cause the drive to remap it. That will only fail if the drive is out of spare blocks, in which case it's time to replace the drive!

The upshot is that an OS marking "bad blocks" in the style of scandisk is usually pointless.

With that said, I'd use a SMART extended self test. smartmontools should work. You can also get the number of remapped blocks.

Note that in linux a plain dd if=/dev/sdx of=/dev/null , where sdx is the disk's block device, will do a full logical read of the disk. If any blocks are unreadable you'll get an error. If you don't mind clobbering data you can dd if=/dev/zero of=/dev/sdx to just overwrite the entire disk, causing the drive to remap as necessary.

Captain Segfault
  • 1,331
  • 8
  • 7
  • 1
    Instead of using 'dd', it's better to use the linux command 'badblocks', which is specifically designed for this task. – davr Nov 06 '09 at 23:26
  • 1
    My point is that "this task" is as obsolete as the concept of a "bad block". – Captain Segfault Nov 07 '09 at 01:53
  • The hard drive doesn't fix the bad blocks until you write to them. One good way of writing to them is to use badblocks in non-destructive mode. :D – endolith Dec 06 '09 at 05:16
  • I wish this was true. You are confusing internal disks with USB external disks. USB drive enclosures need better firmware with SMART reporting, which most of them lack. – Nicolay77 Jul 26 '15 at 14:37
  • @endolith Some hard drives do relocate suspicios blocks upon reading too. At least some enterprise HDD-s. – Roland Pihlakas Sep 14 '18 at 19:00
1

On Windows, I'll use the free version of HDTune to scan for bad sectors. However, the Linux program BadBlocks is much better, giving you an exact list of every bad block, and supports both read and write checking (although write is destructive).

Dentrasi
  • 11,155
  • 4
  • 27
  • 28
  • 2
    badblocks also has a non-destructive write test. it reads the block, writes a new value, checks the new value, then writes the original block back. so it wont destroy any valid data on the disk. downside is the extra operations make it run much slower. – davr Nov 06 '09 at 23:28
0

In Windows I use Victoria for Windows for this purpose.

enter image description here

enter image description here

Joep van Steen
  • 4,730
  • 1
  • 17
  • 34
-1

I've never been too keen on USB external drives, because they didn't really exist when some of the best tools like ScanDisk were written. I particularly like the version of ScanDisk that comes with Windows 98 SE.

So, if it is an external drive, you should probably put it into a computer and then run fsck -f on the drive from a Linux LiveCD such as the PLD Rescue CD.

eleven81
  • 15,376
  • 15
  • 55
  • 83
  • 1
    ScanDisk is obsolete. fsck -f will force fsck to run, but it won't do a physical media test. – rob Nov 06 '09 at 23:12