#!/bin/bash

if [ $# -lt 1 ]; then
	echo "Run this script on dom0 (hypervisor)"
	echo "Usage: $0 [domU_name]"
	exit 3
fi

lvcreate -L512M -Zy --yes -n $1-boot hddstore

sfdisk -f -q --no-reread --no-tell-kernel /dev/hddstore/$1-boot <<EOF
label: dos
label-id: 0x3aa0b8ab
device: domu-boot
unit: sectors

domu-boot1 : start=        2048, size=     1046528, type=83, bootable
EOF

xl block-attach $1 phy:///dev/hddstore/$1-boot xvda w
