prepare-volatile-img.sh 428 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. set -e
  3. if ! echo $PATH | grep -q sbin; then
  4. PATH=$PATH:/sbin:/usr/sbin
  5. fi
  6. FILENAME=$1
  7. ROOT_SIZE=$2
  8. SWAP_SIZE=$[ 1024 ]
  9. if [ -z "$ROOT_SIZE" -o -z "$FILENAME" ]; then
  10. echo "Usage: $0 <filename> <root.img size in MB>"
  11. exit 1
  12. fi
  13. if [ -e "$FILENAME" ]; then
  14. echo "$FILENAME already exists, not overriding"
  15. exit 1
  16. fi
  17. umask 002
  18. TOTAL_SIZE=$[ $ROOT_SIZE + $SWAP_SIZE + 512 ]
  19. truncate -s ${TOTAL_SIZE}M "$FILENAME"