3
# Just create an image in the filesystem, then grow it.
10
local out="${TEMP_D}/out"
11
"$@" > "$out" 2>&1 || { echo "FAILED:" "$@"; cat "$out"; return 1; }
15
[ -z "$MP" ] || { echo "unmount $MP"; umount "$MP"; }
16
if [ -n "$LODEV" ]; then
18
echo "losetup --detach $LODEV";
19
losetup --detach "$LODEV";
21
[ ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
23
TEMP_D=$(mktemp -d ${TMPDIR:-/tmp}/${0##*/}.XXXXXX)
26
img="${TEMP_D}/disk.img"
33
truncate --size $osize "$img"
35
if [ "${PT_TYPE}" = "gpt" ]; then
36
rq sgdisk --new 1:2048: "$img"
38
echo "2048," | rq sfdisk --force --unit=S "$img"
41
truncate --size "$size" "$img"
43
echo "==== before ===="
44
sfdisk --list --unit=S "$img"
46
err="${TEMP_D}/gp.err"
47
out="${TEMP_D}/gp.out"
48
if ! growpart -v -v "$img" 1 2>"$err" > "$out"; then
53
echo "==== growpart-stderr ==="
55
echo "==== growpart-stdout ===="
57
grep -q "^CHANGED:" "$out" ||
58
{ echo "did not find 'CHANGED'"; exit 1; }
60
echo "==== after ===="
61
sfdisk --list --unit=S "$img"