sjt003
sjt003

Reputation: 2607

How do ZFS snapshots use space in practice?

  1. Created a snapshot
  2. Deleted a huge file
  3. Delta is still 0 (snapshot not using anymore space) in zfs list for past three snapshots

Should the delta or used space not be the size of the deleted file. I know ZFS is COW but I'm confused as to why I can't rollback the /usr/home/xxxx child

# ls /home/xxxxx/testing12345.txt 
/home/xxxxx/testing12345.txt
# ls -alh /home/xxxxx/testing12345.txt                                                                                                                                 
-rw-r--r--  1 root  xxxxx   254M Aug 28 00:06 /home/xxxxx/testing12345.txt
# zfs list -rt snapshot tank1/usr/home/xxxxx
NAME                                        USED  AVAIL  REFER  MOUNTPOINT
tank1/usr/home/xxxxx@myRecursiveSnapshot   291M      -   804M  -
tank1/usr/home/xxxxx@devEnv                 71K      -  1.39G  -
tank1/usr/home/xxxxx@xfce                     0      -  1.39G  -
tank1/usr/home/xxxxx@testhome                 0      -  1.39G  -
tank1/usr/home/xxxxx@testagain               1K      -  1.39G  -
tank1/usr/home/xxxxx@27082015                 0      -  1.39G  -
tank1/usr/home/xxxxx@270820150                0      -  1.39G  -
tank1/usr/home/xxxxx@2708201501               0      -  1.39G  -
# 
# 
# 
# 
# zfs snapshot -r tank1@28082015                                                                                                                                        
# zfs list -rt snapshot tank1/usr/home/xxxxx                                                                                                                           
NAME                                        USED  AVAIL  REFER  MOUNTPOINT
tank1/usr/home/xxxxx@myRecursiveSnapshot   291M      -   804M  -
tank1/usr/home/xxxxx@devEnv                 71K      -  1.39G  -
tank1/usr/home/xxxxx@xfce                     0      -  1.39G  -
tank1/usr/home/xxxxx@testhome                 0      -  1.39G  -
tank1/usr/home/xxxxx@testagain               1K      -  1.39G  -
tank1/usr/home/xxxxx@27082015                 0      -  1.39G  -
tank1/usr/home/xxxxx@270820150                0      -  1.39G  -
tank1/usr/home/xxxxx@2708201501               0      -  1.39G  -
tank1/usr/home/xxxxx@28082015                 0      -  1.39G  -
# rm /home/xxxxx/testing12345.txt                                                                                                                                      
# zfs list -rt snapshot tank1/usr/home/xxxxx                                                                                                                           
NAME                                        USED  AVAIL  REFER  MOUNTPOINT
tank1/usr/home/xxxxx@myRecursiveSnapshot   291M      -   804M  -
tank1/usr/home/xxxxx@devEnv                 71K      -  1.39G  -
tank1/usr/home/xxxxx@xfce                     0      -  1.39G  -
tank1/usr/home/xxxxx@testhome                 0      -  1.39G  -
tank1/usr/home/xxxxx@testagain               1K      -  1.39G  -
tank1/usr/home/xxxxx@27082015                 0      -  1.39G  -
tank1/usr/home/xxxxx@270820150                0      -  1.39G  -
tank1/usr/home/xxxxx@2708201501               0      -  1.39G  -
tank1/usr/home/xxxxx@28082015                 0      -  1.39G  -
# 

I've been tried rolling back using various snapshots the /usr, /usr/home, and /usr/home/xxxx directories. I've read the FreeBSD forums, the handbook, and I've also tried rolling back just tank1@[snapshot name]--all to no effect. Something odd, when I change files in /usr/home/xxxxx files in the hidden .zfs/snapshots/[snapshot name]/usr/home/xxxxx directory change as well.

Upvotes: 11

Views: 1697

Answers (1)

soyayix
soyayix

Reputation: 175

Use this command to see space used for all snapshots of a vdev - relevant property you want is usedsnap:

zfs list -o name,used,avail,refer,creation,usedds,usedsnap,origin,compression,compressratio,refcompressratio,mounted,atime,lused

I've added a few more properties since I use compression on my zfs pools.

zfs snapshots directories are read-only by the way.

You said you cannot roll back? If that's the case specify -r or -R and possibly -f if you have clones, sample:

zfs rollback -r poolname/dataset@oldersnaphot
zfs rollback -R poolname/dataset@oldersnaphot

Read the manual before issuing zfs rollback:

       -r
           Destroy any snapshots and bookmarks more recent than the one specified.
       -R
           Recursively destroy any more recent snapshots and bookmarks, as well as any clones of those snapshots.
       -f
           Used with the -R option to force an unmount of any clone file systems that are to be destroyed.

Upvotes: 3

Related Questions