core-admin/linux/aux-tools/prepare-volatile-img.sh
Marek Marczykowski-Górecki de275cc917
core: leave volatile.img structure creation for the VM
This is already handled by a script in initramfs.

Fixes QubesOS/qubes-issues#1308
2015-11-25 01:35:04 +01:00

29 lines
469 B
Bash
Executable File

#!/bin/sh
if [ "`id -u`" != "0" ]; then
exec sudo $0 $*
fi
set -e
if ! echo $PATH | grep -q sbin; then
PATH=$PATH:/sbin:/usr/sbin
fi
FILENAME=$1
ROOT_SIZE=$2
SWAP_SIZE=$[ 1024 ]
if [ -z "$ROOT_SIZE" -o -z "$FILENAME" ]; then
echo "Usage: $0 <filename> <root.img size in MB>"
exit 1
fi
if [ -e "$FILENAME" ]; then
echo "$FILENAME already exists, not overriding"
exit 1
fi
TOTAL_SIZE=$[ $ROOT_SIZE + $SWAP_SIZE + 512 ]
truncate -s ${TOTAL_SIZE}M "$FILENAME"