How to Create and Manage Btrfs File System in Linux

Step 2: Adding Devices to Btrfs Filesystem

12. Now we need to extend the mount point size /mnt/tecmint_btrfs1/ for this, we don’t have to extent the logical volume, instead we can add the device to mount point, it will extend the size of file-system.

# btrfs device add /dev/tecmint_vg/tecmint_lv2 /mnt/tecmint_btrfs1/

13. After adding device to btrfs filesytem, now verify the mount point size using ‘df -h‘ command.

# df -h
Add Device to Btrfs

Add Device to Btrfs

14. Now, check the status of the added device.

# btrfs device stats /mnt/tecmint_btrfs1/
Verify Device Status

Verify Device Status

If in-case, you want to remove the logical volume tecmint_lv2 from mount point, you can use the below commands.

# btrfs device delete /dev/tecmint_vg/tecmint_lv2 /mnt/tecmint_btrfs1/
# df -h
Remove LVM Device

Remove LVM Device

Useful Available options in Btrfs

a. To check the disk usage of mount point.

# btrfs filesystem df /mnt/tecmint_btrfs1/
Check Disk Usage

Check Disk Usage

b. To list the btrfs file-system with more information’s. Mounted and unmounted using –all-devices.

# btrfs filesystem show --mounted

Instead of using –mounted we can list every devices using –all-devices.

List Btrfs Filesystems

List Btrfs Filesystems

c. To force a sync for the file-system identified by path {/mnt/tecmint_btrfs1/}.

# btrfs filesystem sync /mnt/tecmint_btrfs1/
Sync Btrfs Filesystems

Sync Btrfs Filesystems

d. To defragment the files and directory metadata.

# btrfs filesystem defragment -v -r /mnt/tecmint_btrfs1/
  1. -r = recursively defragment through directories.
  2. -v = verbose.
  3. -c = to compress the file contents while defragmenting.

c. Checking file-system using btrfsck command to check the btrfs file-system.

# btrfsck /dev/tecmint_vg/tecmint_lv1
Scan Btrfs Filesystems

Scan Btrfs Filesystems

Step 3: Creating Btrfs Subvolumes

Btrfs subvolume are not a block devices, but it will behaves like block devices, not like LVM, ZFS volumes. Subvolumes are thought as a POSIX file namespace, These namespace can be accessed via the top level subvolume of the file-system by b-tree structure that contains directories.

Can create multiple subvolumes inside each subvolumes and we can mount the subvolume using it’s ID without mounting it’s parent subvolumes. We can create, delete the subvolume using simple commands.

Snapshots: This to Create a writeable/readonly snapshot of the subvolume, Snapshots to create the copy of writes but here it will not make copies of files instead it will shared the metadata and data’s of original subvolumes. We can create snapshot by read-only and writeable.

15. Before creating subvolume list if any subvolume existing.

# btrfs subvolume list /mnt/tecmint_btrfs1/

16. To create subvolume we can use the below command. Here i have created two subvolumes.

# btrfs subvolume create /mnt/tecmint_btrfs1/subvol1
# btrfs subvolume create /mnt/tecmint_btrfs1/subvol2

17. Now list and check for the newly created subvolumes.

# btrfs subvolume list /mnt/tecmint_btrfs1/
Create Btrfs Subvolume

Create Btrfs Subvolume

18. Then navigate to mount point /mnt/tecmint_btrfs1/ and list to see the newly created subvolumes what we have created in above steps.

# cd /mnt/tecmint_btrfs1/subvol1/

Copy some of the random files from /etc/ to subvol1.

# cp /etc/[abcde]* .
Verify Btrfs Subvolumes

Verify Btrfs Subvolumes

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Babin Lonston

I'm Working as a System Administrator for last 10 year's with 4 years experience with Linux Distributions, fall in love with text based operating systems.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

2 Responses

  1. Mike says:

    aaahh… why would you ever want to put btrfs on top of lvm2 instead of just using btrfs?

  2. puppet says:

    you do know that btrfs is inherently a volume manager as well (just like ZFS), so there is absolutely no need for lvm here

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.