The examples given in the question are not block devices, but the question is asked generically, so if yours is a block device, use:
badblocks -n -c1 /dev/device-name 0 0
This will try to do a non-destructive re-write of the first 1024 bytes of the device
If it's in use, you'll see:
/dev/device-name is apparently in use by the system; it's not safe to run badblocks!