Is there a good way to scan a drive for bad blocks in the background?

0

I just got a QNAP TS-251, an NAS that runs Linux plus the manufacturer's tools. One of the setup options is to run a bad block scan, but on a pair of 4 TB drives that might take a really long time to run, during which I can't start to use my new NAS.

So, is there a utility that I can run in the background once the device is fully functional? Obviously such a utility would take even longer than one that's running on new, empty drives, since it has to do its thing without destroying live data. But meanwhile the machine is functional and available.

Such a utility might also be useful as a periodic preventive maintenance tool, a few times a year, not just as a way to bring a new device into service sooner.

  • Does such a utility exist for Linux in general?
  • If so, does it run on a QNAP NAS?
  • Or is there a QNAP specific utility for this purpose?

Steve

Posted 2016-02-25T23:21:17.450

Reputation: 563

1

No a bad blocks search should be performed when the process can obtain exclusive access to the disk, so generally speaking, the disk should be unmounted at time of scan. This is because even when mounted as readonly, the process may cause kernel panics or damage the filesystem. see the notes on -f here: http://linux.die.net/man/8/badblocks

– Frank Thomas – 2016-02-26T02:16:11.430

1Last time I built up a NAS, I did check the SMART data and performed a filesystem check with free-space testing on each of the disks before using them, and good think I did as disk 2 needed to be RMA'd. I use JBOD though, so I did the testing on another PC, and then installed each disk to the NAS as it became ready. even if you plug it into a windows system, format it NTFS and run chkdsk on it, you can always let the QNAS reformat it natively when you are sure the new disk is healthy. – Frank Thomas – 2016-02-26T02:19:37.977

Answers

0

Since you tagged badblocks in your question, I assume you have some measure of familiarity with it. It can be run as a part of the e2fsck program used to check Ext2/3/4 filesystems if the underlying partitions on the NAS use that filesystem:

e2fsck -c /dev/blockDeviceHere

Darth Android

Posted 2016-02-25T23:21:17.450

Reputation: 35 133

I don't know e2fsck very well, and I seem to remember that the BSD fsck I used many years ago tended to start over frequently if there was any write activity on the drive. Also, I see that the man page says, "If e2fsck asks whether or not you should check a filesystem which is mounted, the only correct answer is ''no''." – Steve – 2016-02-25T23:55:12.677