tisdag 25 maj 2010

Creating a Xen Ubuntu Lucid DomU

# work in progress
# create a new file system, add a user, enable networking with dummy ip4 address,  create the VM

vg=cluster5
export vm=myvm
LUCID=/mnt
lvcreate --size 1G --name $vm  $vg
mkfs.ext4 /dev/$vg/$vm

mount /dev/$vg/$vm $LUCID
debootstrap --variant=buildd --arch i386 lucid $LUCID http://se.archive.ubuntu.com/ubuntu
chroot $LUCID
export LC_ALL=C

cat > /etc/apt/sources.list <<EOF
deb http://se.archive.ubuntu.com/ubuntu lucid          main restricted universe
deb http://se.archive.ubuntu.com/ubuntu lucid-security main restricted universe
EOF

apt-get update
apt-get -y install ubuntu-minimal openssh-server
adduser --ingroup sudo larsr
# fill in stuff

echo $vm > /etc/hostname
cat >>/etc/network/interfaces <<EOF
auto eth0
iface eth0 inet static
 address 1.1.1.1
 netmask 255.255.255.255
EOF

exit
umount $LUCID

xm create /dev/null kernel=/boot/vmlinuz-2.6.31.13 ramdisk=/boot/initrd.img-2.6.31.13 name=$vm  disk=phy:/dev/$vg/$vm,/dev/xvda1,w  root=/dev/xvda1 vif="mac=00:16:3e:0e:34:14,vifname=$vm" -c

Then you can create snapshots of the disk very quickly (thanks to LVM)
orig=vm
vm=newvm
lvcreate --snapshot --size 1G --name $vm $vg/$orig
mount /dev/$vg/$vm /mnt
echo $vm > /mnt/etc/hostname 
umount /mnt

Inga kommentarer:

Skicka en kommentar