summaryrefslogtreecommitdiffstats
path: root/builder/modules.d/dnbd3-rootfs/scripts/device-add-write-layer.sh
blob: 2e4116a7f9403b1c04122c6fd66e66b609562b62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# region imports
# shellcheck source=./rebash/core.sh
source "/usr/lib/rebash/core.sh"
core.import exceptions
exceptions.activate
# endregion

combined_device_name="$1"
read_only_device="$2"
writable_device="$3"
persistent="$4" # P or N
chunksize='1'

partition_size="$(blockdev --getsz "$read_only_device")"
writable_partition_name='root'
modprobe dm_snapshot
dmsetup create "$combined_device_name" --noudevsync --table \
    "0 $partition_size snapshot $read_only_device $writable_device $persistent $chunksize"
dmsetup mknodes --noudevsync "$combined_device_name"

# region vim modline
# vim: set tabstop=4 shiftwidth=4 expandtab:
# vim: foldmethod=marker foldmarker=region,endregion:
# endregion