• 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. Configuring Remote Logging using rsyslog in CentOS/RHEL
  2. CentOS / RHEL 6,7 : How to delete an iSCSI Target on the initiator (iSCSI client)
  3. aptitude: command not found
  4. atrm Command Examples in Linux
  5. 12 RPM (Red Hat Package Manager) Command Examples
  6. CentOS / RHEL 7 : How to enable or disable automatic updates (via packagekit)
  7. clamdscan: A command-line virus scanner using the ClamAV Daemon
  8. aurman Command Examples
  9. CentOS / RHEL : How to remove unused Physical Volume(PV) from Volume Group (VG) in LVM
  10. How to Change or Rename a Mount Point in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • ctags: Generates an index (or tag) file of language objects found in source files for many popular programming languages
  • csvtool: Utility to filter and extract data from CSV formatted sources
  • csvstat: Print descriptive statistics for all columns in a CSV file
  • csvsql: Generate SQL statements for a CSV file or execute those statements directly on a database

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright