diff options
author | Andrew Cady <d@jerkface.net> | 2016-04-25 20:40:39 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-04-25 20:40:39 -0400 |
commit | d0f8d023e06d4d25e85ee0ceff96955cbe8a24d3 (patch) | |
tree | 2df779934f3c8228a7134e52440ba89c8a78ee58 /old-school/mdadm-dup.sh | |
parent | e213dac839137b9a51f8349b81f2d29a6d7c27d8 (diff) |
fixup! Cdrom duplication
Diffstat (limited to 'old-school/mdadm-dup.sh')
-rw-r--r-- | old-school/mdadm-dup.sh | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/old-school/mdadm-dup.sh b/old-school/mdadm-dup.sh index 27a39ca..b1bcd33 100644 --- a/old-school/mdadm-dup.sh +++ b/old-school/mdadm-dup.sh | |||
@@ -41,7 +41,8 @@ dm_snapshot_teardown() | |||
41 | read _ _ snapshot ro_dev rw_dev _ _ | 41 | read _ _ snapshot ro_dev rw_dev _ _ |
42 | [ "$snapshot" = snapshot ] || exit 1 | 42 | [ "$snapshot" = snapshot ] || exit 1 |
43 | dmsetup remove "$dev" || exit 1 | 43 | dmsetup remove "$dev" || exit 1 |
44 | # errors ignored because the loop dev can be automatically removed upon disuse already | 44 | # errors ignored because the loop dev can be configured to be |
45 | # automatically removed upon disuse | ||
45 | losetup -d /dev/block/"$rw_dev" || true | 46 | losetup -d /dev/block/"$rw_dev" || true |
46 | eject /dev/block/"$ro_dev" || exit 1 | 47 | eject /dev/block/"$ro_dev" || exit 1 |
47 | ) || return | 48 | ) || return |
@@ -58,11 +59,11 @@ wait_for_dm_device() | |||
58 | done | 59 | done |
59 | } | 60 | } |
60 | 61 | ||
61 | mount_cdrom() | 62 | dup_mount_cdrom() |
62 | { | 63 | { |
63 | local cdrom_dev="$1" | 64 | local cdrom_dev="$1" mountpoint="$2" |
64 | 65 | ||
65 | local sectors md_dev=/dev/md0 cdrom_rw_file=/"${cdrom_dev##*/}".rw | 66 | local sectors md_dev=/dev/md55 cdrom_rw_file=/"${cdrom_dev##*/}".rw |
66 | 67 | ||
67 | sectors=$(get_cdrom_sizelimit "$cdrom_dev") || return | 68 | sectors=$(get_cdrom_sizelimit "$cdrom_dev") || return |
68 | 69 | ||
@@ -72,7 +73,7 @@ mount_cdrom() | |||
72 | dd if=/dev/zero of="$cdrom_rw_file" bs=1K count=32 || return | 73 | dd if=/dev/zero of="$cdrom_rw_file" bs=1K count=32 || return |
73 | cdrom_rw_dev=$(dm_snapshot "$cdrom_dev" "$cdrom_rw_file" "$sectors") || return | 74 | cdrom_rw_dev=$(dm_snapshot "$cdrom_dev" "$cdrom_rw_file" "$sectors") || return |
74 | mdadm_dup "$cdrom_rw_dev" "$md_dev" "$sectors" || return | 75 | mdadm_dup "$cdrom_rw_dev" "$md_dev" "$sectors" || return |
75 | mount -t iso9660 -r $md_dev /cdrom | 76 | mount -t iso9660 -r $md_dev "$mountpoint" |
76 | } | 77 | } |
77 | 78 | ||
78 | get_cdrom_sizelimit() | 79 | get_cdrom_sizelimit() |