summaryrefslogtreecommitdiff
path: root/src/initrd/loop-layer.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/initrd/loop-layer.sh')
-rw-r--r--src/initrd/loop-layer.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/initrd/loop-layer.sh b/src/initrd/loop-layer.sh
new file mode 100644
index 0000000..7e08e12
--- /dev/null
+++ b/src/initrd/loop-layer.sh
@@ -0,0 +1,15 @@
1losetup_snapshot()
2{
3 local ro_dev rw_dev new_dev_name size persist chunksize
4 ro_file=$1
5 rw_file=$2
6
7 ro_dev=$(LoSetup -r -f --show "$ro_file") || return
8 rw_dev=$(LoSetup -f --show "$rw_file") || return
9 new_dev_name=${ro_dev##*/}
10 size=$(blockdev --getsz "$ro_dev") || return
11 persist=p
12 chunksize=16
13 dmsetup create "$new_dev_name" --table "0 $size snapshot $ro_dev $rw_dev $persist $chunksize" || return
14 echo /dev/mapper/"$new_dev_name"
15}