Course contentsShow
← Linux
Lesson 723 of 1,8197. Storage Management and Logical VolumesFree lesson

Managing Btrfs device pools

Dynamically add and remove disks to resize storage pools without data re-layout.

In this lesson, you will learn how to expand or shrink your Btrfs storage pool on the fly by adding and removing physical disks without requiring a full data re-layout.

Understanding Btrfs Device Pools

Unlike traditional hardware RAID, where you define a static stripe size and disk count during initial setup, Btrfs treats your storage as a fluid "pool." When you mount a Btrfs filesystem, the kernel manages the collection of block devices as a single logical entity. Because Btrfs is based on a copy-on-write (CoW) design, it can track which chunks of data reside on which disk independently. This means you don't have to rebuild an entire array just to change the number of drives involved.

Dynamically Adding Storage

If you find your filesystem filling up, you can add a new disk to your existing pool instantly using the btrfs device add command. Once added, Btrfs treats the new capacity as available space for new writes:

# Add a new disk to your pool
sudo btrfs device add /dev/sdb /mnt/btrfs_data

The system immediately recognizes the increased capacity. You do not need to reformat or migrate your existing data to benefit from the extra space.

Dynamically Removing Storage

Similarly, if you need to retire a drive, Btrfs allows you to remove it from the pool while the filesystem is live. When you issue the remove command, Btrfs automatically migrates the data chunks existing on that device to the other remaining drives in the pool:

# Remove a disk and migrate data
sudo btrfs device remove /dev/sdb /mnt/btrfs_data

The command will pause until all blocks have been safely relocated. This allows for seamless hardware maintenance without ever unmounting the filesystem or interrupting active applications. Because the data is moved chunk-by-chunk based on physical location, it avoids the "rebuild" performance penalty associated with standard RAID parity layouts, provided you have enough free space on the remaining devices to accommodate the migration.

Key Takeaway: Btrfs manages storage as a flexible pool, allowing you to add or remove disks seamlessly by migrating data chunks in the background while the filesystem remains online.