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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. How to disable lvmetad in CentOS/RHEL
  2. Beginners Guide to “journalctl” – How To Use Journalctl to View and Manipulate Systemd Logs
  3. How to disable NetworkManager on CentOS / RHEL 7
  4. s2i: command not found
  5. create_ap: command not found
  6. ceph Command Examples in Linux
  7. How to Add Network Printer via Command Line in CentOS/RHEL
  8. How to enable core dump for Applications on CentOS/RHEL
  9. coredumpctl: command not found
  10. cpio Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright