diff options
Diffstat (limited to 'old-school')
-rw-r--r-- | old-school/lvm-create.sh | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/old-school/lvm-create.sh b/old-school/lvm-create.sh index 743b83a..ecbae49 100644 --- a/old-school/lvm-create.sh +++ b/old-school/lvm-create.sh | |||
@@ -26,16 +26,25 @@ ceil4() | |||
26 | printf '%d\n' "$x" | 26 | printf '%d\n' "$x" |
27 | } | 27 | } |
28 | 28 | ||
29 | . loop-layer.sh | ||
30 | |||
31 | losetup_layers() | ||
32 | { | ||
33 | for fs in /cdrom/live/*.btrfs; do | ||
34 | fs_rw=/"${fs##*/}".rw | ||
35 | dd if=/dev/zero of="$fs_rw" bs=1M count=10 | ||
36 | losetup_snapshot "$fs" "$fs_rw" || return | ||
37 | done | ||
38 | } | ||
39 | |||
29 | init_samizdat() | 40 | init_samizdat() |
30 | { | 41 | { |
31 | local imgfile="$1" megs="$2" keyfile="$3" dev | 42 | local imgfile="$1" megs="$2" keyfile="$3" dev fs fs_rw |
32 | 43 | ||
33 | init_samizdat_blockdev "$imgfile" "$megs" "$keyfile" || return | 44 | init_samizdat_blockdev "$imgfile" "$megs" "$keyfile" || return |
34 | local blockdev=/dev/mapper/samizdatcrypt uuid | 45 | local blockdev=/dev/mapper/samizdatcrypt uuid |
35 | 46 | ||
36 | for fs in /cdrom/live/*.btrfs; do | 47 | losetup_layers || return |
37 | losetup -f "$fs" || return | ||
38 | done | ||
39 | modprobe btrfs || return | 48 | modprobe btrfs || return |
40 | btrfs device scan || return | 49 | btrfs device scan || return |
41 | 50 | ||
@@ -47,17 +56,6 @@ init_samizdat() | |||
47 | btrfs device add "$blockdev" /root || return | 56 | btrfs device add "$blockdev" /root || return |
48 | mount -o rw,remount /root || return | 57 | mount -o rw,remount /root || return |
49 | btrfs subvolume create /root/gpg || return | 58 | btrfs subvolume create /root/gpg || return |
50 | # TODO: Restart gpg agent with stored credentials. | ||
51 | |||
52 | # TODO: Actually, if we unconditionally added a ramdisk, we could go | ||
53 | # ahead with the boot, and then do this whole thing from the installed | ||
54 | # system (after pivot_root). That way, there would be no need to | ||
55 | # restart. | ||
56 | |||
57 | # Really, the option to install could be identical to the option to | ||
58 | # boot from RAM except that it would record the intent to install; or | ||
59 | # else it could be removed entirely, with an option to persist added | ||
60 | # as some kind of UI element. | ||
61 | mv /gpg/gnupghome /root/gpg/ || return | 59 | mv /gpg/gnupghome /root/gpg/ || return |
62 | 60 | ||
63 | bootdone root-mounted | 61 | bootdone root-mounted |
@@ -82,7 +80,7 @@ choose_uuid() | |||
82 | seen_devs=${line#*Total devices } | 80 | seen_devs=${line#*Total devices } |
83 | seen_devs=${seen_devs%% *} | 81 | seen_devs=${seen_devs%% *} |
84 | ;; | 82 | ;; |
85 | *path\ /dev/loop*) | 83 | *path\ /dev/mapper/*) |
86 | seen_loop=t;; | 84 | seen_loop=t;; |
87 | esac | 85 | esac |
88 | [ "$seen_loop" ] && echo "$seen_devs $seen_uuid" | 86 | [ "$seen_loop" ] && echo "$seen_devs $seen_uuid" |
@@ -90,13 +88,23 @@ choose_uuid() | |||
90 | uniq | sort -nr | head -n1 | (read _ x; echo $x) | 88 | uniq | sort -nr | head -n1 | (read _ x; echo $x) |
91 | } | 89 | } |
92 | 90 | ||
91 | filesystem_incomplete() | ||
92 | { | ||
93 | local n | ||
94 | n=$(btrfs filesystem show "$1" | sed -ne 's/.*Total devices \([^ ]*\) .*/\1/p') | ||
95 | [ "$n" != 1 ] | ||
96 | } | ||
97 | |||
93 | open_samizdat() | 98 | open_samizdat() |
94 | { | 99 | { |
95 | open_samizdat_blockdev "$@" || return | 100 | open_samizdat_blockdev "$@" || return |
96 | local blockdev=/dev/mapper/samizdatcrypt fs | 101 | local blockdev=/dev/mapper/samizdatcrypt fs |
97 | for fs in /cdrom/live/*.btrfs; do | 102 | |
98 | losetup -f "$fs" || return | 103 | # For this part, we don't necessarily need the cdrom. |
99 | done | 104 | # Unfortunately the init_gpg code is still getting the GPG key there. |
105 | if filesystem_incomplete "$blockdev"; then | ||
106 | losetup_layers | ||
107 | fi | ||
100 | modprobe btrfs || return | 108 | modprobe btrfs || return |
101 | btrfs device scan || return | 109 | btrfs device scan || return |
102 | mount -t btrfs -o subvol=ROOT "$blockdev" /root || return | 110 | mount -t btrfs -o subvol=ROOT "$blockdev" /root || return |