[1/1] Remove cow file early for non-persistent systems

Message ID 20180629091619.26172-1-list@eworm.de
State New
Headers show
Series [1/1] Remove cow file early for non-persistent systems | expand

Commit Message

Christian Hesse June 29, 2018, 9:16 a.m. UTC
From: Christian Hesse <mail@eworm.de>

The kernel has an open file handle after setting up the mapping. We can
remove it early to make sure it is gone on shutdown.

This helps to keep the cow_device clean for non-persistent systems where
cow_directory contains a version specific string.

Signed-off-by: Christian Hesse <mail@eworm.de>
 archiso/initcpio/hooks/archiso | 4 ++++
 1 file changed, 4 insertions(+)


diff --git a/archiso/initcpio/hooks/archiso b/archiso/initcpio/hooks/archiso
index 753e3da..5c56561 100644
--- a/archiso/initcpio/hooks/archiso
+++ b/archiso/initcpio/hooks/archiso
@@ -33,6 +33,10 @@  _mnt_dmsnapshot() {
     dmsetup create ${dm_snap_name} --table "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} ${cow_chunksize}"
+    if [[ "${cow_persistent}" != "P" ]]; then
+        rm -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow"
+    fi
     _mnt_dev "/dev/mapper/${dm_snap_name}" "${newroot}${mnt}" "-w" "defaults"
     echo $(readlink -f /dev/mapper/${dm_snap_name}) >> /run/archiso/used_block_devices