Skip to content

stony-letter-strategy-aptitude/btrfs-with-badblocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

Features

  • 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.

⚠️ Warning:

  • 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.

Prerequisites

Ensure the following tools are available on your system:

  • badblocks
  • parted

These tools are typically pre-installed on most Linux distributions. If not, they can be installed via your package manager.

Usage

⚠️ Warning: Running this tool will erase all data on your disk.

Prerequisite before running: The target disk must have a GPT partition table and contain no existing partitions.

  1. Clone the repository:

    git clone https://github.com/stony-letter-strategy-aptitude/btrfs-with-badblocks.git
    cd btrfs-with-badblocks
  2. 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.
  3. 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/sdX3 with your actual partition names.

License

This project is licensed under the GPLv2 License. See LICENSE for details.

Contributing

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.

About

Python utility to scan for bad blocks and create safe partitions for Btrfs on storage devices.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages