[zfs-discuss] How to get the actual ZFS dataset size & how to recover a ZFS dataset?
jlawrence at squaretrade.com
Wed Dec 21 15:29:33 EST 2016
> On Dec 21, 2016, at 11:36 AM, Nick Gilmour via zfs-discuss <zfs-discuss at list.zfsonlinux.org> wrote:
> 1. How can I get the actual size of the pool and the datasets? Why zfs was reporting the wrong capacity even though I have deleted files?
I can only help with your less-critical-sounding question.
There isn’t enough information to determine that in your message. The most likely explanation of what happened is that you have snapshots that reference at least some of the data you deleted in them. Those snapshots cost space for things deleted from your live filesystem, but that still exist in a snapshot. (That’s one big reason for the existence of snapshots in the first place.)
zfs get listsnapshots
The first one will show your current live file systems and usage data.
The second shows the same for snapshots.
From there, collate and add up. If you end up doing this a lot, you may find it convenient to set `zpool set listsnapshots=on <poolname>`, which will cause your snapshots to show in a `zfs list`.
You might want to have a look at some documentation; I have the feeling that some of the features that make ZFS special are what you are finding surprising.
Also note that normal operating system utilities work, but can mislead if you don’t have a good handle on what you’re looking at. `df`, for instance, knows nothing of snapshots (which is the Right Thing), and as a hypothetical extreme case, you could have a mounted multi-PB ZFS volume with nothing written to it that shows as completely full due to snapshots.
There is no integration between the standard unix disk utilities and ZFS. This is mostly as it should be, and they work fine, but COW filesystem semantics are sufficiently different that people tend to be surprised when they don’ t know what’s happening, and in any case, the FS-agnostic utilities can only offer incomplete information when it comes to ZFS.
> 2. How can I recover a dataset? According to this:
> it was done but it was on FreeNAS. How can I make it work for Linux (Ubuntu 16.04)? In particular with this step:
> 2) Select recovery mode by loading the ZFS KLD with "vfs.zfs.recover=1"
> set in /boot/loader.conf
This is one for someone else; unfortunately I can’t answer that.
If you’re new to ZFS, I highly recommend spending some time with your new installation and some docs, kicking the tires and experimenting with the features *with noncritical data*. ZFS is solid, but if you aren’t accustomed to how it works, assumptions that are valid for other file systems can lead you to do unfortunate things to ZFS. (This is another way of saying that, as best I can tell, most ZFS data loss is caused by operator error.) So I highly advise learning what those are with data you can afford to lose.
More information about the zfs-discuss