Home > Uncategorized > Create Debian Lenny Xen VE

Create Debian Lenny Xen VE

October 28th, 2009 Leave a comment Go to comments

I got sick of doing the same bunch of things every time I created a new VE so I wrote myself a script. It takes only one argument: The path to the lvm volume you want to use as the root device.


#!/bin/bash

mkfs.ext3 "$1"
mkdir -p /media/buildvetmp
mount "$1" /media/buildvetmp
debootstrap lenny /media/buildvetmp http://aptcache:3142/ftp.us.debian.org/debian/
sed -n '/########/,$p' /root/buildve.sh | sed -n '/bin\/bash/,$p' | sed -n '/########/,$p' | sed -n '/bin\/bash/,$p' > /media/buildvetmp/buildve.sh
chmod 700 /media/buildvetmp/buildve.sh
chroot /media/buildvetmp /bin/bash /buildve.sh
rm /media/buildvetmp/buildve.sh
umount /media/buildvetmp
rm -r /media/buildvetmp

exit

###################chroot starts here
#!/bin/bash

echo "/dev/sda2 / ext3 relatime,nodiratime 0 0
/dev/sda1 none swap sw" >> /etc/fstab
echo "APT::Default-Release \"stable\";" >> /etc/apt/apt.conf
rm -f /etc/apt/sources.list
echo "deb http://ftp.us.debian.org/debian lenny main contrib non-free
deb http://ftp.us.debian.org/debian testing main contrib non-free
deb http://packages.dotdeb.org stable all" >> /etc/apt/sources.list
echo "Acquire::http::Proxy \"http://aptcache:3142/\";" >> /etc/apt/apt.conf.d/80proxy
echo "127.0.0.1 localhost" >> /etc/hosts
rm /etc/hostname
echo "localhost" >> /etc/hostname
echo "
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.0.0.49
netmask 255.255.0.0
network 10.0.0.0
broadcast 10.0.255.255
gateway 10.0.0.1" >> /etc/network/interfaces

apt-get update
apt-get -y install linux-modules-`uname -r` libc6-xen vim

echo "#!/bin/bash
apt-get -y install udev openssh-server syslog-ng ntp
sleep 5
rm -f /etc/rc2.d/S20installpkgs
sleep 1
shutdown -r now" >> /etc/rc2.d/S20installpkgs
chmod +x /etc/rc2.d/S20installpkgs

exit
Be Sociable, Share!
Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.

 

dork-e.com is Stephen Fry proof thanks to caching by WP Super Cache