Created
May 18, 2021 14:54
-
-
Save alevchuk/cd21fbe31e37d8e588941daae326129f to your computer and use it in GitHub Desktop.
check fs / storage for corruption
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python3 | |
import os | |
import sys | |
data_dir = "checker-data" | |
try: | |
os.mkdir(data_dir) | |
except FileExistsError: | |
pass | |
print("Writing and reading checker data to dir: {}".format(data_dir)) | |
count = 1 | |
while True: | |
with open("checker-data/{:08}".format(count), "w") as w: | |
w.write(str(count) * 100) | |
for i in range(1, count + 1): | |
with open("checker-data/{:08}".format(i), "r") as r: | |
line = r.readlines()[0] | |
expected = str(i) * 100 | |
if line != expected: | |
print("Found inconsistency in {}".format(i)) | |
print("Got '{}'".format(line)) | |
print("Expected '{}'".format(expected)) | |
sys.exit(1) | |
count += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cd
into a folder in the mount where you're suspecting data corruptioncat > fs_checker.py
chmod +x fs_checker.py
time ./fs_checker.py
du -sch checker-data/
rm -rf checker-data/