A Python utility to scan for bad blocks and create safe partitions on a storage device. This tool automates low-level disk preparation, ensuring partitions are free from damaged sectors, making them suitable for subsequent Btrfs filesystem creation.
- Detects the device's hardware sector size.
- Scans for bad blocks using
badblocks. - Creates multiple partitions that avoid bad blocks.
- Prepares the disk for a manual Btrfs filesystem creation.
- This tool is not meant for production use.
- Running this script will delete all data on the target disk. Use only on non-critical drives and make backups first.
Ensure the following tools are available on your system:
badblocksparted
These tools are typically pre-installed on most Linux distributions. If not, they can be installed via your package manager.
Prerequisite before running: The target disk must have a GPT partition table and contain no existing partitions.
-
Clone the repository:
git clone https://github.com/stony-letter-strategy-aptitude/btrfs-with-badblocks.git cd btrfs-with-badblocks -
Run the script:
python src/main.py
The script will:
- Detect the device's hardware sector size.
- Scan for bad blocks and save them to
badblocks.txt. - Create partitions that avoid the bad blocks.
-
Manually create a Btrfs filesystem:
After partitioning, you can create a Btrfs filesystem on the new partitions:
sudo mkfs.btrfs -L my_btrfs /dev/sdX1 /dev/sdX2 /dev/sdX3
Replace
/dev/sdX1,/dev/sdX2, and/dev/sdX3with your actual partition names.
This project is licensed under the GPLv2 License. See LICENSE for details.
Welcome to contribute! If you have suggestions, bug fixes, or improvements, feel free to create a Pull Request (PR).
Please ensure your contributions are well-documented before submitting.