diff options
-rw-r--r-- | src/initrd/btrfs-create.sh | 16 | ||||
-rwxr-xr-x | src/parted-usb.sh | 17 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/initrd/btrfs-create.sh b/src/initrd/btrfs-create.sh index cdf73ef..9604340 100644 --- a/src/initrd/btrfs-create.sh +++ b/src/initrd/btrfs-create.sh | |||
@@ -58,7 +58,8 @@ cdrom_has_rootfs() | |||
58 | 58 | ||
59 | losetup_layers() | 59 | losetup_layers() |
60 | { | 60 | { |
61 | if cdrom_has_rootfs; then | 61 | if cdrom_has_rootfs |
62 | then | ||
62 | # TODO: This is some kind of shortcut or short circuit to find these | 63 | # TODO: This is some kind of shortcut or short circuit to find these |
63 | # files, that ought to be found through the grok-block system (i.e., | 64 | # files, that ought to be found through the grok-block system (i.e., |
64 | # event-driven rather than polling). | 65 | # event-driven rather than polling). |
@@ -68,14 +69,23 @@ losetup_layers() | |||
68 | dd if=/dev/zero of="$fs_rw" bs=1M count=10 | 69 | dd if=/dev/zero of="$fs_rw" bs=1M count=10 |
69 | losetup_snapshot "$fs" "$fs_rw" || return | 70 | losetup_snapshot "$fs" "$fs_rw" || return |
70 | done | 71 | done |
72 | elif [ -e /dev/disk/by-partlabel/samizdat-rootfs ] | ||
73 | then | ||
74 | local dev | ||
75 | for dev in samizdat-rootfs | ||
76 | do | ||
77 | umount /dev/disk/by-partlabel/$dev | ||
78 | dd if=/dev/zero of=/$dev.rw bs=1M count=10 | ||
79 | dm_snapshot /dev/disk/by-partlabel/$dev /$dev.rw | ||
80 | done | ||
71 | else | 81 | else |
72 | bootwait samizdat-nbd-dev | 82 | bootwait samizdat-nbd-dev |
73 | local dev | 83 | local dev |
74 | for dev in nbd0 nbd1; do | 84 | for dev in nbd0 nbd1 |
85 | do | ||
75 | dd if=/dev/zero of=/$dev.rw bs=1M count=10 | 86 | dd if=/dev/zero of=/$dev.rw bs=1M count=10 |
76 | dm_snapshot /dev/$dev /$dev.rw | 87 | dm_snapshot /dev/$dev /$dev.rw |
77 | done | 88 | done |
78 | return | ||
79 | fi | 89 | fi |
80 | } | 90 | } |
81 | 91 | ||
diff --git a/src/parted-usb.sh b/src/parted-usb.sh index 730dc26..50fcb78 100755 --- a/src/parted-usb.sh +++ b/src/parted-usb.sh | |||
@@ -34,7 +34,7 @@ initialize_target() | |||
34 | if [ "$ROOTFS" ] | 34 | if [ "$ROOTFS" ] |
35 | then | 35 | then |
36 | get_rootfs_size | 36 | get_rootfs_size |
37 | fallocate -l $(($(KiB 17) + $(MiB $end_keys) + rootfs_size)) "$target" | 37 | fallocate -l $(($(KiB 17) + $(MiB $end_keys) + rootfs_size + $(KiB 640))) "$target" |
38 | else | 38 | else |
39 | fallocate -l $(($(KiB 17) + $(MiB $end_keys))) "$target" | 39 | fallocate -l $(($(KiB 17) + $(MiB $end_keys))) "$target" |
40 | fi | 40 | fi |
@@ -74,6 +74,20 @@ make_target_bootable() | |||
74 | sync | 74 | sync |
75 | } | 75 | } |
76 | 76 | ||
77 | copy_rootfs() | ||
78 | { | ||
79 | if [ -z "$ROOTFS" ] | ||
80 | then | ||
81 | return | ||
82 | fi | ||
83 | [ -e "$ROOTFS" -a -b "$part"3 ] | ||
84 | get_rootfs_size | ||
85 | part_size=$(blockdev --getsize64 "$part"3) | ||
86 | [ "$rootfs_size" -le "$part_size" ] || die "rootfs_size=$rootfs_size > part_size=$part_size" | ||
87 | |||
88 | dd if="$ROOTFS" of="$part"3 | ||
89 | } | ||
90 | |||
77 | acquire_target_block_devices() | 91 | acquire_target_block_devices() |
78 | { | 92 | { |
79 | if [ -b "$target" ] | 93 | if [ -b "$target" ] |
@@ -143,6 +157,7 @@ globalize() | |||
143 | partition_target | 157 | partition_target |
144 | acquire_target_block_devices | 158 | acquire_target_block_devices |
145 | make_target_bootable | 159 | make_target_bootable |
160 | copy_rootfs | ||
146 | } | 161 | } |
147 | 162 | ||
148 | sanity_checks() | 163 | sanity_checks() |