Skip to content

CentOS install over VNC

Sometimes we need/want to reinstall a remote Centos (or other distro) server. We can either ask the data centre to do it, but this can be costly or we can do it ourselves as long as we still have a functioning system.
The procedure to install Centos (same for RHEL and Fedora) is amazingly simple, the only thing we need is a barely functional system with grub and good connectivity.
My main source of inspiration for this article was a blog post from Karanbir; I'm writing this only to have a lighter, easier to read and copy/paste from document.
In this case I'm also using Centos as the existing remote OS. Here we go:
cd /boot
wget http://mirror.centos.org/centos/5/os/x86_64/images/pxeboot/initrd.img -O pxe-initrd.img
wget http://mirror.centos.org/centos/5/os/x86_64/images/pxeboot/vmlinuz -O pxe-vmlinuz

Now we need to add a grub entry using the downloaded files and set it default. Add something similar to your grub.conf/menu.lst (make sure to change the IP settings, password** etc):
title Centox-vnc-install
        root (hd0,0)
        kernel /boot/pxe-vmlinuz vnc vncpassword=blah132 headless ip=123.231.234.106 netmask=255.255.255.248 gateway=123.231.234.105 dns=4.2.2.3 hostname=blahserver ksdevice=eth0 method=http://mirror.centos.org/centos/5/os/x86_64/ keymap=uk lang=en_GB
        initrd /boot/pxe-initrd.img

You might also want to add "biosdevname=0 net.ifnames=0" to the vmlinux command line if you don't want your network interfaces to be renamed to em1 or eno1 which seem to happen in CentOS 6 and 7 under certain circumstances.

Double check the above entry is default and reboot. Keep pinging the IP you specified above, when it's up start vncviewer on IP:1. That's it, now you can reinstall your server(s) whenever you want without asking for KVMoIP or the data centre staff to do it for you.
Enjoy!


** Achtung! Vncpassword needs to be 6-8 characters long otherwise you won't be allowed to connect.