Installing Ubuntu

From PrgmrWiki

I wrote this because of the somewhat difficult time I had installing a fresh copy of Ubuntu 10.04. Lucid's debootstrap triggers a bug in tar when it's run in a kernel prior to 2.6.22, making it impossible to bootstrap a Lucid install from the CentOS 5.2 rescue image. There also doesn't appear to be an updated Ubuntu tarball under /distros on girdle, which is why I created this page.

First, use parted to create the partitions. I used a 1GB bootstrap partition, a 100 MB /boot ext3 boot partition, and everything else for a ext4 root.

mkfs.ext3 -L PRGMRDISK1 /dev/xvda1
mount -n /dev/xvda1 /mnt
tar zxf /distros/debian64.tar.gz -C /mnt
chroot /mnt
passwd
exit

Reboot into the Debian install (which is happily using kernel 2.6.26).

mkfs.ext3 /dev/xvda2
mkfs.ext4 /dev/xvda3
tune2fs -E test_fs /dev/xvda3
mount /dev/xvda3 /mnt

Grab the debootstrap for Lucid from http://packages.ubuntu.com/lucid/debootstrap.

apt-get install binutils
mkdir debootstrap
dpkg-deb -x debootstrap*.deb debootstrap
export DEBOOTSTRAP_DIR=/root/debootstrap/usr/share/debootstrap
/root/debootstrap/usr/sbin/debootstrap --arch=amd64 --include ssh,linux-image-virtual lucid /mnt

Set up /mnt/etc/fstab:

/dev/xvda2      /boot   ext     errors=remount-ro       0       0
/dev/xvda3      /       ext4    errors=remount-ro       0       0
/var/swap       none    swap    sw      0       0

Set up /mnt/etc/network/interfaces:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
iface eth0 inet6 manual

Relocate the boot directory to the boot partition:

mkdir /tmp/boot
mount /dev/xvda2 /tmp/boot
cp -r /mnt/boot/* /tmp/boot

Add the new kernel to /boot/grub/menu.lst.

title Ubuntu 10.04
root (hd0,1)
kernel /vmlinuz-2.6.32-21-server root=/dev/xvda3 ro
initrd /initrd.img-2.6.32-21-server

title Ubuntu 10.04 single user
kernel /vmlinuz-2.6.32-21-server root=/dev/xvda3 ro
initrd /initrd.img-2.6.32-21-server

Don't forget to update the default= value.

Create a new user and add the user to the sudo group:

chroot /mnt
adduser user
usermod -a -G sudo user
passwd user
exit

TODO: set up serial console on hvc0, iptables Other useful things to consider installing: man, manpages, vim, bind9, apache2, ntp, language-pack-en sudo dpkg-reconfigure tzdata

Reboot, SSH to your VPS, login as the user you created and sudo su - away.