summaryrefslogtreecommitdiff
path: root/btrfs-receive-root.sh
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-04-22 13:52:29 -0400
committerAndrew Cady <d@jerkface.net>2016-04-22 18:50:58 -0400
commit727026bb76dc2e9cbc4d935db5eb03049d65385e (patch)
tree297c1dd5cf57833c90e8411fc77f59657f100056 /btrfs-receive-root.sh
parent85aa0fb94d870aae7e793f44816fd1652042b1bb (diff)
functions to send btrfs diffs back to the parent (incomplete)
these hard-code paths on my local machine the names of the generated files are also not useful
Diffstat (limited to 'btrfs-receive-root.sh')
-rw-r--r--btrfs-receive-root.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/btrfs-receive-root.sh b/btrfs-receive-root.sh
new file mode 100644
index 0000000..178fd64
--- /dev/null
+++ b/btrfs-receive-root.sh
@@ -0,0 +1,37 @@
1#!/bin/sh
2
3layer_dir=/home/d/sami
4seed_file=debian-live-8.4.0-amd64-standard.btrfs
5layer_file=debian-live-8.4.0-amd64-standard.layer.$$.btrfs
6layer_size=1000
7mountpoint=layer_dest.$$
8
9disable_stdout() { exec 3>&1; exec >&2; }
10enable_stdout() { exec >&3; }
11
12with_stdout() { enable_stdout; "$@"; disable_stdout; }
13
14create_layer_filesystem()
15{
16 [ ! -e "$layer_file" ] || return
17 mkdir -p "$mountpoint" &&
18 dd if=/dev/zero of="$layer_file" bs=1M count="$layer_size" &&
19 mount -o subvol=/,compress "$seed_file" "$mountpoint" &&
20 layer_dev=$(losetup -f --show "$layer_file") &&
21 btrfs device add "$layer_dev" "$mountpoint" &&
22 mount -o rw,remount "$mountpoint"
23}
24
25finish()
26{
27 umount "$mountpoint" &&
28 btrfstune -S1 "$layer_file"
29}
30
31set -ex
32
33cd "$layer_dir" &&
34disable_stdout &&
35create_layer_filesystem &&
36with_stdout btrfs receive "$mountpoint" &&
37finish