6

I've created ZFS datasets and installed virtual servers into them. Suddenly my ZFS volume free space is gone, but not all space is used in each dataset. I want to introduce thin provisioning (use ZFS sparse volume).

Is it possible to convert datasets into sparse volumes without deleting them? Thanks.

2

As far as I know it's not possible to convert an existing zvol to sparse; they must be created sparse to begin with.

However, you can create a new sparse zvol, and zfs send from the old one and zfs recv to the new one, and then swap their names.

| improve this answer | |
  • 2
    Isn't this command zfs set refreservation=none tank/dataset same as send and receive? – Xdg May 7 '16 at 19:40
  • 1
    There is some article about it - nex7.blogspot.cz/2013/03/… – Xdg May 7 '16 at 19:55
  • Can you actually do that? – Michael Hampton May 8 '16 at 1:40
  • Yes, I've done that and it's working okay. – Xdg May 8 '16 at 5:23
  • @Xdg Hm, I think if you do that then you also need to make sure reservation is also set to none. – Michael Hampton May 9 '16 at 8:36
8

I don't think the accepted answer is correct in fact, but I don't have enough rep to comment.

Assuming when the OP says "datasets" they mean "ZFS volume" (or ZVOL).

The only difference between a thin-provisioned (a.k.a sparse) ZVOL and a regular one is whether the full size is reserved via the refreservation property e.g.

# zfs create -V 10G tank/test_full
# zfs create -s -V 10G tank/test_sparse
# zfs list -o name,used,usedbydataset,usedbyrefreservation,logicalused,logicalreferenced,refreservation tank/test_sparse tank/test_full
NAME               USED  USEDDS  USEDREFRESERV  LUSED  LREFER  REFRESERV
tank/test_full    10.3G    136K          10.3G    30K     30K      10.3G
tank/test_sparse   136K    136K              0    30K     30K       none

So you can convert an existing ZVOL to sparse by changing refreservation for an existing ZVOL e.g.

# zfs set refreservation=none tank/test_full
# zfs list -o name,used,usedbydataset,usedbyrefreservation,logicalused,logicalreferenced,refreservation tank/test_sparse tank/test_full
NAME               USED  USEDDS  USEDREFRESERV  LUSED  LREFER  REFRESERV
tank/test_full     136K    136K              0    30K     30K       none
tank/test_sparse   136K    136K              0    30K     30K       none
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.