While moving a client's moderately complex mail and web setup to a new
machine, I discovered that it ran an older version of CentOS than the
existing server (4.8 vs. 5). I got all the relevant software installed,
but major-version differences in packages like Apache and MySQL made me
feel less than confident about putting the result into production right
away.
The client and I agreed that it would be best to run CentOS 5.x on the
new server, so I started looking for a way to upgrade. GigeNET support
suggested “yum update” and “yum upgrade -y”, but
those commands are analogous to Debian's “apt-get upgrade”
and I wanted something like “apt-get dist-upgrade”. In fact,
there doesn't seem to be any recommended way to remotely upgrade CentOS.
Fair enough. I wouldn't want to mess with a running server either, but
this was a special case.
After a little research, I found
this blog post
about remotely reinstalling CentOS by booting the
PXE installer images
via grub and connecting to the running installer using VNC. It sounded
promising, if a bit risky. I decided to try it, based on an endorsement
of the method by #centos, because I saw no other realistic
options.
The crux of the technique is to boot from an entry like the following in
/boot/grub/menu.lst:
title CentOS installer
root (hd0,0)
initrd /initrd-pxe
kernel /vmlinuz-pxe vnc vncpassword=whatever headless ip=A.B.C.D netmask=N.N.N.N gateway=N.N.N.N dns=N.N.N.N hostname=x.example.org ksdevice=eth0 method=http://mirror.centos.org/centos/5/os/i386/ lang=en_US keymap=us
The server took forever to come up after I rebooted (I suspect that it
runs a slow self-test on 4GB of RAM, and I foresee many panic-filled
moments in my future in which I wonder if the machine is ever going to
come back up), but I was able to connect to it afterwards using a VNC
client (xvnc4viewer, which I installed while waiting). To my surprise,
the entire experience was quite pleasant. The installer was much more
responsive than I had expected based on my experience, many years ago,
of remotely installing Oracle 8i using the (then shiny new) Java
installer via X forwarded over SSH on a 14.4k PPP link. I grabbed a
quick nap while the installer downloaded packages.
When I woke up, the installer had reached the "Click Reboot to finish
installation" stage, but the VNC session was unresponsive because my
PPPoE link went down and came back up with a different IP sometime
during the night. I restarted xvncviewer, but it claimed the server was
in use (even after an hour) and wouldn't let me reconnect. I took a
chance and rebooted the server using the hosting provider's web-based
administration interface, hoping that the installer wasn't lying about
having no more work to do.
After another heart-stopping wait, however, the shiny new CentOS 5.3
server came up just fine.