From 7b4e27232dec4595ef842ce7c0e31aafd255a20a Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Tue, 1 Sep 2020 19:14:16 -0400 Subject: Add 'zfs rename -u' to rename without remounting Allow to rename file systems without remounting if it is possible. It is possible for file systems with 'mountpoint' property set to 'legacy' or 'none' - we don't have to change mount directory for them. Currently such file systems are unmounted on rename and not even mounted back. This introduces layering violation, as we need to update 'f_mntfromname' field in statfs structure related to mountpoint (for the dataset we are renaming and all its children). In my opinion it is worth it, as it allow to update FreeBSD in even cleaner way - in ZFS-only configuration root file system is ZFS file system with 'mountpoint' property set to 'legacy'. If root dataset is named system/rootfs, we can snapshot it (system/rootfs@upgrade), clone it (system/oldrootfs), update FreeBSD and if it doesn't boot we can boot back from system/oldrootfs and rename it back to system/rootfs while it is mounted as /. Before it was not possible, because unmounting / was not possible. Authored by: Pawel Jakub Dawidek Reviewed-by: Allan Jude Reviewed-by: Brian Behlendorf Ported by: Matt Macy Signed-off-by: Ryan Moeller Closes #10839 --- man/man8/zfs-rename.8 | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'man/man8') diff --git a/man/man8/zfs-rename.8 b/man/man8/zfs-rename.8 index 9d650709a..d8d9f49d7 100644 --- a/man/man8/zfs-rename.8 +++ b/man/man8/zfs-rename.8 @@ -44,9 +44,16 @@ .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Nm .Cm rename -.Op Fl fp +.Fl p +.Op Fl f .Ar filesystem Ns | Ns Ar volume .Ar filesystem Ns | Ns Ar volume +.Nm +.Cm rename +.Fl u +.Op Fl f +.Ar filesystem +.Ar filesystem .Sh DESCRIPTION .Bl -tag -width "" .It Xo @@ -59,10 +66,19 @@ .It Xo .Nm .Cm rename -.Op Fl fp +.Fl p +.Op Fl f .Ar filesystem Ns | Ns Ar volume .Ar filesystem Ns | Ns Ar volume .Xc +.It Xo +.Nm +.Cm rename +.Fl u +.Op Fl f +.Ar filesystem +.Ar filesystem +.Xc Renames the given dataset. The new target can be located anywhere in the ZFS hierarchy, with the exception of snapshots. @@ -73,12 +89,24 @@ Renamed file systems can inherit new mount points, in which case they are unmounted and remounted at the new mount point. .Bl -tag -width "-a" .It Fl f -Force unmount any filesystems that need to be unmounted in the process. +Force unmount any file systems that need to be unmounted in the process. +This flag has no effect if used together with the +.Fl u +flag. .It Fl p Creates all the nonexistent parent datasets. Datasets created in this manner are automatically mounted according to the .Sy mountpoint property inherited from their parent. +.It Fl u +Do not remount file systems during rename. +If a file system's +.Sy mountpoint +property is set to +.Sy legacy +or +.Sy none , +the file system is not unmounted even if this option is not given. .El .It Xo .Nm -- cgit v1.2.3