Net-install a custom linux distro on Cloud Servers

I originally posted this article over at Failverse, but I figured I should have it on my own blog as well. This guide may be a little dated as Rackspace has updated their host servers to utilize a newer version of Xen. Your mileage may vary.

This guide will walk you through installing a custom linux distro to Rackspace Cloud Servers without the need of taring up a file system from a donor box. This particular guide is specific to openSuse, but the same method can be used to install other distros that support automated/remote install.

This process is entirely unsupported by Rackspace.

First, some documentation before we get started:
http://en.opensuse.org/SDB:Remote_installation
http://en.opensuse.org/SDB:Linuxrc

Spin up a box on the cloud. I went with Debian for this step, but you can use whichever variant of linux you please. First thing to do is to gather up your networking info: IPs, netmasks, gateway, static routes, and DNS servers (on Debian, just cat /etc/network/interfaces and /etc/resolv.conf for all of the info you need). Make a /boot and /boot/grub, and move to /boot. Now we need to grab the xen-compatible installer kernel and initrd:

/boot# wget http://download.opensuse.org/distribution/11.4/repo/oss/boot/x86_64/vmlinuz-xen
/boot# wget http://download.opensuse.org/distribution/11.4/repo/oss/boot/x86_64/initrd-xen

Now edit /boot/grub/menu.lst and make an entry for openSuse. We’re going to want it to look like this (fill in the network config with what you pulled previously):

timeout 5
default 0
title openSuse Install
      root (hd0)
      kernel /boot/vmlinuz-xen textmode=1 noapic ssh=1 sshpassword="yoursshpassword" addswap=/dev/xvda2 install=http://download.opensuse.org/distribution/11.4/repo/oss/ hostip=serverip netmask=servernetmask gateway=servergateway nameserver=serverdnsserver
      initrd /boot/initrd-xen

Submit a ticket to Rackspace support to enable PV-GRUB for you. Go ahead, I’ll wait.

If all goes well, you should see the box pinging after they switch it over to PV-GRUB (if all did not go well, kick the box into rescue mode and double check your work). SSH into it using user root and the password that you set in the “sshpassword” kernel option. Once you’re at the shell, run “yast”. This will launch the text based installer.

On the Installation Mode screen, un-select “Use Automatic Configuration”. On the Desktop Selection screen, select “Other” -> “Minimal Server Selection (Text Mode)”. On the “Suggested Partitioning” screen, select “Edit Partition Setup…”. On the next screen tab to /dev/xvda1 and press enter. Then tab to “Edit” and hit enter. Match these settings (NOTE: Only use EXT3! PV-GRUB freaked out when I tried EXT4):

  Edit Partition /dev/xvda1
                        ┌Formatting Options───────────┐
                        │ (x) Format partition        │
                        │     File System             │
                        │     Ext3                    │
                        │     [     Options...      ] │
                        │ ( ) Do not format partition │
                        │     File system ID:         │
                        │     0x83 Linux              │
                        │ [ ] Encrypt device          │
                        └─────────────────────────────┘
                        ┌Mounting Options─────────────┐
                        │ (x) Mount partition         │
                        │     Mount Point             │
                        │     /                       │
                        │     [  Fstab Options...   ] │
                        │ ( ) Do not mount partition  │
                        └─────────────────────────────┘

Then hit “Finish”, then “Accept”. Continue on with creating your user, uncheck “Automatic Login” (not sure how that would work for a server….). I also unchecked “Use this password for system administrator” since I wanted to set a password for root. On the Installation Settings screen, be sure to enable SSH and open it in the firewall. Now hit Install. It should chug along just fine until it gets to installing grub. Don’t bother to retry installing the boot loader, just continue along. Stop it from rebooting and open up a second SSH connection to the box and run the following commands:

~# mount /dev/xvda1 /mnt/
~# sed -i 's/hd0,0/hd0/' /mnt/boot/grub/menu.lst
~# umount /mnt/

Now it is safe to reboot. Try to SSH to the box when it starts responding to ping. Congrats, you’ve just installed openSuse on Cloud Servers the less ghetto way =P.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>