Archive

Posts Tagged ‘Reinstall’

CentOS 5 Remote Reinstall over VNC

January 14th, 2010 3 comments

So you want to live your life on the edge, and do a remote reinstall of your server? The reasons can be many – maybe the server was compromised, or – like me – you just received a freshly installed new system with a horrible disk partitioning or maybe even the wrong choice of architecture. I’ll show you how! :-)

I just received my dedicated server at bulk price, but unfortunately also with a bulk installation of CentOS. It’s fitted with two 250G disks, yet there is no mirroring or anything installed. On top of this, this delicious 64-bit system was running a 32-bit operating system. I was not amused. Asking for a special reinstall would probably cost me a fortune in support, and even then I probably wouldn’t get it exactly like I wanted it.

Luckily most new Linux distributions feature remote installation via VNC. If the system is already running Linux – like this one – its both easy and safe to play around with this method. In this example, we’ll be installing CentOS 5.4 x86_64.

Step 1: Get a hold of the bootstrap files. This includes the Linux kernel image and the ramdisk image. Put these on your /boot partition:

$ cd /boot
$ mkdir centos5-x86_64
$ cd centos5-x86_64
$ wget http://mirror.leaseweb.com/centos/5.4/os/x86_64/isolinux/vmlinuz
$ wget http://mirror.leaseweb.com/centos/5.4/os/x86_64/isolinux/initrd.img

Step 2: Add an entry to the Grub boot loader. Adjust values for network (ip, netmask, dns, gateway) and pick a better VNC password than me. Copy the “root (…)” line from a working entry:

title CentOS 5 VNC Install
root (hd0,0)
kernel /centos5-x86_64/vmlinuz vnc vncpassword=foobar headless ip=1.2.3.4 netmask=255.255.255.0 gateway=1.2.3.1 dns=2.3.4.5 ksdevice=eth0 method=http://mirror.leaseweb.com/centos/5.4/os/x86_64/ lang=en_US keymap=us
initrd /centos5-x86_64/initrd.img

Step 3: Ask the Grub boot loader to boot your new entry next time, and only next time. This makes a lot of sense if your hosting facility allows you to power cycle the server remote – and they should. Really. If you can’t do this yourself, at least you can have some support drone push the reset button if the server doesn’t come up. Note what number your new entry in the Grub configuration file has. First one is 0, second is 1 etc. I had two entries already, so that made my new entry number 2:

$ echo “savedefault –stage2=/boot/grub/stage2 –default=2 –once” | grub –batch

Step 4: Reboot and be patient. Some servers take up to five minutes to come back up – probably because of a BIOS misconfiguration. Anyway, reboot it:

$ reboot

Step 5: Connect to your server with your favorite VNC client. Mine’s Chicken of the VNC :-) You’ll need to connect to port 5901, which in VNC-terms often is referred to as “Display 1″. Use the password you specified:

vnc

Step 6: Run the install ;-) After this, your neat remote installation will be wiped, so double check all your network settings.

install

Good luck! :-)