summaryrefslogtreecommitdiff
path: root/src/initrd/btrfs-create.sh
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2017-03-28 16:07:09 -0400
committerAndrew Cady <d@jerkface.net>2017-03-28 16:12:28 -0400
commit5160fd50cf2bf09700c20236cac992a7a85fc943 (patch)
treec4bef4cc1b8a0635222cf83b4927f5fdcdedf635 /src/initrd/btrfs-create.sh
parent2a575328ac1432c21e0b983d2432f1f64dff0f96 (diff)
Use pxelinux "ipappend" option to choose rootfs source
This fixes the issue described in the first 'netkeys' commit, where the network would need to be available even when it was not used. The "ipappend" option results in a $BOOTIF variable in the initrd environment. This variable is now used to determine whether to wait on the network for a rootfs & keys, or to wait on the boot device becoming available to determine whether it has the keys. That is, there may or may not be a boot device which may or may not have keys and/or rootfs, but we will always know for sure whether it does, therefore there are no races and no waiting on the network unnecessarily. The qemu.sh script was updated to provide the BOOTIF variable when PXE boot is emulated.
Diffstat (limited to 'src/initrd/btrfs-create.sh')
-rw-r--r--src/initrd/btrfs-create.sh24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/initrd/btrfs-create.sh b/src/initrd/btrfs-create.sh
index a1a53ed..8a0cd87 100644
--- a/src/initrd/btrfs-create.sh
+++ b/src/initrd/btrfs-create.sh
@@ -27,22 +27,28 @@ ceil4()
27 printf '%d\n' "$x" 27 printf '%d\n' "$x"
28} 28}
29 29
30cdrom_has_rootfs()
31{
32 [ ! "$BOOTIF" ] || return
33 bootwait samizdat-cdrom
34 [ -d /cdrom/rootfs ]
35}
36
30losetup_layers() 37losetup_layers()
31{ 38{
32 if netbooting; then 39 if cdrom_has_rootfs; then
40 local fs fs_rw
41 for fs in /cdrom/rootfs/*.btrfs; do
42 fs_rw=/"${fs##*/}".rw
43 dd if=/dev/zero of="$fs_rw" bs=1M count=10
44 losetup_snapshot "$fs" "$fs_rw" || return
45 done
46 else
33 bootwait samizdat-nbd-dev 47 bootwait samizdat-nbd-dev
34 dd if=/dev/zero of=/nbd0.rw bs=1M count=10 48 dd if=/dev/zero of=/nbd0.rw bs=1M count=10
35 dm_snapshot /dev/nbd0 /nbd0.rw 49 dm_snapshot /dev/nbd0 /nbd0.rw
36 return 50 return
37 fi 51 fi
38
39 bootwait samizdat-cdrom
40 local fs fs_rw
41 for fs in /cdrom/rootfs/*.btrfs; do
42 fs_rw=/"${fs##*/}".rw
43 dd if=/dev/zero of="$fs_rw" bs=1M count=10
44 losetup_snapshot "$fs" "$fs_rw" || return
45 done
46} 52}
47 53
48init_samizdat() 54init_samizdat()