Skip to content

Commit

Permalink
Whiteout both / and /boot
Browse files Browse the repository at this point in the history
This is a modified version of the code from boxcutter

Signed-off-by: Tim Smith <tsmith@chef.io>
  • Loading branch information
tas50 committed Nov 17, 2016
1 parent a5e552a commit 8acb783
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scripts/common/minimize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ case "$PACKER_BUILDER_TYPE" in
qemu) exit 0 ;;
esac

# Whiteout root
count=$(df --sync -kP / | tail -n1 | awk -F ' ' '{print $4}')
count=$(($count-1))
dd if=/dev/zero of=/tmp/whitespace bs=1M count=$count || echo "dd exit code $? is suppressed";
rm /tmp/whitespace

# Whiteout /boot
count=$(df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}')
count=$(($count-1))
dd if=/dev/zero of=/boot/whitespace bs=1M count=$count || echo "dd exit code $? is suppressed";
rm /boot/whitespace

set +e
swapuuid="`/sbin/blkid -o value -l -s UUID -t TYPE=swap`";
case "$?" in
Expand All @@ -21,8 +33,4 @@ if [ "x${swapuuid}" != "x" ]; then
/sbin/mkswap -U "$swapuuid" "$swappart";
fi

dd if=/dev/zero of=/EMPTY bs=1M || echo "dd exit code $? is suppressed";
rm -f /EMPTY;
# Block until the empty file has been removed, otherwise, Packer
# will try to kill the box while the disk is still full and that's bad
sync;

0 comments on commit 8acb783

Please sign in to comment.