1

I want to test if physical errors of the disk, of it that is not possible, file system errors of the disk. The disk is a typical USB external drive. The disk (not by partition-level, but the whole disk itself) is encrypted using VeraCrypt. The partition I stored the files is using Btrfs. What is the way?


Here are the things I have tried on my own:

First, the web search result said badblocks but other result said that it is an obsolete tool now. And when I ran it, it asked for read-only something, and that made me think that it may destruct existing files, so I cancelled it.

Then, I tried to use the "Check filesystem" context menu on the volume of the VeraCrypt. But it showed an "fsck" window saying "If you wish to check the consistency of a BTRFS filesystem or repair a damaged filesystem, see btrfs(8) subcommand 'check'" and exited.

enter image description here

I opened a Terminal and tried to execute btrfs check but "sudo btrfs check (the device name)" failed with "no valid btrfs found on /dev/sdd" (probably because the whole disk is encrypted") and "sudo btrfs check (the decrypted directory)" failed with "not a regular file or block device".

enter image description here


PS: Thanks to the accepted answer, I got the correct device name. I am adding the following for future people who encounter the same problem. The comment I used was sudo btrfs --force --check-data-csum -p /dev/mapper/veracrypt1. I added --check-data-csum, because without it, it only checked the disk for the metadata checksum, not the actual files, so I had to run the test again (doing all the previous checks again). -p seems to be a nice option because it displays how many items have been checked so far.

Damn Vegetables
  • 1,187
  • 9
  • 19

3 Answers3

0

you can try a simple cat

sudo cat /dev/sdd > /dev/null

That will go through the raw device and should report if there are physical-level errors.

eftshift0
  • 555
  • 4
  • 13
0

If you want to check the disk for errors, you can use SMART:

smartctl -a /dev/sdd

or if you want GUI you can use GNOME Disks and the SMART Data & Self-Test menu option. (Not all external drives support SMART, this might not work for you.)

To check the filesystem, you can't use /dev/sdd because it holds the encrypted data, not the "readable" btrfs filesystem. Use lsblk to get name of the dm-crypt device which is used to access the cleartext data (it will probably be /dev/mapper/veracrypt1) and run the filesystem check on it:

btrfs check /dev/mapper/veracrypt1
Vojtech Trefny
  • 16,922
  • 6
  • 24
  • 48
  • It seems `smartctrl` is not supported for my Seagate. I ran the comment and it said "Read Device Identity failed: scsi error unsupported field in scsi command". `/dev/mapper/veracrypt1` worked. It warned about the partition being mounted, but I don't know of a way to unmount the drive without also removing decryption in VeraCrypt's GUI, so I continued with the `--force` argument. – Damn Vegetables Sep 30 '21 at 15:43
  • @DamnVegetables, this blog site, says to do: sudo veracrypt -p secretpassword -k "" --protect-hidden=no /path/to/disk --filesystem=none; then: veracrypt -l, to get location of semi-mounted drive, http://john.wesorick.com/2012/03/running-fsck-on-truecrypt-volume.html – gimmegimme Apr 20 '23 at 05:21
0

badblocks should be safe, after all, it asks only for read only access by default (unless you use the -w option). Run it as badblocks -s -v /dev/sdd. Though a better way (unless the disk is a SDD) is smartctl -t long /dev/sdd, then use smartctl -a /dev/sdd to monitor the progress (it will take some time) and to see the number of bad (i. e. reallocated) blocks.

Radovan Garabík
  • 1,833
  • 10
  • 15