Setting up Xen hosts and guests can be repetitive. Here are some scripts to automate the installation of Xen dom0 and domU using Ubuntu Server 12.04 LTS.
Perform a clean install of Ubuntu Sever 12.04. During the installation, use LVM while partitioning, and don’t install any optional packages other than the OpenSSH server. Once the installation is complete, and you have done any required customizations (network, hostname, etc.), run the following script (as sudo/root) to install and customize the Xen hypervisor. By default, the script assigns 512MB of RAM to dom0. Adjust line 24 to suit your needs. Also note that the script grants VNC access from everywhere – adjust line 29 to limit access.
When the script has finished, reboot the machine. [TODO: add tweaks to /etc/xen/xend-config.sxp for dom0-min-mem and to disable balooning]
Once the Xen hypervisor is installed, the following script will do a network-install of Ubuntu Server 12.04 as a para-virtualized guest. There are some user-configurable values at the top of the script. Run as sudo/root: