summaryrefslogtreecommitdiff
path: root/old-school/lvm-create.sh
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-04-28 04:56:28 -0400
committerAndrew Cady <d@jerkface.net>2016-04-28 04:56:28 -0400
commitd0c64cb0a0d6673e7f17363d77c31f17c3aed4ce (patch)
tree81c8b57ab9edc0d7f05634a46dea7a3f4d94f3c6 /old-school/lvm-create.sh
parent29842334b19f9404536111200c0c84b25b333668 (diff)
share more code between boot-new and boot-ram -- this fixes a bug
Diffstat (limited to 'old-school/lvm-create.sh')
-rw-r--r--old-school/lvm-create.sh41
1 files changed, 22 insertions, 19 deletions
diff --git a/old-school/lvm-create.sh b/old-school/lvm-create.sh
index d1ffc51..0e88995 100644
--- a/old-school/lvm-create.sh
+++ b/old-school/lvm-create.sh
@@ -28,6 +28,8 @@ ceil4()
28 28
29losetup_layers() 29losetup_layers()
30{ 30{
31 bootwait samizdat-cdrom
32 local fs fs_rw
31 for fs in /cdrom/rootfs/*.btrfs; do 33 for fs in /cdrom/rootfs/*.btrfs; do
32 fs_rw=/"${fs##*/}".rw 34 fs_rw=/"${fs##*/}".rw
33 dd if=/dev/zero of="$fs_rw" bs=1M count=10 35 dd if=/dev/zero of="$fs_rw" bs=1M count=10
@@ -37,25 +39,22 @@ losetup_layers()
37 39
38init_samizdat() 40init_samizdat()
39{ 41{
40 local imgfile="$1" megs="$2" keyfile="$3" dev fs fs_rw 42 local blockdev="$1" imgfile="$2" uuid
41 43
42 init_samizdat_blockdev "$imgfile" "$megs" "$keyfile" || return 44 losetup_layers || return
43 local blockdev=/dev/mapper/samizdatcrypt uuid 45 modprobe btrfs || return
46 btrfs device scan || return
44 47
45 losetup_layers || return 48 uuid=$(choose_uuid) || return
46 modprobe btrfs || return 49 [ "$uuid" ] || return
47 btrfs device scan || return
48
49 uuid=$(choose_uuid) || return
50 [ "$uuid" ]
51 50
52 mount -t btrfs -o subvol=ROOT UUID="$uuid" /root || return 51 mount -t btrfs -o subvol=ROOT UUID="$uuid" /root || return
53 52
54 btrfs device add "$blockdev" /root || return 53 btrfs device add "$blockdev" /root || return
55 mount -o rw,remount /root || return 54 mount -o rw,remount /root || return
56 samizdat_movemounts "$imgfile" 55 samizdat_movemounts "$imgfile" || return
57 56
58 initialize_root_filesystem || return 57 initialize_root_filesystem || return
59 58
60 bootdone root-mounted 59 bootdone root-mounted
61} 60}
@@ -64,12 +63,16 @@ samizdat_movemounts()
64{ 63{
65 local imgfile="$1" mountpoint 64 local imgfile="$1" mountpoint
66 65
67 mountpoint=$(mountpoint_of "$imgfile") || return 66 if [ "$imgfile" ]; then
68 mkdir /root/cdrom /root/outerfs 67 mountpoint=$(mountpoint_of "$imgfile") || return
68 mkdir /root/outerfs
69 mount -o move "$mountpoint" /root/outerfs
70 fi
71 mkdir /root/cdrom
69 mount -o move /cdrom /root/cdrom 72 mount -o move /cdrom /root/cdrom
70 mount -o move "$mountpoint" /root/outerfs 73# mkdir /run/initramfs/samizdat
71 mkdir /run/initramfs/samizdat 74# mv /var/log /run/initramfs/samizdat/log
72 mv /var/log /run/initramfs/samizdat/log 75 true
73} 76}
74 77
75mountpoint_of() 78mountpoint_of()
@@ -162,7 +165,7 @@ open_samizdat()
162 165
163init_samizdat_lodev() 166init_samizdat_lodev()
164{ 167{
165 local imgfile="$1" megs=$(ceil4 "$2") 168 local imgfile="$1" megs=$(ceil4 "$2") dev
166 truncate -s ${megs}M "$imgfile" || return 169 truncate -s ${megs}M "$imgfile" || return
167 dev=$(losetup -f) && losetup "$dev" "$imgfile" || return 170 dev=$(losetup -f) && losetup "$dev" "$imgfile" || return
168 echo "$dev" 171 echo "$dev"