In the .zfs directory of a ZFS filesystem there are a few subdirectories. One of them is .zfs/snapshot. I think many of you know the trick that you can create a snapshot by just doing a mkdir in this directory.
Let`s fill our filesystem with some stuff:
root@testbed:/tank/test2# touch monday
root@testbed:/tank/test2# touch tuesday
root@testbed:/tank/test2# touch wednesday
root@testbed:/tank/test2# ls
monday tuesday wednesdayNow we go into the .zfs/snapshot directory.
root@testbed:/tank/test2# cd .zfs
root@testbed:/tank/test2/.zfs# cd snapshot/
root@testbed:/tank/test2/.zfs/snapshot# ls
root@testbed:/tank/test2/.zfs/snapshot# mkdir 26032025_0527
root@testbed:/tank/test2/.zfs/snapshot# cd 26032025_0527/
root@testbed:/tank/test2/.zfs/snapshot/26032025_0527# ls
monday tuesday wednesday
root@testbed:/tank/test2/.zfs/snapshot/26032025_0527# touch test
touch: cannot create test: Read-only file system
root@testbed:/tank/test2/.zfs/snapshot/26032025_0527#As it’s a snapshot, you can`t make any changes to it. It’s a read-only filesystem.
Sometimes it would be quite practical to be able to write into such a snapshot. Well, there is now a .zfs/clone subdirectory and you can do the same for ZFS clones. Just a a different directory. Execute an mkdir there and a clone is created.
root@testbed:/tank/test2/.zfs/clone# cd /tank/test2/.zfs/clone
root@testbed:/tank/test2/.zfs/clone# mkdir c26032025_0527
root@testbed:/tank/test2/.zfs/clone# cd c26032025_0527/
root@testbed:/tank/test2/.zfs/clone/c26032025_0527# ls
monday tuesday wednesday
root@testbed:/tank/test2/.zfs/clone/c26032025_0527# touch thursday
root@testbed:/tank/test2/.zfs/clone/c26032025_0527# ls
monday thursday tuesday wednesday
root@testbed:/tank/test2/.zfs/clone/c26032025_0527# ls ../../../
monday tuesday wednesdayThis clone allows you to write into the filesystem without changing the source of the clone.
Let’s assume you have created a clone with the normal commands:
root@testbed:~# zfs snapshot tank/test2@26032025_0549
root@testbed:~# zfs clone tank/test2@26032025_0549 tank/test20By setting the mountpoint property to clonedir, the clone will now appear under `.zfs/clone
root@testbed:~# zfs set mountpoint=clonedir tank/test20
root@testbed:~# cd /tank/test2/.zfs
root@testbed:/tank/test2/.zfs# cd clone/
root@testbed:/tank/test2/.zfs/clone# ls
c26032025_0527 test20PS: You can now comment on this blog entries. However you need an account in the Fediverse (Mastodon for example) for this. When you reply to the Announcement post in the fediverse, it will automatically appear here.