build_image: dump debug info when target image is full

When we run out of space in the target image, it can be unclear that this
is the actual issue.  Detect this case and issue an appropriate warning,
and dump disk usage to help people triage things.

BUG=chromium-os:34167
TEST=`./build_image --board=amd64-generic` passed normally
TEST=`./build_image --board=amd64-generic factory_install` triggered the out-of-space check

Change-Id: I3052892a8c8bc386c7f08e1df26432eea2285563
Reviewed-on: https://gerrit.chromium.org/gerrit/32250
Reviewed-by: Peter Mayo <petermayo@chromium.org>
Reviewed-by: Brian Harring <ferringb@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2012-09-05 14:34:38 -04:00 committed by Gerrit
parent 0887dc2f7a
commit 15a884825a

View File

@ -16,6 +16,16 @@ STATEFUL_FS_IMG="${BUILD_DIR}/stateful_partition.image"
ESP_FS_IMG=${BUILD_DIR}/esp.image
cleanup_rootfs_loop() {
# See if we ran out of space.
local df=$(df -B 1M "${ROOT_FS_DIR}")
if [[ ${df} == *100%* ]]; then
error "Here are the biggest files (by disk usage):"
# Send final output to stderr to match `error` behavior.
sudo find "${ROOT_FS_DIR}" -xdev -type f -printf '%b %P\n' | \
awk '$1 > 16 { $1 = $1 * 512; print }' | sort -n | tail -100 1>&2
error "Target image has run out of space:"
error "${df}"
fi
sudo umount -d "${ROOT_FS_DIR}"
}