diff options
author | Andrew Cady <d@jerkface.net> | 2016-04-22 18:48:58 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-04-22 18:50:58 -0400 |
commit | 004812b461ff45c8771c5513afa379a32d322046 (patch) | |
tree | 51c28d889f4201a9734dae6b42a2ea804f35bb3c | |
parent | f24016632e13ebd3ec356bdf0ef9c599f55b2100 (diff) |
Add multi-layered seed support
The available filesystem with the largest number of seeds will be chosen
for the root of the initial install.
-rw-r--r-- | old-school/lvm-create.sh | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/old-school/lvm-create.sh b/old-school/lvm-create.sh index e6f4eea..743b83a 100644 --- a/old-school/lvm-create.sh +++ b/old-school/lvm-create.sh | |||
@@ -31,9 +31,19 @@ init_samizdat() | |||
31 | local imgfile="$1" megs="$2" keyfile="$3" dev | 31 | local imgfile="$1" megs="$2" keyfile="$3" dev |
32 | 32 | ||
33 | init_samizdat_blockdev "$imgfile" "$megs" "$keyfile" || return | 33 | init_samizdat_blockdev "$imgfile" "$megs" "$keyfile" || return |
34 | local blockdev=/dev/mapper/samizdatcrypt | 34 | local blockdev=/dev/mapper/samizdatcrypt uuid |
35 | |||
36 | for fs in /cdrom/live/*.btrfs; do | ||
37 | losetup -f "$fs" || return | ||
38 | done | ||
39 | modprobe btrfs || return | ||
40 | btrfs device scan || return | ||
41 | |||
42 | uuid=$(choose_uuid) || return | ||
43 | [ "$uuid" ] | ||
44 | |||
45 | mount -t btrfs -o subvol=ROOT UUID="$uuid" /root || return | ||
35 | 46 | ||
36 | mount -t btrfs -o subvol=ROOT /cdrom/live/filesystem.btrfs /root || return | ||
37 | btrfs device add "$blockdev" /root || return | 47 | btrfs device add "$blockdev" /root || return |
38 | mount -o rw,remount /root || return | 48 | mount -o rw,remount /root || return |
39 | btrfs subvolume create /root/gpg || return | 49 | btrfs subvolume create /root/gpg || return |
@@ -53,14 +63,44 @@ init_samizdat() | |||
53 | bootdone root-mounted | 63 | bootdone root-mounted |
54 | } | 64 | } |
55 | 65 | ||
66 | # Get the uuid of the filesystem with the most devices, | ||
67 | # excluding filesystems that don't incorporate loop devices. | ||
68 | # This is used to choose the latest seed -- which should have | ||
69 | # the most layers. | ||
70 | choose_uuid() | ||
71 | { | ||
72 | local seen_loop= seen_uuid= seen_devs= | ||
73 | btrfs filesystem show | | ||
74 | while read line; do | ||
75 | case "$line" in | ||
76 | Label*) | ||
77 | seen_uuid=${line##*uuid: } | ||
78 | seen_devs= | ||
79 | seen_loop= | ||
80 | ;; | ||
81 | *Total\ devices*) | ||
82 | seen_devs=${line#*Total devices } | ||
83 | seen_devs=${seen_devs%% *} | ||
84 | ;; | ||
85 | *path\ /dev/loop*) | ||
86 | seen_loop=t;; | ||
87 | esac | ||
88 | [ "$seen_loop" ] && echo "$seen_devs $seen_uuid" | ||
89 | done | | ||
90 | uniq | sort -nr | head -n1 | (read _ x; echo $x) | ||
91 | } | ||
92 | |||
56 | open_samizdat() | 93 | open_samizdat() |
57 | { | 94 | { |
58 | open_samizdat_blockdev "$@" || return | 95 | open_samizdat_blockdev "$@" || return |
59 | local blockdev=/dev/mapper/samizdatcrypt | 96 | local blockdev=/dev/mapper/samizdatcrypt fs |
60 | losetup -f /cdrom/live/filesystem.btrfs || return | 97 | for fs in /cdrom/live/*.btrfs; do |
98 | losetup -f "$fs" || return | ||
99 | done | ||
61 | modprobe btrfs || return | 100 | modprobe btrfs || return |
62 | btrfs device scan || return | 101 | btrfs device scan || return |
63 | mount -t btrfs -o subvol=ROOT "$blockdev" /root || return | 102 | mount -t btrfs -o subvol=ROOT "$blockdev" /root || return |
103 | LoSetup -D | ||
64 | bootdone root-mounted | 104 | bootdone root-mounted |
65 | } | 105 | } |
66 | 106 | ||