Skip to content

Instantly share code, notes, and snippets.

@ngocleek
Last active October 31, 2024 02:25
Show Gist options
  • Select an option

  • Save ngocleek/7a65b2d13e4fe5d1a95c92ad1399e65e to your computer and use it in GitHub Desktop.

Select an option

Save ngocleek/7a65b2d13e4fe5d1a95c92ad1399e65e to your computer and use it in GitHub Desktop.

Using Badblocks to check new drive

  1. Locate the drive's device ID using the lsblk command
  2. Check the recommended block size using the command blockdev --getbsz /dev/<YOUR BLOCK DEVICE ID>
  3. Note the block size you got from the last command
  4. Have you ensured that the USB device does NOT have any important data on it? Running the specific badblocks command we'll use will destroy data on the drive!
  5. Fire up a new tmux session tmux new -s badblocks_<YOUR BLOCK DEVICE ID>
  6. Run the command badblocks -t random -w -s -b <YOUR BLOCKSIZE GOES HERE> /dev/<YOUR BLOCK DEVICE ID>
  7. Disconnect from the session by pressing CTRL+b then d
  8. Reconnect to the session to check on it by using tmux attach-session -t badblocks_<YOUR BLOCK DEVICE ID>
  9. Wait for it to finish
  10. To kill tmux session pressing CTRL+b then : and type kill-session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment