summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/initrd/btrfs-create.sh61
-rwxr-xr-xsrc/initrd/grok-block4
-rwxr-xr-xsrc/parted-usb.sh11
3 files changed, 43 insertions, 33 deletions
diff --git a/src/initrd/btrfs-create.sh b/src/initrd/btrfs-create.sh
index 9604340..c3cfcbb 100644
--- a/src/initrd/btrfs-create.sh
+++ b/src/initrd/btrfs-create.sh
@@ -71,13 +71,15 @@ losetup_layers()
71 done 71 done
72 elif [ -e /dev/disk/by-partlabel/samizdat-rootfs ] 72 elif [ -e /dev/disk/by-partlabel/samizdat-rootfs ]
73 then 73 then
74 local dev 74 # TODO: prevent raciness
75 for dev in samizdat-rootfs 75 umount /dev/disk/by-partlabel/samizdat-rootfs
76 do 76 if [ -e /dev/disk/by-partlabel/samizdat-patchfs ]
77 umount /dev/disk/by-partlabel/$dev 77 then
78 dd if=/dev/zero of=/$dev.rw bs=1M count=10 78 umount /dev/disk/by-partlabel/samizdat-patchfs
79 dm_snapshot /dev/disk/by-partlabel/$dev /$dev.rw 79 mountdev=/dev/disk/by-partlabel/samizdat-patchfs
80 done 80 else
81 mountdev=/dev/disk/by-partlabel/samizdat-rootfs
82 fi
81 else 83 else
82 bootwait samizdat-nbd-dev 84 bootwait samizdat-nbd-dev
83 local dev 85 local dev
@@ -93,20 +95,24 @@ init_samizdat()
93{ 95{
94 local blockdev="$1" imgfile="$2" uuid 96 local blockdev="$1" imgfile="$2" uuid
95 97
96 losetup_layers || return 98 losetup_layers || return
97 modprobe btrfs || return 99 modprobe btrfs || return
98 btrfs device scan || return 100 btrfs device scan || return
99 101
100 uuid=$(choose_uuid) || return 102 if [ "$mountdev" ]
101 [ "$uuid" ] || return 103 then
102 104 mount -t btrfs "$mountdev" /root || return
103 mount -t btrfs UUID="$uuid" /root || return 105 else
106 uuid=$(choose_uuid) || return
107 [ "$uuid" ] || return
108 mount -t btrfs UUID="$uuid" /root || return
109 fi
104 110
105 btrfs device add "$blockdev" /root || return 111 btrfs device add "$blockdev" /root || return
106 mount -o rw,remount /root || return 112 mount -o rw,remount /root || return
107 samizdat_movemounts "$imgfile" || return 113 samizdat_movemounts "$imgfile" || return
108 114
109 initialize_root_filesystem || return 115 initialize_root_filesystem || return
110} 116}
111 117
112movemounts() 118movemounts()
@@ -248,24 +254,15 @@ filesystem_incomplete()
248 254
249partition_new_hard_drive_DESTROYING_EVERYTHING() 255partition_new_hard_drive_DESTROYING_EVERYTHING()
250{ 256{
251 # TODO: get the actual size of the btrfs master and actually triple it. The empty 257 local target="$1" sz=2910
252 # space can be left available to allow the local machine to boot a
253 # locally-regenerated rootfs seed.
254 sz=3
255 u=GiB
256 actual_sz=$sz$u
257 tripled_sz=$((sz * 3))$u
258 pct=100% # TODO: use 50%
259
260 local target="$1" sz=6GiB
261 # [ "$(parted -sm "$target" print | grep -c :)" = 1 ] || return 258 # [ "$(parted -sm "$target" print | grep -c :)" = 1 ] || return
262 parted "$target" -sm \ 259 parted "$target" -sm \
263 unit B \ 260 unit MiB \
264 mklabel gpt \ 261 mklabel gpt \
265 mkpart samizdat-grub-incomplete 32KiB 8MiB \ 262 mkpart samizdat-grub-incomplete 1 8 \
266 set 1 bios_grub on \ 263 set 1 bios_grub on \
267 mkpart samizdat-plaintext-incomplete btrfs 64MiB $actual_sz \ 264 mkpart samizdat-plaintext-incomplete btrfs 64 $((sz + 64)) \
268 mkpart samizdat-luks-encrypted-incomplete $tripled_sz $pct \ 265 mkpart samizdat-luks-encrypted-incomplete $((sz + 64)) 100% \
269 && 266 &&
270 udevadm settle 267 udevadm settle
271} 268}
diff --git a/src/initrd/grok-block b/src/initrd/grok-block
index 0b5f3f9..f925061 100755
--- a/src/initrd/grok-block
+++ b/src/initrd/grok-block
@@ -186,6 +186,7 @@ grok_block()
186 return 186 return
187 ;; 187 ;;
188 samizdat-keys) ;; 188 samizdat-keys) ;;
189 samizdat-rootfs) ;;
189 samizdat-grub) return ;; 190 samizdat-grub) return ;;
190 samizdat-luks-encrypted) 191 samizdat-luks-encrypted)
191 menu-select boot-native "$(parent_device "$DEVNAME")" 192 menu-select boot-native "$(parent_device "$DEVNAME")"
@@ -219,6 +220,9 @@ grok_block()
219 # TODO: Need option to boot the partitions we create 220 # TODO: Need option to boot the partitions we create
220 # TODO: And what if we create partitions and then reboot the machine mid-install? 221 # TODO: And what if we create partitions and then reboot the machine mid-install?
221 222
223 elif [ "$ID_PART_ENTRY_NAME" = samizdat-rootfs ]; then
224 :
225
222 elif [ "$ID_PART_ENTRY_NAME" = samizdat-keys ]; then 226 elif [ "$ID_PART_ENTRY_NAME" = samizdat-keys ]; then
223 mkdir -p /gpg 227 mkdir -p /gpg
224 cp -a "$mountpoint"/gnupghome /gpg/ && bootdone samizdat-gpg && bootdone samizdat-cdrom 228 cp -a "$mountpoint"/gnupghome /gpg/ && bootdone samizdat-gpg && bootdone samizdat-cdrom
diff --git a/src/parted-usb.sh b/src/parted-usb.sh
index 50fcb78..0f62019 100755
--- a/src/parted-usb.sh
+++ b/src/parted-usb.sh
@@ -199,7 +199,8 @@ boot_vm()
199 -smp 2 \ 199 -smp 2 \
200 -m 512 \ 200 -m 512 \
201 -k en-us \ 201 -k en-us \
202 -net nic,model=virtio,macaddr=$MAC \ 202 -net nic,model=virtio,macaddr="$MAC" \
203 -net tap,ifname=tap0,script=no,downscript=no \
203 -vga qxl \ 204 -vga qxl \
204 -drive file="$boot_drive",format=raw \ 205 -drive file="$boot_drive",format=raw \
205 -drive file="$installer_target",format=raw 206 -drive file="$installer_target",format=raw
@@ -207,6 +208,14 @@ boot_vm()
207 208
208. samizdat-paths.sh || die 'samizdat-paths.sh not found' 209. samizdat-paths.sh || die 'samizdat-paths.sh not found'
209samizdat_linux_dir=/boot 210samizdat_linux_dir=/boot
211
212
213
214ROOTFS=rootfs/samizdat.seed.btrfs
215PATCHFS=rootfs/samizdat.patch.btrfs
216GPG_INPUT_DIR=/root/.gnupg
217
218
210: ${GPG_INPUT_DIR:=/cdrom/gnupghome} 219: ${GPG_INPUT_DIR:=/cdrom/gnupghome}
211: ${GRUB_CONFIG:=conf/grub.cfg} 220: ${GRUB_CONFIG:=conf/grub.cfg}
212start_keys=64 # megs 221start_keys=64 # megs