如何显示btrfs快照大小

如何显示btrfs快照大小

我在某些 btrfs 卷上有相当多的快照,我想知道每个快照占用多少空间,这样我就知道何时以及是否有重要的更改。

sudo btrfs subvolume show /home/
/
Name:           <FS_TREE>
UUID:           -
Parent UUID:        -
Received UUID:      -
Creation time:      -
Subvolume ID:       5
Generation:         1181373
Gen at creation:    0
Parent ID:      0
Top level ID:       0
Flags:          -
Snapshot(s):
            .snapshot/_0
            .snapshot/_1
            .snapshot/_2
            .snapshot/_3
            .snapshot/_4
            ...

但如果我使用du 它们会报告整个空间

du -sh /home/.snapshot/*
1,2T    /home/.snapshot/_0
1,2T    /home/.snapshot/_1
1,2T    /home/.snapshot/_2

有没有办法发现 _1 和 _2 之间在空间上存在哪些差异

编辑:注意:我一直在使用Btrfs 列表成功简单地显示快照大小

答案1

如果您有大量备份,则不建议启用配额。

相反,您可以使用btrfs filesystem du -s命令:

# btrfs filesystem du -s @snapshot*
     Total   Exclusive  Set shared  Filename
  17.98GiB    13.05GiB     4.93GiB  @snapshot_system_2022-01-22d
  17.91GiB     2.66GiB    15.25GiB  @snapshot_system_2023-01-22w
  18.09GiB     2.08GiB    16.01GiB  @snapshot_system_2023-01-29w
  16.90GiB     2.05GiB    14.85GiB  @snapshot_system_2023-02-05w
  18.23GiB     1.96GiB    16.27GiB  @snapshot_system_2023-02-12w
  18.81GiB     2.07GiB    16.74GiB  @snapshot_system_2023-02-19w
  21.59GiB     4.90GiB    16.69GiB  @snapshot_system_2023-02-26w
  22.38GiB   172.61MiB    22.21GiB  @snapshot_system_2023-03-18d

请参阅man btrfs-filesystemBTRFS 文档

答案2

为了显示 BTRFS 子卷的使用数据,您必须首先启用配额,如下所示:

sudo btrfs quota enable /home

然后,您可以运行诸如sudo btrfs subvol show /home/.snapshots/your_snapshot和 获取使用情况统计信息之类的命令。这是一个例子:

    sudo btrfs subvol show /.snapshots/1076/snapshot/
@/.snapshots/1076/snapshot
    Name:           snapshot
    UUID:           3ba9ffa0-a355-d544-be10-1b1d0a3a321e
    Parent UUID:        5c0c4206-9b15-074f-83c3-65861366e318
    Received UUID:      -
    Creation time:      2022-02-01 00:00:09 -0800
    Subvolume ID:       1445
    Generation:         66371
    Gen at creation:    66370
    Parent ID:      275
    Top level ID:       275
    Flags:          readonly
    Send transid:       0
    Send time:      2022-02-01 00:00:09 -0800
    Receive transid:    0
    Receive time:       -
    Snapshot(s):
    Quota group:        0/1445
      Limit referenced: -
      Limit exclusive:  -
      Usage referenced: 13.92GiB
      Usage exclusive:  8.25GiB

相关内容