#!/bin/bash
# Usage: no command-line args.
# "arguments" come in environment:
-# TARGET a device filename, IMAGESIZE its size in XXXX what unit?
+# TARGET a device filename
+# IMAGESIZE the desired filesystem size in megabytes (rest will be swap)
# ARCH, DIST, MIRROR
# HOSTNAME, IP
+set -e
+
echo ,"${IMAGESIZE}"$',L,*\n,,S\n;\n;' | sfdisk -uM -H 255 -S 63 "$TARGET"
kpartx -a "$TARGET" # should be no-op in guest