diff options
Diffstat (limited to 'loop-layer.sh')
-rw-r--r-- | loop-layer.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/loop-layer.sh b/loop-layer.sh new file mode 100644 index 0000000..7e08e12 --- /dev/null +++ b/loop-layer.sh | |||
@@ -0,0 +1,15 @@ | |||
1 | losetup_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 | } | ||