2

Based on this instructions I should be able to make a clone of a zfs volume using commands like so:

$ sudo zfs snapshot -r zfs/logs/test@tmp-1236
$ sudo zfs clone zfs/logs/test@tmp-1236 zfs/logs/test-3

The issue is that it does not work. The clone seem to be created but its not mounted, and I cannot find a way to mount it:

$ ls -l /data/zfs-1/logs/test-3
ls: cannot access '/data/zfs-1/logs/test-3': No such file or directory

$ zfs list
NAME              USED  AVAIL     REFER  MOUNTPOINT
zfs               984K   674G      104K  /data/zfs-1
zfs/cache          96K   674G       96K  /data/zfs-1/cache
zfs/data           96K   674G       96K  /data/zfs-1/data
zfs/logs          280K   674G      104K  /data/zfs-1/logs
zfs/logs/test     176K   674G      104K  /data/zfs-1/logs/test
zfs/logs/test-2     0B   674G      104K  /data/zfs-1/logs/test-2
zfs/logs/test-3     0B   674G      104K  /data/zfs-1/logs/test-3

$ zfs get all zfs/logs/test-3
NAME             PROPERTY              VALUE                    SOURCE
zfs/logs/test-3  type                  filesystem               -
zfs/logs/test-3  creation              Wed Apr 20 17:41 2022    -
zfs/logs/test-3  used                  0B                       -
zfs/logs/test-3  available             674G                     -
zfs/logs/test-3  referenced            104K                     -
zfs/logs/test-3  compressratio         1.00x                    -
zfs/logs/test-3  mounted               no                       -
zfs/logs/test-3  origin                zfs/logs/test@tmp-1236   -
zfs/logs/test-3  quota                 none                     default
zfs/logs/test-3  reservation           none                     default
zfs/logs/test-3  recordsize            128K                     default
zfs/logs/test-3  mountpoint            /data/zfs-1/logs/test-3  inherited from zfs
zfs/logs/test-3  sharenfs              off                      default
zfs/logs/test-3  checksum              on                       default
zfs/logs/test-3  compression           on                       inherited from zfs/logs
zfs/logs/test-3  atime                 off                      inherited from zfs/logs
zfs/logs/test-3  devices               on                       default
zfs/logs/test-3  exec                  on                       default
zfs/logs/test-3  setuid                on                       default
zfs/logs/test-3  readonly              off                      default
zfs/logs/test-3  zoned                 off                      default
zfs/logs/test-3  snapdir               hidden                   default
zfs/logs/test-3  aclinherit            restricted               default
zfs/logs/test-3  createtxg             452830                   -
zfs/logs/test-3  canmount              on                       default
zfs/logs/test-3  xattr                 on                       default
zfs/logs/test-3  copies                1                        default
zfs/logs/test-3  version               5                        -
zfs/logs/test-3  utf8only              off                      -
zfs/logs/test-3  normalization         none                     -
zfs/logs/test-3  casesensitivity       sensitive                -
zfs/logs/test-3  vscan                 off                      default
zfs/logs/test-3  nbmand                off                      default
zfs/logs/test-3  sharesmb              off                      default
zfs/logs/test-3  refquota              none                     default
zfs/logs/test-3  refreservation        none                     default
zfs/logs/test-3  guid                  585396924087649129       -
zfs/logs/test-3  primarycache          all                      default
zfs/logs/test-3  secondarycache        all                      default
zfs/logs/test-3  usedbysnapshots       0B                       -
zfs/logs/test-3  usedbydataset         0B                       -
zfs/logs/test-3  usedbychildren        0B                       -
zfs/logs/test-3  usedbyrefreservation  0B                       -
zfs/logs/test-3  logbias               latency                  default
zfs/logs/test-3  objsetid              516                      -
zfs/logs/test-3  dedup                 off                      default
zfs/logs/test-3  mlslabel              none                     default
zfs/logs/test-3  sync                  standard                 default
zfs/logs/test-3  dnodesize             legacy                   default
zfs/logs/test-3  refcompressratio      1.02x                    -
zfs/logs/test-3  written               0                        -
zfs/logs/test-3  logicalused           0                        -
zfs/logs/test-3  logicalreferenced     47K                      -
zfs/logs/test-3  volmode               default                  default
zfs/logs/test-3  filesystem_limit      none                     default
zfs/logs/test-3  snapshot_limit        none                     default
zfs/logs/test-3  filesystem_count      none                     default
zfs/logs/test-3  snapshot_count        none                     default
zfs/logs/test-3  snapdev               hidden                   default
zfs/logs/test-3  acltype               off                      default
zfs/logs/test-3  context               none                     default
zfs/logs/test-3  fscontext             none                     default
zfs/logs/test-3  defcontext            none                     default
zfs/logs/test-3  rootcontext           none                     default
zfs/logs/test-3  relatime              off                      default
zfs/logs/test-3  redundant_metadata    all                      default
zfs/logs/test-3  overlay               on                       default
zfs/logs/test-3  encryption            off                      default
zfs/logs/test-3  keylocation           none                     default
zfs/logs/test-3  keyformat             none                     default
zfs/logs/test-3  pbkdf2iters           0                        default
zfs/logs/test-3  special_small_blocks  0                        default

$ sudo zfs set mounted=yes zfs/logs/test-3
cannot set property for 'zfs/logs/test-3': 'mounted' is readonly

$ sudo zfs mount zfs/logs/test-3
cannot mount 'zfs/logs/test-3': Dataset is not complete, was created by receiving a redacted zfs send stream.

Looks like the new volume has option mounted: no that prevents it from mounting.
I tried to switch it to yes but no success.
I am not sure if zfs mount is the correct command or is it for mounting zpools, but I tried it out of desperation.
What am I missing?

My goal is to create on demand clones of specific zfs volume.

2 Answers 2

1

Your assumption that mounted:no is the culprit is not correct. The mounted attribute, in conformance with its name, is read only and tells you whether a dataset is currently mounted. Therefore, you can't change it directly.

Being unable to mount it is the consequence of another problem which zfs is already telling you about. The last line from your terminal session:

cannot mount 'zfs/logs/test-3': Dataset is not complete, was created by receiving a redacted zfs send stream.

This actually is the problem. I don't know how you created the snapshot which you are trying to clone, but obviously that snapshot has been received from a different (or even the same) system using zfs receive, where the sending party redacted the snapshot.

To learn about redacting, please have a look into man zfs, man zfs-send or man zfs-redact (depending on your zfs version), or into the HTML man page. I can't explain much here, because I don't use that feature. However, in my experience, sending and receiving snapshots the "normal" way (without redacting), always works reliably and does not lead to any problems with mounting received snapshots or clones of them.

I know that link-only answers are not the best behavior, but the passages from the manuals where redacting is explained are really way too long to cite them here, even in part.

3
  • I created the snapshot using commands from the question: sudo zfs snapshot -r zfs/logs/test@tmp-1236. I did find into some info that this might be caused by a bug in older kernels so I will try to upgrade to Ubuntu 22.04 and try again if that is the reason. In fact if I use zfs send/receive then everything works fine, but it will not work for my use case, since I need multiple (around 20-50) copies of a filesystem with more than 10 GB of data and zfs send/receive will not COW as far as I know.
    – HubertNNN
    Apr 25, 2022 at 11:16
  • I hadn't realized that you tried to mount immediately after creating: I saw the first code box in your question, but thought that there were further actions between the first and the second line. Sorry for that. Coming back to the issue, we're using ZFS since at least 2018 with older kernels (we're mostly on Debian, which is usually more behind than other distros), but never experienced a problem like this. Sad that I can't help you then ...
    – Binarus
    Apr 25, 2022 at 11:34
  • One more idea: If you want to keep your current system as far as possible for some reason, you can try to compile a recent ZFS version yourself and keep your old kernel that way. This will solve the issue only in case it's a bug in ZFS, not the kernel. We've done this multiple times and had no issues (except one time a dependence issue of a library because of a bug in the ZFS build scripts).
    – Binarus
    Apr 25, 2022 at 11:42
1

The behavior is caused by mismatch between ZFS tools and Kernel module. ZFS 2.x application is not compatible with Kernels older than 5.11.

Since in Ubuntu kernel version is tied to Release, the simplest solution was to do a release upgrade. After updating Ubuntu from 20.04 LTS to 22.04 LTS, ZFS clone started to work correctly, including clones made before the update.

Solution based on an issue found on https://github.com/openzfs/zfs/issues/11581

2
  • Thanks for reporting, and +1. However: ZFS 2.x application is not compatible with Kernels older than 5.11. We can't confirm this. Right now, we are running ZFS 2.1.4 with kernel 4.19 on two production machines without any issues.
    – Binarus
    Apr 27, 2022 at 5:57
  • @Binarus It was working fine for me too until I needed to clone a volume. Its possible that only cloning is broken and everything else works fine with older kernels. Ticket I linked is still opened, so maybe there will be more info when OpenZFS developers will check it, for now the comment in that ticket mentioned that on kernel 5.4 zfs clone is broken and updating kernel to 5.11 fixes the issue and it did for me.
    – HubertNNN
    Apr 27, 2022 at 8:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .