btrfs doesn't use the entire parition size

I’m getting a No space left on device error on my btrfs filesystem for my root partition. Unlike most issues that people have, this seems to stem from the fact that btrfs isn’t using the entire space left by the filesystem.


sudo btrfs filesystem show
Label: none  uuid: 8f89fba4-d877-4814-b5c8-e2e5c2942c6b
        Total devices 1 FS bytes used 14.09GiB
        devid    1 size 20.00GiB used 16.28GiB path /dev/sda1

As you can see the size is 20g, but it is using only 16g and My root takes up 14g. Is there away to for btrfs to claim the entire 20g?

Thanks

Have you turned off snapper? Snapper uses space to save the FS state often. 20 gig is not enough for BTRFS with snapper running min recommended is 40 gig

Hi
No, it needs space for snapshots (if snapper running), else turn off snapper and delete snapshots from latest backwards, then run the btrfs-balance cronjob manually down in /etc/cron.weekly.

A better check is;


btrfs fi usage

Thanks for the replies. I uninstalled snapper and ran the filesystem balance. However it seems like my unallocated space is even bigger now.


sudo btrfs fi usage /     
Overall:
    Device size:                  20.00GiB
    Device allocated:             15.76GiB
    Device unallocated:            4.24GiB
    Device missing:                  0.00B
    Used:                         14.63GiB
    Free (estimated):              4.75GiB      (min: 4.75GiB)
    Data ratio:                       1.00
    Metadata ratio:                   1.00
    Global reserve:              240.00MiB      (used: 0.00B)

Data,single: Size:14.48GiB, Used:13.97GiB
   /dev/sda1      14.48GiB

Metadata,single: Size:1.25GiB, Used:676.95MiB
   /dev/sda1       1.25GiB

System,single: Size:32.00MiB, Used:16.00KiB
   /dev/sda1      32.00MiB

Unallocated:
   /dev/sda1       4.24GiB

also I don’t have a btrfs balance cron job, is there a way to install it?

thanks

Hi
If the btrfsmaintenance package is installed, then it’s /usr/share/btrfsmaintenance/btrfs-balance.sh which (well on Leap) is softlinked in /etc/cron.weekly.


ls -la /etc/cron.weekly/btrfs-balance.sh
lrwxrwxrwx 1 root root 44 Oct 29 15:35 /etc/cron.weekly/btrfs-balance.sh -> /usr/share/btrfsmaintenance/btrfs-balance.sh

You may need to run it a few times to clean things up.

Also see;

https://btrfs.wiki.kernel.org/index.php/Problem_FAQ

  
  • 14.09 is the used (data and metadata extents) amount, it should be close to df -h.

  • 20.00 is the (block) device size, i.e. the partition size

  • 16.28 is the amount allocated to all chunk (block group) types

    The chunk is a contiguous range of space, for one of three chunk types: data, metadata, or system. The amount allocated at a time depends on the device size, typically it’s 256MiB for metadata and 1GiB for data chunks. The amount unused can be allocated into either chunk type on demand. So there’s nothing wrong here and there’s nothing you need to do about it.

Cron job is installed by service; and this service is disabled by default. See http://lists.opensuse.org/opensuse-factory/2016-01/msg00407.html