Installing Centos 4 From a Remote Location

This is a howto about installing Centos from most running Linux installs. I am rewriting a sweet blog that has helped me and saved a lot of time. I will be including options that are to my personal preferences and take no responsibility if this is ever actually used.

I would first like to give credit to the inspiration of this howto and, hopefully, a tool to generate a grub config to help with the configuration of grub. Please take the time to view the origial work.

Warning!

This doc should be considered a work in progress. It is a BETA, DO NOT USE! even though you should still be able to get up and running with this.

Stop now... you don't want to do this. You will get no help. Use at your own risk. With that said... here is the goodness:

If setup correct, you will get a really neat install session via VNC. Take a look at the screen shot of what you should get when it is all up and working.

Other Notes: This is for x86/i386/ia32... you will need to make any adjustments as needed. I will try to provide 64bit/PPC support for this howto when I get some more time.

Step 1. Obtain the Needed PXE Images

Note:
You will need both initrd.img and vmlinuz. See Step 2 (Install Images)
for my preference of how to obtain and install the images.

Step 2. Install Images

The
images need to be installed in /boot or where your LILO or Grub looks
for images. You will need to know if '/boot' is needed or not. Check to make sure the permissions match existing kernels
and other data in the same location. I name my images initrd.img.cent.pxe and vmlinuz.cent.pxe
to keep things sain. I will use this naming in the rest of this howto.
If you don't use my naming convention or are not able to, use a simple
name that does not exist already.

Note:
This method should set the correct permissions on the new images. This
is a result of using copy (cp) and not move (mv). You should also check
this on your server using ls (ls -al).

Step 3a. Configure Boot Loader for New Images

Warning!

I have been testing this doc and ran into a new problem. I think it was
caused by a slow/bad mirror. It might be a good idea to pick a mirror
you know and can trust to serve your install. I just had a failed
install (failed on python 2.3 complaining about media source issues)
and I think it was due to a bad mirror. I will try to research this
more.

You will need to configure your boot
loader for the new PXE images. At this point you will need information
about the existing server and network. This is key to the success of
the reboot. You must know that the PXE images will boot your
hardware. Specifically hard disk drives and network interface cards are
needed to do the install. The best way to check this is read
(TODO:missing link) about it or test it. You must also know
what your network adapter will show up as on Centos as it is passed to
the kernel at boot. Again, you have been warned. Also, it is good to
make backups of your boot loader configs. As another note, please
'append' this information into your configs. Do not replace what you
have, just add to it.

For this example we will use the following network settings, you must adjust to your own network:

I
will start with Grub, my personal choice for a boot loader. Full Grub
and LILO examples are available in the in 'Examples' section. You
should check them. I have not included everything you will need in this
section. I am making the assumption you know how to use your boot
loader.

The following are example kernel config lines for grub:

The following is an example kernel config line with the example static IP config:

Note: Use the examples for Grub to tune the append line to what you are expecting to use.

If you are using LILO, you must run the following as root or your system will most likely fail to boot:

lilo

If you have configured everything correctly, you should see something like the following:

Added Linux *Added CentosAdded LinuxOLD

The
entry with the asterisk (*) is what is set to boot by default. I
personally reboot the server into the old kernel after making changes.
Then I adjust the config more to boot the PXE images. You may do
whatever you would like.

WARNING!

The LILO configs here are still borked. This is not just a settings issue (en_GB/uk vs. en_US/us.) I will look further into this issue at a later time. Do not use LILO. The
server will reboot and boot to an interactive screen that requires
input. After input on the first screen (select keyboard,) the
networking comes up and the server starts downloading stage two from
there. If you have a way to interact with your server that does not
require it's network to be up, you could still continue. This would be
something like remote KVM or a serial console.

Step 3b. Reboot the Server Into the Old Kernel

This
step may be safely skipped. Any time you reboot a server from remote it
is a good idea to have a backup plan. See Step 4 for information about
having a backup plan. If you would like to skip this step, see Step 3c
for setting your boot loader to boot the PXE images. Reboot the server
to the existing kernel. This means you did not change either of the
following boot options from their original settings (depending on what
boot loader you use):

LILO Example:

default=Linux

GRUB Example:

default=0

Step 3c. Configure Boot Loader to Boot the PXE Images

To
be able to boot the images you have just installed, you must configure
your boot loader to do so. As backround, Grub uses ordering as default
and it starts at zero (0). LILO uses labels. If you followed my
installation instructions, the Label for the Centos image is 'Centos'.
I am also assuming you have configured the Centos PXE images where Grub
will see them as item one (1). Count the 'title' lines, starting at
zero (0), to confirm where you configured the images at. Adjust your settings as needed.

LILO Example:

default=Centos

GRUB Example:

default=1

If you are using LILO, you must run the following as root or your system will most likely fail to boot:

lilo

If you have configured everything correctly, you should see something like the following:

Added Linux
Added Centos *
Added LinuxOLD

Step 3d. Setup your Workstation to Listen for the VNC Install to Start

This step is only needed if you choose to use vncconnect. For some,
this will be better. I personally use vncpassword because I have
network level security on my servers and only I will be able to connect
to the server that I am rebuilding. Using vncconnect prevents someone
unauthorized from connecting to the VNC install, however, this adds
another step in the boot and install process that could fail. If you do
allow connections, using vncpassword is still fairly secure. If you are
not actively being hacked, don't worry about it.

To be
able to use vncconnect you must setup a vncviewer to listen for the
server to boot. Run the following on another computer:

vncviewer --listen

This
will setup vncviewer for use with the rebuild. It will be listening on
port 5500. Use netstat to check to see if it is listening:

netstat -an|grep 5500

Also, check to make sure the server can connect to your client. You can do this from the server with the following command:

nmap -sT -p 5500 -P0 192.168.1.23

Step 4. Backup Plan

Have one of these... or do not proceed. What happens if the server does
not reboot? Plan on this happening and then be very happy when it does
boot. The best thing would be remote KVM or serial console access.
Another option, have someone able to select the old kernel and get the
server back online so you are able to try again.

Step 5. Double Check, Reboot

This document is missing important information. However, you should be
able to use it just fine. Double check your boot loader and make sure
it is set to load the PXE images. Check my 'Examples' against your
settings. If you used vncpassword, you must connect to the server as
outlined in Step 6. If you used vncconnnect, sit back and hope the
server asks you to set it up.

Step 6. Connect to VNC Server

I normally start pinging the server before I restart it (assuming a
static network config) and wait for the ping replys to start again.
This should happen then the installer brings up the networking.

ping 192.168.1.2

The boot takes a little while to get going. If you never hear from the
server, see Step 4. When you are able to ping the server, connect to
the installer:

vncviewer 192.168.1.2:1

It
also takes some time to get vncserver started. If your network starts
responding and you still can not connect to the server, wait longer or
see Step 4. I have had machines ask for a keymap and sit there waiting
to start the install. The fix might be as simple as selecting the
keymap from the console and the installer will start as expected. This
is not able to be done remote at this time unless you have hardware
support for this type of thing. See Step 4.

Troubleshooting:

If you added the PXE images correctly, you should still be able to boot
back to the old kernel. Do this and try again. You must know if your boot loader expects /boot or not. I will be adding much
more here after I test and test again.