Remote rebuild – Centos/RHEL

Until now the rebuild of a server meant to me burning the disc or preparing a USB stick and going for a trip to wherever the machine was hosted. Now I have learned how to rebuild remotely a (working and ssh’able!!) machine, things are about to change.

As mentioned just above this way of rebuilding works only for servers that are already accessible – this is due to need of using SSH to reconfigure GRUB/Kernel options.

Preparation.

  1. Locate one of the Centos/Red Hat mirrors that could be used to network install – in my example I’ll install Centos 6.3 and use this mirror: http://mirror.stshosting.co.uk/centos/6.3/os/x86_64/
  2. Login to the machine that needs rebuilding
  3. 3. Enter /boot/ folder/partition
    cd /boot/
  4. Download installation copy of initrd.img and rename it to initrd.img-install, run:
    wget -O 'initrd.img-install' http://mirror.stshosting.co.uk/centos/6.3/os/x86_64/isolinux/initrd.img
  5. Download installation copy of vmlinuz and rename it to vmlinuz-install, run:
    wget -O 'vmlinuz-install' http://mirror.stshosting.co.uk/centos/6.3/os/x86_64/isolinux/vmlinuz</li>

  6. Just to be on the safe side copy the current version of grub.conf – this may be useful when you decide last minute that you don't want to rebuild it but recover the machine to previous state, run:
    /boot/grub/grub.conf /boot/grub/grub.conf-original
  7. And finally create new grub.conf with:

cat > /boot/grub/grub.conf << "EOF"
default=0
timeout=0
hiddenmenu

title Install Centos 6.3
root (hd0,0)
kernel /vmlinuz-install ip=192.168.1.50 netmask=255.255.255.0 gateway=192.168.1.254 dns=8.8.8.8 repo=http://mirror.stshosting.co.uk/centos/6.3/os/x86_64/ vnc vncpassword=C3nt0S lang=en_US keymap=uk sshd
initrd /initrd.img-install
EOF

DON'T FORGET TO ADJUST KERNEL OPTIONS TO MATCH YOUR ENVIRONMENT – the machine will not be usable if after reboot Anaconda won't be able to connect to internet.

Once you made sure all the network setting are OK restart the machine – it will boot into installer and Anaconda starting the installation to which you'll be able to connect to with VNC client using the ip (in my case it would be 192.168.1.50 and port number 5901. Give it few minutes before you try to connect – graphical installer won't be the first thing started after reboot.

For explanation of the options used with kernel please visit following links:

https://fedoraproject.org/wiki/Anaconda_Boot_Options?rd=Anaconda/Options
http://www.linuxtopia.org/online_books/rhel6/rhel_6_installation/rhel_6_installation_sn-medialess-editing-grub-conf.html

When browsing through kernel/anaconda options you may notice that there is 'vncport' which should allow to specify your own port for VNC connection. However, this one doesn't get recognized in Anaconda version used for Centos 6.3 installation and the installation fails leaving you with unreachable machine.

Good luck

This entry was posted in Managed Hosting. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

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