packer-arch/scripts/cleanup.sh
Christian Kotte c1125dc9b8 Add variable/option to control if zeros are written to the disk
It takes some time to write zeros to the disk and it aborts later if
less than 20GB are available.

Add variable to the template, cleanup script and add a new option to
wrapacker.
2020-08-13 15:53:08 -07:00

14 lines
435 B
Bash
Executable file

#!/usr/bin/bash -x
# Clean the pacman cache.
echo ">>>> cleanup.sh: Cleaning pacman cache.."
/usr/bin/pacman -Scc --noconfirm
# Write zeros to improve virtual disk compaction.
if [[ $WRITE_ZEROS == "true" ]]; then
echo ">>>> cleanup.sh: Writing zeros to improve virtual disk compaction.."
zerofile=$(/usr/bin/mktemp /zerofile.XXXXX)
/usr/bin/dd if=/dev/zero of="$zerofile" bs=1M
/usr/bin/rm -f "$zerofile"
/usr/bin/sync
fi