3 08 2013
Setting up a VDS using a stacklet image.
Stacklet is a super awesome site that provides OS images for several virtualization platforms. Since we mostly use Xen at work, this guide will be for Xen (funnily enough). Stacklet does require a subscription, but it’s pretty cheap.
On the site find the image you want to use, for this guide we will be setting up a CentOS 6.4 x86-64 server.
CentOS 6.4 for Xen on x86-64
Format: Xen 3/Xen 4 Architecture: x86-64
Login to your VM node and download the image like so
curl -O "http://stacklet.com/dl/4a....84c6f3d/centos.6-4.x86-64.20130309.img.tar.bz2"
It might take a little while to download, they have terrible speeds. :(
Once it’s downloaded, extract it.
tar -xvf centos.6-4.x86-64.20130309.img.tar.bz2
You will have two files;
centos.6-4.x86-64.20130309.img, which is the image.
centos.6-4.x86-64.20130309.pygrub.cfg, which is a example config file.
Make a directory to mount the image to.
mkdir /root/CentOS64
Mount the image to the directory as a loopback device.
mount -o loop centos.6-4.x86-64.20130309.img /root/CentOS64/
Now if you list the contents of the directory you created you will see the file system of the image.
ls -la /root/CentOS64/ total 108 drwxr-xr-x 22 root root 4096 Mar 9 16:10 . dr-xr-x---. 9 root root 4096 Aug 3 20:58 .. dr-xr-xr-x 2 root root 4096 Mar 9 15:56 bin dr-xr-xr-x 4 root root 4096 Mar 9 15:57 boot drwxr-xr-x 2 root root 4096 Sep 23 2011 dev drwxr-xr-x 60 root root 4096 Mar 9 15:58 etc drwxr-xr-x 2 root root 4096 Sep 23 2011 home dr-xr-xr-x 9 root root 4096 Mar 9 14:59 lib dr-xr-xr-x 7 root root 12288 Mar 9 15:56 lib64 drwx------ 2 root root 16384 Mar 9 16:10 lost+found drwxr-xr-x 2 root root 4096 Sep 23 2011 media drwxr-xr-x 2 root root 4096 Sep 23 2011 mnt drwxr-xr-x 2 root root 4096 Sep 23 2011 opt drwxr-xr-x 2 root root 4096 Aug 10 2012 proc dr-xr-x--- 2 root root 4096 Mar 9 15:00 root dr-xr-xr-x 2 root root 4096 Mar 9 15:57 sbin drwxr-xr-x 2 root root 4096 Sep 23 2011 selinux drwxr-xr-x 2 root root 4096 Sep 23 2011 srv drwxr-xr-x 2 root root 4096 Sep 23 2011 sys drwxrwxrwt 2 root root 4096 Mar 9 15:58 tmp drwxr-xr-x 13 root root 4096 Mar 9 14:54 usr drwxr-xr-x 17 root root 4096 Mar 9 14:54 var
Then you just need to setup the VDS as normal.
Create the logical volume.
lvcreate -L20G -n exampleSetup vg
Create the swap.
lvcreate -L1G -n exampleSetup-swap vg
Make the filesystem.
mkfs -t ext3 /dev/vg/exampleSetup
Make the swap
mkswap /dev/vg/exampleSetup-swap
Make a directory to mount the volume to.
mkdir /mnt/exampleSetup
Mount the volume
mount /dev/vg/exampleSetup /mnt/exampleSetup
Copy the CentOS image to the mountpoint.
cp -ax /root/CentOS64/* /mnt/exampleSetup
Set the hostname.
nano /mnt/exampleSetup/etc/sysconfig/network
NETWORKING=yes HOSTNAME=exampleSetup.domain.tld
Setup networking
nano /mnt/exampleSetup/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=static ONBOOT=yes TYPE=Ethernet IPADDR=192.168.1.55 GATEWAY=192.168.1.1 NETMASK=255.255.255.0
Set nameservers.
nano /mnt/exampleSetup/etc/resolv.conf
nameserver 8.8.8.8 nameserver 8.8.4.4
Add swap to fstab.
nano /mnt/exampleSetup/etc/fstab
/dev/xvda / ext4 defaults,errors=remount-ro 1 1 none /dev/shm tmpfs defaults 0 0 /dev/xvdb swap swap defaults 0 0 /usr/tmpDSK /tmp ext3 defaults,noauto 0 0
Unmount the volume.
umount /mnt/cpanelImage
Generate a MAC address with the easymac script and note it down.
/usr/local/sbin/easymac.sh -x
Change to the Xen config directory
cd /etc/xen/
Make a new config file.
nano exampleSetup
bootloader = "/usr/bin/pygrub" memory = 768 name = "exampleSetup" vif = [ 'bridge=<bridge>, mac=<mac address>' ] disk = ['phy:vg/exampleSetup,xvda,w','phy:vg/exampleSetup-swap,xvdb,w'] root = "/dev/xvda" extra = "fastboot" vcpus = 4 acpi = 0
Once you have saved/exited the config you can start the VM.
xm create -c exampleSetup
The -c attaches a console.
Login with root and the password is password.
Change the password immediately!
Once the password has been changed, just check you can ping things.
ping google.com PING google.com (173.194.34.35) 56(84) bytes of data. 64 bytes from par03s03-in-f3.1e100.net (173.194.34.35): icmp_seq=1 ttl=53 time=9.59 ms
Then ssh to your VDS from your desktop.
Logout of the root session on the console by typing ‘exit’ and then to escape from the console back to the nodes shell do;
Ctrl + ]
Update CentOS over ssh.
yum -y update
Then you are ready to do what you want with it. :)
Creating users with Puppet. Yum: DB_RUNRECOVERY: Fatal error, run database recovery