btrfs-find-root - Linux
Overview
btrfs-find-root is a command-line tool used to search a given block device or file for the root filesystem of a Btrfs filesystem. It is primarily useful for identifying the correct device or file where a Btrfs filesystem is located, making it crucial for system rescue and recovery scenarios.
Syntax
btrfs-find-root [options] [device|file]
Options/Flags
- -B, –block-size BYTES: Specify the block size to use, in bytes. Defaults to 4096.
- -m, –metadata-offset BYTES: Specify the metadata offset to use, in bytes. Defaults to 64.
- -s, –search-size BYTES: Specify the maximum size of the search area, in bytes. Defaults to the size of the device or file.
- -v, –verbose: Print additional information during the search.
- -h, –help: Print usage information.
Examples
Basic Usage
To search for the root filesystem on a block device (/dev/sda):
btrfs-find-root /dev/sda
Searching a Specific Range
To search a specific range of bytes on a file (myfile.img):
btrfs-find-root -s 10000000 myfile.img
Modifying Metadata Offset
To specify a custom metadata offset:
btrfs-find-root -m 128 /dev/sdc1
Common Issues
- Device Not Recognized: Ensure that the specified device or file exists and is accessible.
- No Root Filesystem Found: The device or file may not contain a Btrfs filesystem or the root filesystem may have been damaged.
- Unexpected Output: The output may contain multiple matches if the device or file contains multiple root filesystems.
Integration
btrfs-find-root can be used in conjunction with other tools for system recovery:
- fdisk -l: To obtain a list of block devices and their partitions.
- ddrescue: To recover data from a damaged device.
- btrfs-restore: To restore a backup of the root filesystem.
Related Commands
- btrfs-check: Checks the integrity of a Btrfs filesystem.
- btrfs-rescue: Provides various rescue and recovery options for Btrfs filesystems.
- dumpe2fs: Dumps the superblock and other metadata from an ext2/ext3/ext4 filesystem.