Created
March 26, 2025 12:47
-
-
Save KrzysztofHajdamowicz/1618d33e76542b11dc9a5731d6415769 to your computer and use it in GitHub Desktop.
bcachefs read FUA test
This file contains hidden or 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
#!/usr/bin/env python3 | |
import os | |
import glob | |
def list_bcachefs_devices(base_dir): | |
# Iterate over each bcachefs filesystem UUID directory | |
for uuid_dir in glob.glob(os.path.join(base_dir, '*')): | |
if os.path.isdir(uuid_dir): | |
print(f"Filesystem UUID: {os.path.basename(uuid_dir)}") | |
# Iterate over each dev-* directory within the UUID directory | |
for dev_dir in glob.glob(os.path.join(uuid_dir, 'dev-*')): | |
if os.path.isdir(dev_dir): | |
model_file = os.path.join(dev_dir, 'block/device/model') | |
read_fua_test_file = os.path.join(dev_dir, 'read_fua_test') | |
# Read and print the content of the model file | |
if os.path.isfile(model_file): | |
with open(model_file, 'r') as file: | |
model_content = file.read().strip() | |
print(f"Model: {model_content}") | |
else: | |
print("Model file not found.") | |
# Read and print the content of the read_fua_test file | |
if os.path.isfile(read_fua_test_file): | |
with open(read_fua_test_file, 'r') as file: | |
read_fua_test_content = file.read().strip() | |
print(f"Read FUA Test: {read_fua_test_content}") | |
else: | |
print("Read FUA Test file not found.") | |
print("-" * 40) | |
# Define the base directory | |
base_directory = '/sys/fs/bcachefs/' | |
# Call the function with the base directory | |
list_bcachefs_devices(base_directory) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! Thanks for usefull script. But it fail to find Model if bcachefs drive is partition: