Disk check
Bad blocks
Install on NetBSD:
# pkgin install e2fsprogs
or on macOS:
# brew install e2fsprogs
Unmount device first on macOS:
# diskutil unmountDisk /dev/<device>
Start test:
# badblocks -n -s -v /dev/<device>
where <device> can be identified by executing:
# dmesg | tail
right after plugging in the USB flash storage on GNU/Linux or NetBSD and
# diskutil list
on macOS.
Smartmontools
Print health status of device /dev/sdb:
# smartctl --health /dev/sdb
smartctl 7.5 2025-04-30 r5714 [x86_64-linux-7.0.3-arch1-1] (local build)
Copyright (C) 2002-25, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
Start long off-line test on device /dev/sdb:
# smartctl --test=long /dev/sdb
smartctl 7.5 2025-04-30 r5714 [x86_64-linux-7.0.3-arch1-1] (local build)
Copyright (C) 2002-25, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 47 minutes for test to complete.
Test will complete after Fri May 8 16:58:51 2026 CEST
Use smartctl -X to abort test.
Print all SMART and non-SMART information about /dev/sdb:
smartctl --xall /dev/sdb
Print error logs for /dev/sdb:
smartctl --log=error /dev/sdb