github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/images/scripts/common/minimize.sh (about)

     1  #!/bin/sh -eux
     2  
     3  swapuuid="`/sbin/blkid -o value -l -s UUID -t TYPE=swap`";
     4  
     5  if [ "x${swapuuid}" != "x" ]; then
     6      # Whiteout the swap partition to reduce box size
     7      # Swap is disabled till reboot
     8      swappart="`readlink -f /dev/disk/by-uuid/$swapuuid`";
     9      /sbin/swapoff "$swappart";
    10      dd if=/dev/zero of="$swappart" bs=1M || echo "dd exit code $? is suppressed";
    11      /sbin/mkswap -U "$swapuuid" "$swappart";
    12  fi
    13  
    14  dd if=/dev/zero of=/EMPTY bs=1M || echo "dd exit code $? is suppressed";
    15  rm -f /EMPTY;
    16  # Block until the empty file has been removed, otherwise, Packer
    17  # will try to kill the box while the disk is still full and that's bad
    18  sync;