• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Check Btrfs FileSystem Usage and Perform Balancing

by admin

In Btrfs file system there are chunks that are allocated for regular data, metadata. There are also chunks that are allocated to store file system information and also about where other chunks are located on the physical disk. Those chunks can only store the data. Very occasionally, a chunk type may fill up and start to run out of space. However, there may (and often is) still space available in other chunks. Therefore, some space needs to be freed up on it.

There is a balancing feature available in Btrfs FileSystem. The balance operation effectively frees up space in the other chunks to make it available for allocation.

1. Below command shows how much space has been allocated on your filesystem:

# btrfs fi show

2. Below command shows the file usage:

# btrfs filesystem du /btr

3. Complete filesystem usage by data and metadata( Before Balance):

# btrfs filesystem usage /btr

The below command is used for balance and this command does the full balance without filters requested. This operation is very intense and takes potentially very long. It is recommended to use the balance filters to narrow down the balanced data.

[Without Filter]

# btrfs filesystem balance /btr

[With Filter(use dusage and musage)]

# btrfs filesystem balance start -dusage=5 /btr

Note that there should be no space between the -d and usage. This command will attempt to relocate data in empty or near-empty data chunks (at most 5% used, in this example), allowing the space to be reclaimed and reassigned to metadata.

If the balance command ends with “Done, had to relocate 0 out of XX chunks“, then you need to increase the “dusage” percentage parameter till at least one chunk is relocated. If you don’t use the filters then it balances both data and metadata.

Another way for balancing the btrfs filesystem through script

for i in 0 5 10 15 20 25 30 40 50 60 70 80 90 100
do
	echo "${0}: Running with ${i}%"
	sudo btrfs balance start -dusage=$i -musage=$i /btr/
done

After balance check through below command:

# btrfs filesystem usage /btr

Depending on ‘btrfs filesystem du’ and ‘btrfs filesystem usage’ decide the values for -dusage and -musage.

Filed Under: Linux

Some more articles you might also be interested in …

  1. pacman –deptest Command Examples
  2. fallocate Command Examples in Linux
  3. ssh-add: command not found
  4. git help: Display help information about Git
  5. feroxbuster: Simple, fast, recursive content discovery tool written in Rust
  6. kubeadm Command Examples
  7. beep Command Examples in Linux
  8. pvck Command Examples in Linux
  9. macof: command not found
  10. ln Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples
  • mitmproxy Command Examples

© 2024 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright