summaryrefslogtreecommitdiff
path: root/src/initrd/loop-layer.sh
blob: 7e08e122399ca36d2ce357a4c7471172a69351cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
losetup_snapshot()
{
    local ro_dev rw_dev new_dev_name size persist chunksize
    ro_file=$1
    rw_file=$2

    ro_dev=$(LoSetup -r -f --show "$ro_file") || return
    rw_dev=$(LoSetup -f --show "$rw_file") || return
    new_dev_name=${ro_dev##*/}
    size=$(blockdev --getsz "$ro_dev") || return
    persist=p
    chunksize=16
    dmsetup create "$new_dev_name" --table "0 $size snapshot $ro_dev $rw_dev $persist $chunksize" || return
    echo /dev/mapper/"$new_dev_name"
}