Ubuntu Precise domU under Debian Dom0

# configure domU
[ -z $DOMAIN_NAME ] && DOMAIN_NAME=precise
[ -z $DOMAIN_MAC ] && DOMAIN_MAC=00:00:ab:cd:11:10
[ -z $DOMAIN_RAM ] && DOMAIN_RAM=2Gb
[ -z $DOMAIN_HDD ] && DOMAIN_HDD=8Gb

# update bootstrap
http://www.panticz.de/update_debootstrap

# create vm
xen-create-image --hostname=${DOMAIN_NAME} \
--dist=oneiric --mirror=http://de.archive.ubuntu.com/ubuntu \
--lvm=vg1 --size=${DOMAIN_HDD} --fs=ext4 \
--memory=${DOMAIN_RAM} --swap=${DOMAIN_RAM} \
--dhcp --mac=${DOMAIN_MAC} --genpass=0 --password=terceS
#--pygrub

# rename vm config
mv /etc/xen/${DOMAIN_NAME}.cfg /etc/xen/${DOMAIN_NAME}

# set cpu count for domU
sed -i "s|vcpus = '1'|vcpus = '$(cat /proc/cpuinfo | grep processor | wc -l)'|g" /etc/xen/${DOMAIN_NAME}

# post config domU
mount /dev/vg1/${DOMAIN_NAME}-disk /mnt/
# configure locale
chroot /mnt/ sh -c "locale-gen en_US.UTF-8"
echo LANG=en_US.UTF-8 >> /mnt/etc/environment
echo LC_ALL=en_US.UTF-8 >> /mnt/etc/environment
#chroot /mnt/ sh -c "apt-get install -y linux-image-virtual"
umount /mnt/

# add to autostart
ln -s /etc/xen/${DOMAIN_NAME} /etc/xen/auto

# start domU
xm create -c ${DOMAIN_NAME}

# update
apt-get update
apt-get -y dist-upgrade

# reboot domU
poweroff
xm create -c ${DOMAIN_NAME}

# OLD Oneirc fix
# fix high CPU usage by rsyslog
if [ "$(uname -m)" == "x86_64" ]; then
wget http://mirror.netcologne.de/ubuntu/pool/main/r/rsyslog/rsyslog_4.2.0-2ubuntu8_amd64.deb -O /tmp/rsyslog_4.2.0-2ubuntu8_amd64.deb
else
wget http://mirror.netcologne.de/ubuntu/pool/main/r/rsyslog/rsyslog_4.2.0-2ubuntu8_i386.deb -O /tmp/rsyslog_4.2.0-2ubuntu8_i386.deb
fi
dpkg -i /tmp/rsyslog_4.2.0-2ubuntu8_*.deb
echo "rsyslog hold" | dpkg --set-selections # to unhold it: echo "rsyslog install" | dpkg --set-selections

# fix "ureadahead main process terminated with status 5"
sudo sed -i 's|start on starting mountall|start on mounted MOUNTPOINT=/var|' /etc/init/ureadahead.conf