Spearfoot / disk-burnin-and-testing

Shell script for burn-in and testing of new or re-purposed drives
Other
835 stars 102 forks source link

Add check if device is in use. #1

Open nybogard opened 4 years ago

nybogard commented 4 years ago

I ran your script on an 8TB disk but it finished after just a couple of days. I discovered that badblocks had exited immediately with no apparent reason. It just said that it had finished and then the script continued with the next step.

When I ran badblocks myself I got the message

/dev/sdb is apparently in use by the system; it's not safe to run badblocks!

Apparently I had missed to unmount the drive. It would be nice if the script did a check if the device is mounted directly when you run it and warns you.

Thanks for a awsome project!

Kryptonit3-zz commented 4 years ago

Someone needs to convert this script to work on Freenas. https://github.com/ezonakiusagi/bht

Spearfoot commented 4 years ago

I ran your script on an 8TB disk but it finished after just a couple of days. I discovered that badblocks had exited immediately with no apparent reason. It just said that it had finished and then the script continued with the next step.

When I ran badblocks myself I got the message

/dev/sdb is apparently in use by the system; it's not safe to run badblocks!

Apparently I had missed to unmount the drive. It would be nice if the script did a check if the device is mounted directly when you run it and warns you.

Thanks for a awsome project!

Thanks for your comment! I've never run into the problem of mounted drives not being available, probably because I only ever run the script on new drives, or old drives that I want to vet before putting them into service. I either case, I always pay very close attention to drive ID so that I won't mistakenly destroy data on the wrong drive! That said, do you know of a reliable way for a script to determine whether or not it's safe to run badblocks on a drive?

nybogard commented 4 years ago

Hello @Spearfoot! Sorry for the ridiculous long time it took me to answer.

Whether it's safe or not to run badblocks on a device is kinda up to the user. Badblocks wont complain if a device have one or more partitions, it'll just happily write them over if none of them are mounted.

I only suggest that early in the script (before the SMART tests) there is a check if any partition on the device is mounted. Otherwise the script will run for several hours before it comes to badblocks which then fails if anything actually was mounted.

If you want I can make a small check using grep and /proc/mounts and send a PR.

Spearfoot commented 4 years ago

nybogard: pulls requests are always welcome!