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

Btrfs subvolume mounting

Mount specific application subvolumes as distinct filesystems for security and management.

In this lesson, you will learn how to mount specific Btrfs subvolumes as independent filesystems to isolate application data for better security and granular management.

The Power of Targeted Mounting

When you create a Btrfs subvolume, it acts like a filesystem within a filesystem. While the entire Btrfs pool is mounted at the root level (usually /), you don't have to keep all your data in one big bucket. By mounting specific subvolumes to different directories, you can treat them as distinct entities.

This is highly beneficial for security and administration. For example, if you run a web server or a database, you can place their data in a dedicated subvolume and mount it to /var/www or /var/lib/mysql. This allows you to apply different mount options—like noatime for performance or nodev for security—specifically to those subvolumes without affecting the rest of your system.

How to Mount a Subvolume

To mount a subvolume, you use the standard mount command, but you must specify the subvolume path using the subvol flag.

Assume you have a subvolume named database_data inside your Btrfs pool located at /dev/sda1. You would mount it like this:

# Mounting a specific subvolume to a target directory
mount -o subvol=database_data /dev/sda1 /mnt/db_storage

If you prefer to mount by the subvolume's ID instead of its name (which is useful if you rename subvolumes often), you can use subvolid:

# Mounting using the unique Subvolume ID
mount -o subvolid=258 /dev/sda1 /mnt/db_storage

Why Bother?

By mounting subvolumes separately, you gain the ability to manage backups, quotas, and permissions for each service in isolation. If a service needs to be moved or restored from a snapshot, it is much easier to manage when it resides on its own mount point rather than being buried deep within your root filesystem. It effectively turns your monolithic storage pool into a flexible, modular architecture where each piece can be managed, tuned, and secured on its own terms.

Key Takeaway: Mounting subvolumes as distinct filesystems allows you to apply specialized security and performance settings to specific applications while keeping your storage architecture clean and modular.