2

Good afternoon!

I was in the process of writing files via rsync and had enough free disk space, but I am using btrfs and btrfs shows that the free space has run out. Can you please tell me how to deal with this situation? I deleted unnecessary files, but it didn't help.

Can you please tell me how to make the system work again? Judging by the output of the du utility, I should still have about 150 GB.

Additional info:

❯ df -h | grep "sda"
/dev/sda4          515G         513G  5,6M          100% /
/dev/sda4          515G         513G  5,6M          100% /var/log
/dev/sda4          515G         513G  5,6M          100% /home
/dev/sda4          515G         513G  5,6M          100% /var/cache
/dev/sda1          996M         1,5M  995M            1% /boot/efi

❯ mount | egrep "sda"
/dev/sda4 on / type btrfs (rw,noatime,compress=zstd:3,space_cache,autodefrag,subvolid=815,subvol=/@)
/dev/sda4 on /var/log type btrfs (rw,noatime,compress=zstd:3,space_cache,autodefrag,subvolid=260,subvol=/@log)
/dev/sda4 on /home type btrfs (rw,noatime,compress=zstd:3,space_cache,autodefrag,subvolid=814,subvol=/@home)
/dev/sda4 on /var/cache type btrfs (rw,noatime,compress=zstd:3,space_cache,autodefrag,subvolid=259,subvol=/@cache)
/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)

[root@localhost]# du -sh / 2> /dev/null
346G    /

[root@localhost]# btrfs fi df /
Data, single: total=506.52GiB, used=506.51GiB
System, DUP: total=8.00MiB, used=80.00KiB
Metadata, DUP: total=4.00GiB, used=2.71GiB
GlobalReserve, single: total=512.00MiB, used=0.00B

[root@localhost]# btrfs fi usage /
Overall:
    Device size:         514.53GiB
    Device allocated:        514.53GiB
    Device unallocated:        1.03MiB
    Device missing:          0.00B
    Used:            511.92GiB
    Free (estimated):          5.31MiB  (min: 5.31MiB)
    Free (statfs, df):         5.31MiB
    Data ratio:               1.00
    Metadata ratio:           2.00
    Global reserve:      512.00MiB  (used: 0.00B)
    Multiple profiles:              no

Data,single: Size:506.52GiB, Used:506.51GiB (100.00%)
   /dev/sda4     506.52GiB

Metadata,DUP: Size:4.00GiB, Used:2.71GiB (67.64%)
   /dev/sda4       8.00GiB

System,DUP: Size:8.00MiB, Used:80.00KiB (0.98%)
   /dev/sda4      16.00MiB

Unallocated:
   /dev/sda4       1.03MiB

Update:

[root@localhost]# echo "     Total   Exclusive  Set shared  Filename"; find . -maxdepth 1 -type d | grep './' | xargs -I{} btrfs filesystem du -s {} 2> /dev/null | grep -v 'Total'
     Total   Exclusive  Set shared  Filename
 266.01GiB    67.92GiB   189.58GiB  ./home
  64.89GiB     7.96GiB    56.93GiB  ./var
 111.59MiB    34.20MiB    77.39MiB  ./boot
   6.76MiB     2.52MiB     3.79MiB  ./etc
     0.00B       0.00B       0.00B  ./mnt
   1.06GiB   113.59MiB   582.69MiB  ./opt
     0.00B       0.00B       0.00B  ./srv
   8.77GiB     5.28GiB     2.34GiB  ./usr

[root@localhost]# btrfs subvolume list -t --sort=path /
ID  gen top level   path    
--  --- ---------   ----    
815 235310  5       @
259 235014  5       @cache
814 235315  5       @home
260 235315  5       @log
450 233611  5       timeshift-btrfs/snapshots/2021-10-18_19-59-20/@
451 5639    5       timeshift-btrfs/snapshots/2021-10-18_19-59-20/@home
536 233611  5       timeshift-btrfs/snapshots/2021-11-23_22-48-30/@
537 13984   5       timeshift-btrfs/snapshots/2021-11-23_22-48-30/@home
545 233611  5       timeshift-btrfs/snapshots/2021-12-12_18-12-40/@
546 17778   5       timeshift-btrfs/snapshots/2021-12-12_18-12-40/@home
257 233611  5       timeshift-btrfs/snapshots/2022-05-02_13-10-31/@
258 229392  5       timeshift-btrfs/snapshots/2022-05-02_13-10-31/@home
894 233611  5       timeshift-btrfs/snapshots/2022-06-08_20-38-08/@
895 215821  5       timeshift-btrfs/snapshots/2022-06-08_20-38-08/@home
896 233611  5       timeshift-btrfs/snapshots/2022-06-08_21-09-00/@
897 215918  5       timeshift-btrfs/snapshots/2022-06-08_21-09-00/@home
923 233611  5       timeshift-btrfs/snapshots/2022-06-28_19-06-50/@
924 229388  5       timeshift-btrfs/snapshots/2022-06-28_19-06-50/@home

[root@localhost]# timeshift --list
Mounted '/dev/sda4' at '/run/timeshift/3351/backup'
Device : /dev/sda4
UUID   : d0a8bc03-a8d9-470e-8868-ec49b1d4f9dc
Path   : /run/timeshift/3351/backup
Mode   : BTRFS
Status : OK
7 snapshots, 2.3 GB free

Num     Name                 Tags  Description    
------------------------------------------------------------------------------
0    >  2021-10-18_19-59-20  O     {timeshift-autosnap} {created before upgrade}     
1    >  2021-11-23_22-48-30  O     {timeshift-autosnap} {created before upgrade}
2    >  2021-12-12_18-12-40  O     {timeshift-autosnap} {created before upgrade}
3    >  2022-05-02_13-10-31  O     {timeshift-autosnap} {created before upgrade}
4    >  2022-06-08_20-38-08  O     {timeshift-autosnap} {created before upgrade}    
5    >  2022-06-08_21-09-00  O     {timeshift-autosnap} {created before upgrade}    
6    >  2022-06-28_19-06-50  O     {timeshift-autosnap} {created before upgrade}    


Found stale mount for device '/dev/sda4' at path '/run/timeshift/3351/backup'
Unmounted successfully

Update 07/17/22:

enter image description here

[root@localhost]# btrfs filesystem du -s / 2> /dev/null
     Total   Exclusive  Set shared  Filename
 340.59GiB    81.30GiB   249.14GiB  /

How do I know what the 511.92GiB is made up of?

[root@localhost]# btrfs fi usage /
Overall:
    Device size:         514.53GiB
    Device allocated:        514.53GiB
    Device unallocated:        1.03MiB
    Device missing:          0.00B
    Used:            511.92GiB

EDIT 7/23/22:

I deleted some timeshift snapshots, the used disk space decreased, now it shows the following data:

% # df -h | grep '/dev/s'
/dev/sda4          515G         393G  118G           77% /
tmpfs              7,8G          22M  7,8G            1% /dev/shm
/dev/sda4          515G         393G  118G           77% /var/cache
/dev/sda4          515G         393G  118G           77% /var/log
/dev/sda4          515G         393G  118G           77% /home
/dev/sda1          996M         1,5M  995M            1% /boot/efi
/dev/sda4          515G         393G  118G           77% /mnt/sda4

% btrfs filesystem df -h /
Data, single: total=439.01GiB, used=388.90GiB
System, DUP: total=8.00MiB, used=80.00KiB
Metadata, DUP: total=4.00GiB, used=1.49GiB
GlobalReserve, single: total=512.00MiB, used=0.00B

% mkdir /mnt/sda4 && mount -o subvol=/ /dev/sda4 /mnt/sda4 && btdu /mnt/sda4
--- /<SINGLE>/<DATA> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  ~572.9 KiB [          ]  <NO_INODE>
  ~111.2 MiB [          ] /<ROOT_TREE>
   ~50.1 GiB [#         ]  <SLACK>
   ~18.4 GiB [          ] /<UNREACHABLE>
   ~62.7 GiB [##        ] /@
   ~6.26 GiB [          ] /@cache
  ~284.5 GiB [##########] /@home
  ~480.8 MiB [          ] /@log
   ~16.4 GiB [          ] /timeshift-btrfs

--- Details: ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Full path: /mnt/sda4
- Average query duration: 0.0003639 seconds
- Represented size: ~439.0 GiB (68296505 samples), ±10.1 MiB
- Logical offsets: ..., 485646549606, 442831113925, 525544520914

--- Explanation:
This node holds samples from chunks in the DATA block group, which mostly contains file data.

In general, deleting some of the snapshots helped, after that the timeshift showed a display of busy disk space. A screenshot is attached: enter image description here

Unfortunately, btdu did not answer the question of what makes up the 388 Gb of occupied disk space, as in the conclusion attached above:

--- /<SINGLE>/<DATA> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  ~572.9 KiB [          ]  <NO_INODE>
  ~111.2 MiB [          ] /<ROOT_TREE>
   ~50.1 GiB [#         ]  <SLACK>
   ~18.4 GiB [          ] /<UNREACHABLE>
   ~62.7 GiB [##        ] /@
   ~6.26 GiB [          ] /@cache
  ~284.5 GiB [##########] /@home
  ~480.8 MiB [          ] /@log
   ~16.4 GiB [          ] /timeshift-btrfs

--- Details: ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Full path: /mnt/sda4
- Average query duration: 0.0003639 seconds
- Represented size: ~439.0 GiB (68296505 samples), ±10.1 MiB
- Logical offsets: ..., 485646549606, 442831113925, 525544520914

% echo "62.7+6.26+284.5+0.48+16.4"|bc
370.34

Maybe the problem is that btdu gives approximate results? I didn't wait for the program to finish it ran for a few minutes.

somethingSomething
  • 5,721
  • 18
  • 58
  • 98
uji432
  • 21
  • 3
  • [Why are there so many different ways to measure disk usage?](https://unix.stackexchange.com/q/120311/108618) – Kamil Maciorowski Jul 15 '22 at 11:31
  • As I understand it, the utilities du and df do not take into account all the disk space used for a particular file system. To figure out what is taking up the most disk space, you need to use btrfs-specific tools. Is there any way to tell which data is taking up the most disk space in btrfs and to sort that data? – uji432 Jul 15 '22 at 11:52
  • `man 8 btrfs-filesystem`, there are `du` and `df` subcommands there with useful options. An example command `btrfs filesystem du -s *`. Note you want to consider the whole filesystem (see [this answer](https://superuser.com/a/1396270/432690)). – Kamil Maciorowski Jul 15 '22 at 12:04
  • Are you running any snapshot program, such as **timeshift** or **snapper**? What does `btrfs subvolume list -t --sort=path /` return? – ajgringo619 Jul 15 '22 at 17:14
  • Hello! Yes, I use **timeshift** to create snapshots, but I don't know how to see how much disk quota they take up. I added the output of the command to the original question. – uji432 Jul 16 '22 at 12:32
  • The `timeshift` gui should show you how much exclusive data each of its snapshots are using. – ajgringo619 Jul 17 '22 at 05:08
  • On my device, the Timeshift GUI does not show the disk space occupied by snapshots. I attached a screenshot to the original question. – uji432 Jul 17 '22 at 11:25
  • Haven't used `timeshift` in a while; it used to show the exclusive data. You may have to remove some of the older snapshots, but I'd make a complete system backup first. – ajgringo619 Jul 17 '22 at 17:17
  • You seem to have some slack in your filesystem. Use `btrfs filesystem resize max` to get it back. You also seem to have quite a bit of "unused" space which are extents that were partially overwritten. This can be solved by defragmenting files that get overwritten in-place such as databases. I'm not sure what confusion is left because your calculated 370GiB + 18GiB unreachable are the 388GiB `btrfs filesystem df` reports as used. – Atemu Aug 29 '23 at 10:56

1 Answers1

2

btdu is a useful tool which shows where your btrfs space is used visually:

--- /RAID0/DATA -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    ~1.5 GiB [          ] /<ERROR>
   ~20.7 MiB [          ] /<UNREACHABLE>
   ~76.4 GiB [          ] /Something
    ~1.0 TiB [##        ] /Something else
  ~273.9 GiB [          ] /Nothing
  ~154.9 MiB [          ] /Private
    ~4.7 TiB [##########] /Linux ISOs
  ~173.9 GiB [          ] /Snapshots                                                                                                                                                                                   
   ~31.8 GiB [          ] /tmp

--- Details: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Full path: /mnt/data
- Average query duration: 0.0004393 seconds
- Represented size: ~6.3 TiB (1929378 samples), ±539.9 MiB
- Logical offsets: ..., 5037530244057, 1797729456912, 5371666300696

--- Explanation:
This node holds samples from chunks in the DATA block group, which mostly contains file data.

Your space is likely used in those snapshots. Delete a few older ones to free up the space of the files you deleted since.

Atemu
  • 584
  • 4
  • 14