zfs
zfs copied to clipboard
Cannot rename root dataset despite "zfs set mountpoint=/"
System information
| Type | Version/Name |
|---|---|
| Distribution Name | Arch Linux |
| Distribution Version | latest |
| Kernel Version | 5.19.7 |
| Architecture | x64 |
| OpenZFS Version | 2.1.5 |
Describe the problem you're observing
I boot Linux from a ZFS root filesystem. However, despite having the mount point set explicitly, I cannot rename the dataset from within.
Let's assume my root dataset is MyPool/MyRootFs. Before booting into it, I set the mountpoint as mentioned explicitly (via zfs set mountpoint=/ MyPool/MyRootFs), and then I boot into it. Thus, zfs get MyPool/MyRootFs returns:
zfs get MyPool/MyRootFs
NAME PROPERTY VALUE SOURCE
MyPool/MyRootFs mounted yes -
MyPool/MyRootFs mountpoint / local
Trying to rename MyRootFs fails:
zfs rename MyPool/MyRootFs MyPool/MyRootDataset
cannot unmount '/': pool or dataset is busy
Given mount point is pegged to '/', and thus the mount point does not change (i.e. file "/path/to/my/file.txt" before the rename should still point to "/path/to/my/file.txt" after the rename). As a result, the filesystem being "busy" should not be an issue here, as only the dataset name changes from a ZFS perspective, not, however, the mount point from a OS / root FS perspective. Therefore, I believe the rename operation above should succeed.
Describe how to reproduce the problem
See above.
Include any warning/errors/backtraces from the system logs
(100% reproducible, but if needed I can generate logs once I know which logs help here)
You can try 'zfs rename -u'. But I agree that if explicit mountpoint property specified renaming shouldn't change any mounts and should be allowed.
@IvanVolosyuk Thanks for the hint. That's a good workaround for now.
Your comment brought me to an idea. I think the zfs rename's error message
cannot unmount '/': pool or dataset is busy
might be more useful if it suggested to use the -u parameter
I think the zfs rename's error message might be more useful if it suggested to use the
-uparameter
I think that zfs rename should not try to remount in case the effective mountpoint does not change.
Note: zfs set mountpoint= has the same problem. You can't use it to explicitly set the mountpoint on a busy filesystem to what its current inherited value is unless you specify -u.
I also think that if the effective mountpoint doesn't change, the umount shouldn't be attempted in the first place; but that at the very least, the error message should point the user towards -u.