Freenas

我應該如何從 FreeNAS 中刪除古老的檔案?

  • October 2, 2018

我從一位離開公司的同事那裡繼承了 FreeNAS 安裝。該安裝用於保存我們分佈在世界各地的許多 Web 伺服器的內部 rsync 備份。

FreeNAS 盒子中的儲存空間不足,我發現我們仍然有來自早在 2013 年就退役的伺服器的備份。我們不再需要這些舊檔案,所以我想刪除它們以釋放一些空間。

的初步結果df -h是:

...
raid-1                                283G    261G     22G    92%    /mnt/raid-1
raid-1/clone-auto-20140925.0800-2m    283G    261G     22G    92%    /mnt/raid-1/clone-auto-20140925.0800-2m
...

所以,在我的天真中,我只是刪除了舊的 rsync 快照,即rm -rf /mnt/raid-1/backups/old.server.1 /mnt/raid-1/backups/old.server.2. 之後,df -h現在看起來像:

...
raid-1                                266G    244G     22G    92%    /mnt/raid-1
raid-1/clone-auto-20140925.0800-2m    283G    261G     22G    92%    /mnt/raid-1/clone-auto-20140925.0800-2m
...

o_o

我已將問題縮小到我對 ZFS 缺乏了解。顯然,df不是我預期的傳統意義上的報告磁碟使用情況,也不是天真的刪除可以解決我的問題。

如果有人可以,我將不勝感激:

  1. 為我指明正確的方向,了解 FreeNAS 如何利用 ZFS,以便我理解它,並且
  2. 提供一些關於如何通過刪除那些古老備份的副本來釋放一些空間的指導。

編輯 1

我一直在閱讀,現在我明白由於 ZFS 的 CoW,空間沒有被釋放。

輸出zfs list

NAME                                 USED  AVAIL  REFER  MOUNTPOINT
raid-1                              1.76T  21.5G   245G  /mnt/raid-1
raid-1/clone-auto-20140925.0800-2m  34.8G  21.5G   261G  /mnt/raid-1/clone-auto-20140925.0800-2m

編輯 2

`zfs list -t 快照的輸出

NAME                                                       USED  AVAIL  REFER  MOUNTPOINT
raid-1@auto-20140925.0800-2m                              91.0G      -   261G  -
raid-1@auto-20150102.0800-2m                              9.13G      -   301G  -
raid-1@auto-20150103.0800-2m                              4.68G      -   301G  -
raid-1@auto-20150104.0800-2m                              4.70G      -   302G  -
raid-1@auto-20150105.0800-2m                              4.63G      -   302G  -
raid-1@auto-20150106.0800-2m                              15.5G      -   297G  -
raid-1@auto-20150107.0800-2m                              15.6G      -   297G  -
raid-1@auto-20150108.0800-2m                              15.7G      -   297G  -
raid-1@auto-20150109.0800-2m                              16.0G      -   297G  -
raid-1@auto-20150110.0800-2m                              15.9G      -   297G  -
raid-1@auto-20150111.0800-2m                              16.2G      -   298G  -
raid-1@auto-20150112.0800-2m                              15.2G      -   297G  -
raid-1@auto-20150113.0800-2m                              13.8G      -   297G  -
raid-1@auto-20150114.0800-2m                              14.1G      -   298G  -
raid-1@auto-20150115.0800-2m                              19.1G      -   298G  -
raid-1@auto-20150116.0800-2m                              19.3G      -   299G  -
raid-1@auto-20150117.0800-2m                              16.6G      -   299G  -
raid-1@auto-20150118.0800-2m                              16.7G      -   300G  -
raid-1@auto-20150119.0800-2m                              15.7G      -   299G  -
raid-1@auto-20150120.0800-2m                              16.3G      -   300G  -
raid-1@auto-20150121.0800-2m                              16.6G      -   300G  -
raid-1@auto-20150122.0800-2m                              19.5G      -   300G  -
raid-1@auto-20150123.0800-2m                              19.8G      -   299G  -
raid-1@auto-20150124.0800-2m                              17.4G      -   299G  -
raid-1@auto-20150125.0800-2m                              17.6G      -   300G  -
raid-1@auto-20150126.0800-2m                              16.4G      -   299G  -
raid-1@auto-20150127.0800-2m                              16.9G      -   300G  -
raid-1@auto-20150128.0800-2m                              17.5G      -   297G  -
raid-1@auto-20150129.0800-2m                              20.0G      -   297G  -
raid-1@auto-20150130.0800-2m                              20.2G      -   297G  -
raid-1@auto-20150131.0800-2m                              5.43G      -   297G  -
raid-1@auto-20150201.0800-2m                              5.46G      -   302G  -
raid-1@auto-20150202.0800-2m                              16.7G      -   307G  -
raid-1@auto-20150203.0800-2m                              16.8G      -   308G  -
raid-1@auto-20150204.0800-2m                              17.2G      -   309G  -
raid-1@auto-20150205.0800-2m                              20.5G      -   309G  -
raid-1@auto-20150206.0800-2m                              17.4G      -   309G  -
raid-1@auto-20150207.0800-2m                              17.7G      -   310G  -
raid-1@auto-20150208.0800-2m                              17.8G      -   311G  -
raid-1@auto-20150209.0800-2m                               575M      -   310G  -
raid-1@auto-20150210.0800-2m                               575M      -   310G  -
raid-1@auto-20150211.0800-2m                              20.9G      -   309G  -
raid-1@auto-20150212.0800-2m                              21.0G      -   309G  -
raid-1@auto-20150213.0800-2m                              20.6G      -   306G  -
raid-1@auto-20150214.0800-2m                              17.8G      -   306G  -
raid-1@auto-20150215.0800-2m                              18.1G      -   308G  -
raid-1@auto-20150216.0800-2m                               561M      -   307G  -
raid-1@auto-20150217.0800-2m                               561M      -   307G  -
raid-1@auto-20150218.0800-2m                              20.7G      -   308G  -
raid-1@auto-20150219.0800-2m                              21.3G      -   308G  -
raid-1@auto-20150220.0800-2m                              21.6G      -   308G  -
raid-1@auto-20150221.0800-2m                              18.9G      -   309G  -
raid-1@auto-20150222.0800-2m                              19.1G      -   310G  -
raid-1@auto-20150223.0800-2m                              18.0G      -   309G  -
raid-1@auto-20150224.0800-2m                              18.2G      -   309G  -
raid-1@auto-20150225.0800-2m                              18.6G      -   310G  -
raid-1@auto-20150226.0800-2m                              19.1G      -   310G  -
raid-1@auto-20150227.0800-2m                              22.1G      -   238G  -
raid-1@auto-20150228.0800-2m                              19.4G      -   238G  -
raid-1@auto-20150301.0800-2m                              12.2G      -   239G  -
raid-1@auto-20150302.0800-2m                               314M      -   245G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150102.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150103.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150104.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150105.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150106.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150107.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150108.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150109.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150110.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150111.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150112.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150113.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150114.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150115.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150116.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150117.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150118.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150119.0800-2m   584M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150120.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150121.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150122.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150123.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150124.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150125.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150126.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150127.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150128.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150129.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150130.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150131.0800-2m   584M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150201.0800-2m   584M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150202.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150203.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150204.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150205.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150206.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150207.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150208.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150209.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150210.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150211.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150212.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150213.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150214.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150215.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150216.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150217.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150218.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150219.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150220.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150221.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150222.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150223.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150224.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150225.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150226.0800-2m   584M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150227.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150228.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150301.0800-2m   585M      -   261G  -
raid-1/clone-auto-20140925.0800-2m@auto-20150302.0800-2m   584M      -   261G  -

看起來您正在定期拍攝 ZFS 數據集的快照。任何刪除的數據都將保留在快照中。要刪除快照,請執行 zfs destroy raid-1@[snapshotname] 有關快照的完整說明,請查看文件

如果你想一次刪除一堆快照,看看這個答案

這是我到目前為止使用的:

  1. zfs list- 辨識卷/數據集
  2. zfs list -H -t snapshot -o name -S creation -r volume/dataset | tail -10- 用你的資訊替換卷/數據集,尾部 XX 菜單列表 xx 老年人
  3. zfs list -H -t snapshot -o name -S creation -r volume/dataset | tail -10 | xargs -n 1 zfs  destroy- 再次,用你的替換卷/數據集。

引用自:https://serverfault.com/questions/672319