Equivalent of badblocks on Windows or DOS
Solution 1:
With the Windows Subsystem for Linux, you can run badblocks
directly under a Windows 10+ host.
-
Have a working WSL2 installation
-
In a console window, identify the physical path of your disk in Windows:
wmic diskdrive list brief
-
Copy the "DeviceID" for the appropriate drive:
Caption DeviceID Model Partitions Size
SMI USB DISK USB Device \\.\PHYSICALDRIVE6 SMI USB DISK USB Device 1 124654118400
-
Mount the disk so it is visible to WSL2:
wsl --mount \\.\PHYSICALDRIVE6 --bare
-
Inside of WSL, find the newly added device with
lsblk
:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sde 8:64 0 12.8T 0 disk
└─sde1 8:65 0 12.8T 0 part
-
Run
badblocks
against the device:badblocks /dev/sde
-
After
badblocks
completes, don't forget to unmount the disk so that it can be used again in Windows:wsl --unmount \\.\PHYSICALDRIVE6
Solution 2:
The best tool I've ever encountered for testing a hard drive for bad sectors is called SpinRite:
SpinRite 6
http://www.grc.com/sr/spinrite.htm
It was created by Steve Gibson (who writes most of his code in Assembler), and I remember using it back in the late 1980s on XT computers (with 4.77 MHz 8086/8088 processors) to recover bad sectors from failing hard drives.
The current version also works very well (and you also get the benefit of the many years of Steve Gibson's experience in maintaining this software to ensure it works reliably with all types of hard drives).
It is far more thorough than the ScanDisk or ChkDsk programs included with DOS and Windows.
Solution 3:
To update these answers for anyone who finds this as of 2014:
chkdsk
with either /r
or /b
switches is roughly equivalent to badblocks in the default read only mode
SpinRite has far better data recovery capability run at the default level 2
Run at level 4 it's equivalent to badblocks non-destructive read write mode, but with better data recovery capabilities.
However it falls over with divide overflows on modern huge drives, you'll need to wait for SpinRite 6.1 to fix this, development has started on 6.1 according to Steve Gibson on the Security Now netcast, but is suspended again while he completes another project.
Meanwhile, the nearest functional Windows based method to recreate the non destructive read/write badblocks mode for large drives requires owning storage equal to or greater than the drive being tested and would proceed thus:
Download and install a disk image program (Macrium reflect free, Acronis True Image either the commercial or drive maker's free version, or some other)
Create the WinPE recovery disk (you'll need later) and an image of the drive, with intelligent sector copy unchecked, and continue on finding bad sectors checked (both reverse of the default). This recreates the read pass.
Use the drive maker's DOS tool to zero fill the drive (roughly equivalent to the write phase)
Use the recovery CD to restore the image made in step 2 to restore the image you made to it's original location. (roughly equivalent to the write data back phase)
In the above scenario, or when using badblocks a modern drive's internal logic will handle remapping any bad sectors found when they're attempted to be written to.
To recreate the badblocks destructive test you'll need a commercial UK (not US) government approved drive wiping program and you'll need to run it at the higher security level, this will write patterns repeatedly to the drive and verify each pass much as badblocks does.
So until Spinrite 6.1 or later gets released, the question becomes, "Why would you want to do that?"
Downloading pretty much any Linux live CD/DVD will give you a bootable platform to run badblocks, which is cheaper, easier, and safer for your data, for any scenario where you need more than the read only test.
If you want the read only test, just run CHKDSK
with the /r
switch
If you want to run CHKDSK /R
on your system drive under Vista note it will ignore that you told it to run and skip the test on reboot unless you also use FSUTIL to mark the filesystem as dirty.
Solution 4:
chkdsk with the appropriate switch
/R Locates bad sectors and recovers readable information
/b NTFS only: Clears the list of bad clusters on the volume and rescans all allocated and free clusters for errors. /b includes the functionality of /r. Use this parameter after imaging a volume to a new hard disk drive. Works only on vista or better.
See here for a more complete switch list