Skip to content

Instantly share code, notes, and snippets.

@cmcginty
Last active August 5, 2021 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmcginty/484d133469cddd183ca8be2a96b4373e to your computer and use it in GitHub Desktop.
Save cmcginty/484d133469cddd183ca8be2a96b4373e to your computer and use it in GitHub Desktop.
Hard Drive Integrity Tests with Badblocks Command

Before installing a new hard drive, use the following steps to detect any IMF issues.

  1. Install badblocks tool.
brew install e2fsprogs
brew ln --force e2fsprogs
  1. Run badblocks over device for at least 1 complete pass.

IMPORTANT: THIS WILL DESTROY ALL DATA ON YOUR DRIVE!!

NOTE: Make sure to use /dev/rdisk[0-9] device with the badblocks command for better performance.

sudo diskutil unmountDisk /dev/disk5
sudo badblocks -svw -e 1 -b 4096 -c 1024 -t 0xaa -t 0x55 /dev/rdisk5

Estimate ~210 minutes per TB (for each pattern) on a USB drive for this command to run.

For example, the above command runs 2 patterns, therefore an 8TB device requires ~56 hours.

Size 1 Pattern 2 Patterns 4 Patterns (default)
1 TB 3h 30m 7h 14h
2 TB 7h 14h 28h
4 TB 14h 28h 56h
8 TB 28h 56h 112h
12 TB 42h 84h 168h
16 TB 56h 112h 224h
18 TB 63h 126h 252h
20 TB 70h 140h 280h
Checking for bad blocks in read-write mode
From block 0 to 65536
Testing with pattern 0xaa: done
Reading and comparing: done
Testing with pattern 0x55: done
Reading and comparing: done
Testing with pattern 0xff: done
Reading and comparing: done
Testing with pattern 0x00: done
Reading and comparing: done
Pass completed, 0 bad blocks found. (0/0/0 errors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment