From 15a884825af93f71e6e5b041923707d3b2e3d1cf Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 5 Sep 2012 14:34:38 -0400 Subject: [PATCH] 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 Reviewed-by: Brian Harring Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- build_library/base_image_util.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build_library/base_image_util.sh b/build_library/base_image_util.sh index dfc25d1d03..0e548d6b9b 100755 --- a/build_library/base_image_util.sh +++ b/build_library/base_image_util.sh @@ -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}" }