summaryrefslogtreecommitdiff
path: root/samizdat-eject.sh
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-04-26 04:08:56 -0400
committerAndrew Cady <d@jerkface.net>2016-04-26 04:08:56 -0400
commit19fc3ad482a467dbfcd27c8366ba026107498f4f (patch)
tree215c1290167cd213ed0b82bd9a9d23ea6bac2778 /samizdat-eject.sh
parentc33cb424ef479a6947395391b3771cc56b2d6161 (diff)
ejection script for cdrom duplication
included some necessary dependencies
Diffstat (limited to 'samizdat-eject.sh')
-rwxr-xr-xsamizdat-eject.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/samizdat-eject.sh b/samizdat-eject.sh
new file mode 100755
index 0000000..04ee610
--- /dev/null
+++ b/samizdat-eject.sh
@@ -0,0 +1,47 @@
1#!/bin/sh
2
3. mdadm-dup.sh || exit 1
4
5btrfs_subdevices()
6{
7 local mountpoint="$1"
8 btrfs filesystem show "$mountpoint" | sed -ne 's/^[ \t]*devid.* path //p'
9}
10
11devices=$(btrfs_subdevices /) || exit 1
12
13set --
14seen=
15for dev in $devices; do
16 [ -b "$dev" ] || exit 1
17 case "$dev" in
18 /dev/mapper/loop*) set -- "$@" "$dev" ;;
19 /dev/mapper/samizdatcrypt) seen=y ;;
20 esac
21done
22[ "$seen" ] || exit 1
23
24copy()
25{
26 mdadm_copy_eject /dev/md55 /root/samizdat.iso
27}
28
29remove()
30{
31 for dev; do
32 (set -x; btrfs device remove "$dev" /)
33 done
34}
35
36# Doing the mdadm copy before removing the devices means our filesystem includes
37# devices that are ultimately backed by files ON THE SAME FILESYSTEM. As such, it
38# might conceivably put btrfs into a deadlock of some kind.
39
40# If it turns out this doesn't work, the order can be reversed. This will
41# perform the read IO twice, though, almost doubling the total installation
42# time.
43
44copy & remove "$@"
45
46set -x
47wait