some related articles

Ubuntu 25.10 btrfs

Ubuntu 24.04 btrfs

Synology btrfs deduplication


some commands 

dupermove

# apt install duperemove
duperemove -r -d -h -v --hashfile=/storage/.dupe_hash /storage

jdupes

# apt install -y jdupes
jdupes --one-file-system --dedupe --recurse --size /storage/

compsize

# apt install -y btrfs-compsize
compsize -x /storage/

btrfs

#apt install -y btrfs-progs
btrfs filesystem df /storage/
btrfs filesystem du --summarize --human-readable  /storage/
btrfs filesystem show 
btrfs filesystem show /storage/
btrfs filesystem usage -T /storage/
btrfs device stats /storage/


btrfs filesystem defragment /storage/

btrfs scrub start /storage/
btrfs scrub status /storage/

btrfs device add -f /dev/nvme4n1p1 /storage/
btrfs device delete -f /dev/nvme4n1p1 /storage/

sudo mount -o degraded /dev/nvme3n1p /storage/
btrfs device delete missing  /storage/

btrfs subvolume create  
btrfs subvolume list  
btrfs subvolume snapshot  
btrfs subvolume delete  


btrfs fstab example

# NVMe btrfs RAID0
UUID=47679023-51c8-4242-9117-f4b6e76dd3b8 /storage btrfs defaults,compress,autodefrag 0 1


Add second disk to / btrfs

MOREFINE S800 single 8TB NVMe as / to be extended to RAID 0 8+8TB

btrfs device add /dev/nvme1n1p1 /
btrfs balance start -dconvert=raid0 -mconvert=raid1 /
root@server6:~# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
nvme1n1     259:0    0  7.3T  0 disk
├─nvme1n1p1 259:2    0    1G  0 part /boot/efi
└─nvme1n1p2 259:3    0  7.3T  0 part /
nvme0n1     259:1    0  7.3T  0 disk
├─nvme0n1p1 259:6    0    1G  0 part
└─nvme0n1p2 259:7    0  7.3T  0 part
root@server6:~# btrfs device add /dev/nvme0n1p2 /
Performing full device TRIM /dev/nvme0n1p2 (7.28TiB) ...

root@server6:~# btrfs filesystem show
Label: none  uuid: c049c467-2b8f-4906-93f6-c734486218f3
        Total devices 2 FS bytes used 5.95TiB
        devid    1 size 7.28TiB used 5.98TiB path /dev/nvme1n1p2
        devid    2 size 7.28TiB used 0.00B path /dev/nvme0n1p2

root@server6:~# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme1n1p2   15T  6.0T  8.6T  41% /

root@server6:~# btrfs balance start -dconvert=raid0 -mconvert=raid1 /


#after some time in the middle

root@server6:~# btrfs filesystem show
Label: none  uuid: c049c467-2b8f-4906-93f6-c734486218f3
        Total devices 2 FS bytes used 5.95TiB
        devid    1 size 7.28TiB used 5.98TiB path /dev/nvme1n1p2
        devid    2 size 7.28TiB used 940.03GiB path /dev/nvme0n1p2

#after 8 hours (that rebalans took) and some additional +1TB written.

root@server6:~# btrfs filesystem show
Label: none  uuid: c049c467-2b8f-4906-93f6-c734486218f3
        Total devices 2 FS bytes used 6.95TiB
        devid    1 size 7.28TiB used 3.48TiB path /dev/nvme1n1p2
        devid    2 size 7.28TiB used 3.48TiB path /dev/nvme0n1p2




swap file

btrfs sub create /swaps
chattr +C /swaps
cd /swaps
fallocate -l 32G swapfile.0
chmod 600 swapfile.0
mkswap  swapfile.0
swapon  swapfile.0

#
echo '/swaps/swapfile.0               none            swap            sw              0 0' >> /etc/fstab



3-rd party articles

https://wiki.tnonline.net/w/Btrfs/Adding_and_removing_devices

Some commands output examples

server 5 RAID 0 4 disk

root@server5:~# btrfs filesystem show
Label: none  uuid: 057e9267-a9c1-4a1f-96ae-2c00b08e5368
        Total devices 1 FS bytes used 6.49GiB
        devid    1 size 50.18GiB used 14.02GiB path /dev/mmcblk0p4

Label: 'storage'  uuid: 47679023-51c8-4242-9117-f4b6e76dd3b8
        Total devices 4 FS bytes used 8.23TiB
        devid    1 size 3.64TiB used 2.31TiB path /dev/nvme2n1p1
        devid    2 size 3.64TiB used 2.31TiB path /dev/nvme0n1p1
        devid    3 size 3.64TiB used 2.31TiB path /dev/nvme1n1p1
        devid    4 size 3.64TiB used 2.31TiB path /dev/nvme3n1p1

root@server5:~# btrfs filesystem usage -T /storage/
Overall:
    Device size:                  14.55TiB
    Device allocated:              9.23TiB
    Device unallocated:            5.32TiB
    Device missing:                  0.00B
    Device slack:                 14.00KiB
    Used:                          8.24TiB
    Free (estimated):              6.31TiB      (min: 3.65TiB)
    Free (statfs, df):             6.31TiB
    Data ratio:                       1.00
    Metadata ratio:                   2.00
    Global reserve:              512.00MiB      (used: 0.00B)
    Multiple profiles:                  no

                  Data    Metadata System
Id Path           RAID0   RAID1    RAID1     Unallocated Total    Slack
-- -------------- ------- -------- --------- ----------- -------- --------
 1 /dev/nvme2n1p1 2.30TiB  7.00GiB         -     1.33TiB  3.64TiB  3.50KiB
 2 /dev/nvme0n1p1 2.30TiB  7.00GiB         -     1.33TiB  3.64TiB  3.50KiB
 3 /dev/nvme1n1p1 2.30TiB  6.00GiB   8.00MiB     1.33TiB  3.64TiB  3.50KiB
 4 /dev/nvme3n1p1 2.30TiB  6.00GiB   8.00MiB     1.33TiB  3.64TiB  3.50KiB
-- -------------- ------- -------- --------- ----------- -------- --------
   Total          9.21TiB 13.00GiB   8.00MiB     5.32TiB 14.55TiB 14.00KiB
   Used           8.22TiB 11.52GiB 560.00KiB

root@server5:~# compsize -x /storage/
Processed 2625615 files, 4148967 regular extents (4468988 refs), 511639 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL       99%      8.2T         8.2T         9.7T
none       100%      8.2T         8.2T         9.7T
zlib        34%       17G          51G          54G
prealloc   100%      215M         215M         388M


root@server5:~# btrfs filesystem df /
Data, single: total=12.01GiB, used=6.34GiB
System, DUP: total=8.00MiB, used=16.00KiB
Metadata, DUP: total=1.00GiB, used=156.17MiB
GlobalReserve, single: total=23.20MiB, used=0.00B

root@server5:~# btrfs filesystem du --summarize --human-readable  /storage/
     Total   Exclusive  Set shared  Filename
   9.79TiB     6.83TiB     1.42TiB  /storage/

root@server5:~# btrfs device stats /storage/
[/dev/nvme2n1p1].write_io_errs    0
[/dev/nvme2n1p1].read_io_errs     0
[/dev/nvme2n1p1].flush_io_errs    0
[/dev/nvme2n1p1].corruption_errs  0
[/dev/nvme2n1p1].generation_errs  0
[/dev/nvme0n1p1].write_io_errs    0
[/dev/nvme0n1p1].read_io_errs     0
[/dev/nvme0n1p1].flush_io_errs    0
[/dev/nvme0n1p1].corruption_errs  0
[/dev/nvme0n1p1].generation_errs  0
[/dev/nvme1n1p1].write_io_errs    0
[/dev/nvme1n1p1].read_io_errs     0
[/dev/nvme1n1p1].flush_io_errs    0
[/dev/nvme1n1p1].corruption_errs  0
[/dev/nvme1n1p1].generation_errs  0
[/dev/nvme3n1p1].write_io_errs    0
[/dev/nvme3n1p1].read_io_errs     0
[/dev/nvme3n1p1].flush_io_errs    0
[/dev/nvme3n1p1].corruption_errs  0
[/dev/nvme3n1p1].generation_errs  0


server 6 single disk

root@server6:~#  btrfs filesystem show
Label: none  uuid: c049c467-2b8f-4906-93f6-c734486218f3
        Total devices 1 FS bytes used 5.95TiB
        devid    1 size 7.28TiB used 5.98TiB path /dev/nvme0n1p2








root@server6:~# btrfs filesystem usage -T /
Overall:
    Device size:                   7.28TiB
    Device allocated:              5.98TiB
    Device unallocated:            1.29TiB
    Device missing:                  0.00B
    Device slack:                    0.00B
    Used:                          5.95TiB
    Free (estimated):              1.32TiB      (min: 687.27GiB)
    Free (statfs, df):             1.32TiB
    Data ratio:                       1.00
    Metadata ratio:                   2.00
    Global reserve:              512.00MiB      (used: 0.00B)
    Multiple profiles:                  no

                  Data    Metadata System
Id Path           single  DUP      DUP       Unallocated Total   Slack
-- -------------- ------- -------- --------- ----------- ------- -----
 1 /dev/nvme0n1p2 5.96TiB 18.00GiB  16.00MiB     1.29TiB 7.28TiB     -
-- -------------- ------- -------- --------- ----------- ------- -----
   Total          5.96TiB  9.00GiB   8.00MiB     1.29TiB 7.28TiB 0.00B
   Used           5.94TiB  7.80GiB 656.00KiB




root@server6:~# compsize -x /
Processed 1709606 files, 3069159 regular extents (3145120 refs), 259765 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL       99%      5.9T         5.9T         5.9T
none       100%      5.9T         5.9T         5.9T
zlib        32%       12G          37G          40G
prealloc   100%      2.0M         2.0M          13M


root@server6:~# btrfs filesystem df /
Data, single: total=5.96TiB, used=5.94TiB
System, DUP: total=8.00MiB, used=656.00KiB
Metadata, DUP: total=9.00GiB, used=7.80GiB
GlobalReserve, single: total=512.00MiB, used=0.00B

root@server6:~# btrfs filesystem du --summarize --human-readable  /
     Total   Exclusive  Set shared  Filename
   5.97TiB     5.96TiB     4.62GiB  /

root@server6:~# btrfs device stats /
[/dev/nvme0n1p2].write_io_errs    0
[/dev/nvme0n1p2].read_io_errs     0
[/dev/nvme0n1p2].flush_io_errs    0
[/dev/nvme0n1p2].corruption_errs  0
[/dev/nvme0n1p2].generation_errs  0