From d3f3df6199e58fdb36cacbcbd0356e78822b5be9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 1 Mar 2019 15:13:12 +0100 Subject: [PATCH 1/2] btrfs: when falling back to plain copy when snapshoting exclude submounts The subvol snapshot logic doesn't cover sub-mounts either, and it really shouldn't in the general case, hence let's simply stop at submounts in all cases, both in the main and in the fall-back codepath. As discussed here: https://github.com/systemd/systemd/pull/11243#pullrequestreview-209477230 --- src/basic/btrfs-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c index da4dd2a827..b1519cc4eb 100644 --- a/src/basic/btrfs-util.c +++ b/src/basic/btrfs-util.c @@ -1628,7 +1628,7 @@ int btrfs_subvol_snapshot_fd_full( } else if (r < 0) return r; - r = copy_directory_fd_full(old_fd, new_path, COPY_MERGE|COPY_REFLINK, progress_path, progress_bytes, userdata); + r = copy_directory_fd_full(old_fd, new_path, COPY_MERGE|COPY_REFLINK|COPY_SAME_MOUNT, progress_path, progress_bytes, userdata); if (r < 0) goto fallback_fail; From 3f2fa83499fa52d7180fef997194cd00a6a12eb4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 1 Mar 2019 15:14:36 +0100 Subject: [PATCH 2/2] man: document that --ephemeral and --template= don't cover submounts We never made this clear, let's fix that. --- man/systemd-nspawn.xml | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/man/systemd-nspawn.xml b/man/systemd-nspawn.xml index 5ed49e6587..00c14eafeb 100644 --- a/man/systemd-nspawn.xml +++ b/man/systemd-nspawn.xml @@ -160,16 +160,18 @@ - Directory or btrfs subvolume to use as template for the container's root - directory. If this is specified and the container's root directory (as configured by - ) does not yet exist it is created as btrfs snapshot (if - supported) or plain directory (otherwise) and populated from this template tree. Ideally, the specified - template path refers to the root of a btrfs subvolume, in which case a simple copy-on-write - snapshot is taken, and populating the root directory is instant. If the specified template path does not refer - to the root of a btrfs subvolume (or not even to a btrfs file system at - all), the tree is copied (though possibly in a 'reflink' copy-on-write scheme — if the file system supports - that), which can be substantially more time-consuming. May not be specified together with - or . + Directory or btrfs subvolume to use as template for the + container's root directory. If this is specified and the container's root directory (as configured by + ) does not yet exist it is created as btrfs snapshot + (if supported) or plain directory (otherwise) and populated from this template tree. Ideally, the + specified template path refers to the root of a btrfs subvolume, in which case a + simple copy-on-write snapshot is taken, and populating the root directory is instant. If the + specified template path does not refer to the root of a btrfs subvolume (or not + even to a btrfs file system at all), the tree is copied (though possibly in a + 'reflink' copy-on-write scheme — if the file system supports that), which can be substantially more + time-consuming. Note that the snapshot taken is of the specified directory or subvolume, including + all subdirectories and subvolumes below it, but excluding any sub-mounts. May not be specified + together with or . Note that this switch leaves host name, machine ID and all other settings that could identify the instance @@ -183,11 +185,13 @@ If specified, the container is run with a temporary snapshot of its file system that is removed immediately when the container terminates. May not be specified together with . - Note that this switch leaves host name, machine ID and all other settings that could identify the - instance unmodified. Please note that — as with — taking the temporary snapshot is - more efficient on file systems that support subvolume snapshots or 'reflinks' naively (btrfs - or new xfs) than on more traditional file systems that do not - (ext4). + Note that this switch leaves host name, machine ID and all other settings that could identify + the instance unmodified. Please note that — as with — taking the + temporary snapshot is more efficient on file systems that support subvolume snapshots or 'reflinks' + natively (btrfs or new xfs) than on more traditional file + systems that do not (ext4). Note that the snapshot taken is of the specified + directory or subvolume, including all subdirectories and subvolumes below it, but excluding any + sub-mounts. With this option no modifications of the container image are retained. Use (described below) for other mechanisms to restrict persistency of