Installing Centos Remotely « Firelead Blog

Installing Centos Remotely

I found a fast way to reinstall Centos 5.4 on a box that I had completely screwed up. The server is hours away from me in a datacenter, and I needed a quick way to wipe it without calling support.

I already had Centos on this box, and was able to SSH into it as the root user.  This guide is going to assume you have the same access. It will walk you through installing your Centos 5.4 from a remote location using the PXE image.  These directions are also for the 32bit edition, you can edit the links for the 64bit version accordingly.  This is how I did it, don’t come crying to me if you mess up your system using these directions.

1. First download a VNC viewer.  I like RealVNC for Windows, and Chicken of the VNC for Mac.  There are other options out there, but those are both free and easy to use.  Gather your IP address, Gateway address, netmask address, 1 dns address.  If you don’t know what your dns server is – type:   cat /etc/resolv.conf

2. Setup the directories and get the files.  This step copies the PXE boot images to your /boot directory:
mkdir /newsystem
cd /newsystem
wget http://mirror.centos.org/centos/5.4/os/i386/images/pxeboot/initrd.img
wget http://mirror.centos.org/centos/5.4/os/i386/images/pxeboot/vmlinuz
cp vmlinuz /boot/vmlinuz.cent.pxe
cp initrd.img /boot/initrd.img.cent.pxe

3. Edit your /etc/grub.conf file using vi or your favorite editor.  If your default=0, in that file – make sure that the below is edited according to your server info and is in the first title.  Also, DO NOT copy this exactly- you must edit it according to your server – create a password, and fill in your IP address.
title CentOS (pxe)
root (hd0,0)
kernel /vmlinuz.cent.pxe vnc vncpassword=PASSWORDHERE headless ip=111.111.111.111 netmask=255.255.255.255 gateway=222.222.222.222 dns=333.333.333.333 hostname=test.example.com ksdevice=eth0 method=http://mirror.centos.org/centos/5.4/os/i386/ lang=en_US keymap=us
initrd /initrd.img.cent.pxe

In the example above, I created a password in the PASSWORDHERE area… I entered my real IP for this server in the 111.111.111.111 area, along with the netmast, gateway, and dns.  DOUBLE CHECK EVERYTHING BEFORE SAVING AND REBOOTING.  Once you reboot, open up your VNC Viewer and enter your IP address and port of 5901 like this:  111.111.111.111:5901.  Enter the password you entered in the PASSWORDHERE area.  You should be able to remote connect to it and install a fresh copy of Centos 5.4!  If this fails…you will either have to go to the server and reinstall it or call your server facility for help.  Good Luck!