diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/initrd/btrfs-create.sh | 24 | ||||
-rwxr-xr-x | src/initrd/grok-block | 7 | ||||
-rwxr-xr-x | src/qemu.sh | 16 |
3 files changed, 31 insertions, 16 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 | ||
30 | cdrom_has_rootfs() | ||
31 | { | ||
32 | [ ! "$BOOTIF" ] || return | ||
33 | bootwait samizdat-cdrom | ||
34 | [ -d /cdrom/rootfs ] | ||
35 | } | ||
36 | |||
30 | losetup_layers() | 37 | losetup_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 | ||
48 | init_samizdat() | 54 | init_samizdat() |
diff --git a/src/initrd/grok-block b/src/initrd/grok-block index 3ad0432..f44ed19 100755 --- a/src/initrd/grok-block +++ b/src/initrd/grok-block | |||
@@ -150,8 +150,11 @@ grok_block() | |||
150 | # because while it's mounted, the dmsetup stuff will fail with device busy. | 150 | # because while it's mounted, the dmsetup stuff will fail with device busy. |
151 | /dev/nbd0) | 151 | /dev/nbd0) |
152 | if [ -e /bootwait/samizdat-nbd-dev ] | 152 | if [ -e /bootwait/samizdat-nbd-dev ] |
153 | then return | 153 | then |
154 | else wait_for_files_ /sys/block/nbd0/pid | 154 | return |
155 | else | ||
156 | bootwait nbd-script | ||
157 | wait_for_files_ /sys/block/nbd0/pid | ||
155 | fi | 158 | fi |
156 | ;; | 159 | ;; |
157 | esac | 160 | esac |
diff --git a/src/qemu.sh b/src/qemu.sh index b095eb8..3b8cdec 100755 --- a/src/qemu.sh +++ b/src/qemu.sh | |||
@@ -12,6 +12,8 @@ layered=${samizdat_iso_dir}/${iso%.iso}.layered.iso | |||
12 | 12 | ||
13 | initrd.sh || { echo "initrd.sh failed" >&2; exit 1; }; | 13 | initrd.sh || { echo "initrd.sh failed" >&2; exit 1; }; |
14 | 14 | ||
15 | [ "$NO_NET" ] || USE_NET=y | ||
16 | |||
15 | NET='tap,vlan=0,ifname=tap0,script=no,downscript=no' | 17 | NET='tap,vlan=0,ifname=tap0,script=no,downscript=no' |
16 | 18 | ||
17 | [ "$SLOW_BOOT" ] || QEMU_LOADS_LINUX=y | 19 | [ "$SLOW_BOOT" ] || QEMU_LOADS_LINUX=y |
@@ -21,9 +23,13 @@ NET='tap,vlan=0,ifname=tap0,script=no,downscript=no' | |||
21 | 23 | ||
22 | initrd=${samizdat_isolinux_dir}/linux/initrd.img | 24 | initrd=${samizdat_isolinux_dir}/linux/initrd.img |
23 | kernel=${samizdat_isolinux_dir}/linux/vmlinuz | 25 | kernel=${samizdat_isolinux_dir}/linux/vmlinuz |
24 | kcmdline_NET='boot=samizdat components quiet splash nbdroot=192.168.10.1,samizdat.btrfs nbddev=/dev/nbd0 ip=dhcp netkeys' | ||
25 | kcmdline_CDROM_NET='boot=samizdat components quiet splash nbdroot=192.168.10.1,samizdat.btrfs nbddev=/dev/nbd0 ip=dhcp' | ||
26 | kcmdline_CDROM='boot=samizdat components quiet splash' | 26 | kcmdline_CDROM='boot=samizdat components quiet splash' |
27 | kcmdline_CDROM_NET="${kcmdline_CDROM} nbdroot=192.168.10.1,samizdat.btrfs nbddev=/dev/nbd0 ip=dhcp" | ||
28 | kcmdline_NET="${kcmdline_CDROM_NET} netkeys" | ||
29 | |||
30 | MAC='52-54-00-12-34-56' | ||
31 | |||
32 | kcmdline_BOOTIF="BOOTIF=01-$MAC" | ||
27 | 33 | ||
28 | set -- | 34 | set -- |
29 | if [ "$USE_ISO" ]; then | 35 | if [ "$USE_ISO" ]; then |
@@ -40,7 +46,7 @@ if [ "$USE_ISO" ]; then | |||
40 | fi | 46 | fi |
41 | else | 47 | else |
42 | if [ "$QEMU_LOADS_LINUX" ]; then | 48 | if [ "$QEMU_LOADS_LINUX" ]; then |
43 | set -- "$@" -initrd "$initrd" -kernel "$kernel" -append "$kcmdline_NET" | 49 | set -- "$@" -initrd "$initrd" -kernel "$kernel" -append "$kcmdline_NET $kcmdline_BOOTIF" |
44 | else | 50 | else |
45 | set -- "$@" -boot n | 51 | set -- "$@" -boot n |
46 | fi | 52 | fi |
@@ -49,8 +55,8 @@ fi | |||
49 | set -x | 55 | set -x |
50 | sudo qemu-system-x86_64 -enable-kvm -smp 2 -m 640 -k en-us \ | 56 | sudo qemu-system-x86_64 -enable-kvm -smp 2 -m 640 -k en-us \ |
51 | -vga qxl \ | 57 | -vga qxl \ |
52 | -net nic,vlan=0,model=virtio \ | 58 | -net nic,vlan=0,model=virtio,macaddr=$MAC \ |
53 | -net "$NET" \ | 59 | ${USE_NET:+ -net "$NET"} \ |
54 | -rtc base=localtime \ | 60 | -rtc base=localtime \ |
55 | -hda "$disk" \ | 61 | -hda "$disk" \ |
56 | "$@" | 62 | "$@" |