summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-rootfs/scripts/device-add-write-layer.sh
blob: 67c14314a71e8ab9367d59cecc39220b42ea1fd7 (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
27
28
#!/usr/bin/env bash

# region imports

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