Package: schroot Version: 1.6.10-12 Severity: minor File: /etc/schroot/setup.d/05zfs Tags: patch
Dear maintainer, thank you for enabling ZFS usage. Please consider the following patch to make clone removal a little more robust: | diff --git a/schroot/setup.d/05zfs b/schroot/setup.d/05zfs | index 6ecc0196..785aee5f 100755 | --- a/schroot/setup.d/05zfs | +++ b/schroot/setup.d/05zfs | @@ -49,10 +49,10 @@ if [ "$CHROOT_TYPE" = "zfs-snapshot" ] && [ -n "$CHROOT_ZFS_CLONE_NAME" ]; then | if zfs list "$CHROOT_ZFS_CLONE_NAME" >/dev/null 2>&1 | then | if [ "$VERBOSE" = "verbose" ]; then | - zfs destroy "$CHROOT_ZFS_CLONE_NAME" | + zfs destroy -r "$CHROOT_ZFS_CLONE_NAME" | zfs destroy "$CHROOT_ZFS_SNAPSHOT_NAME" | else | - zfs destroy "$CHROOT_ZFS_CLONE_NAME" > /dev/null | + zfs destroy -r "$CHROOT_ZFS_CLONE_NAME" > /dev/null | zfs destroy "$CHROOT_ZFS_SNAPSHOT_NAME" > /dev/null | fi | else I.e. recursively destroy all children of that clone via the "-r" option. Otherwise I can all too easily happen that such children exist in the form of snapshots, e.g. when using zfsnap or any such tool that might automatically create a snapshot of a ZFS dataset while it is in use. For illustration, let's consider the following sequence of actions: 1. a user enters a ZFS-based chroot via $ schroot -c unstable-amd64-sbuild 2. schroot creates a snapshot of the base dataset and then a clone of that snapshot, e.g. $ zfs list -t all [...] zfspool/SYSTEM/srv/chroot/unstable-amd64-sbuild@unstable-amd64-sbuild-44e762df-cab6-4cf3-99dd-15f0fd018d18 0B - 359M - zfspool/SYSTEM/srv/chroot/unstable-amd64-sbuild/schroot-unstable-amd64-sbuild-44e762df-cab6-4cf3-99dd-15f0fd018d18 8K 62.2G 359M legacy 3. some tool - here done manually - creates a snapshot of that clone $ sudo zfs snapshot zfspool/SYSTEM/srv/chroot/unstable-amd64-sbuild/schroot-unstable-amd64-sbuild-44e762df-cab6-4cf3-99dd-15f0fd018d18@test 4. the user exits their schroot session and schroot complains E: 05zfs: cannot destroy 'zfspool/SYSTEM/srv/chroot/unstable-amd64-sbuild/schroot-unstable-amd64-sbuild-44e762df-cab6-4cf3-99dd-15f0fd018d18': filesystem has children E: 05zfs: use '-r' to destroy the following datasets: E: 05zfs: zfspool/SYSTEM/srv/chroot/unstable-amd64-sbuild/schroot-unstable-amd64-sbuild-44e762df-cab6-4cf3-99dd-15f0fd018d18@test E: unstable-amd64-sbuild-44e762df-cab6-4cf3-99dd-15f0fd018d18: Chroot setup failed: stage=setup-stop 5. $CHROOT_ZFS_CLONE_NAME and $CHROOT_ZFS_SNAPSHOT_NAME must be cleaned up manually Cheers, Flo
signature.asc
Description: PGP signature