Sections

Skip to content. | Skip to navigation

You are here: Home HowTos Installing Centos 4 From a Remote Location

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

    Images for Centos 4: http://mirror.centos.org/centos/4/os/i386/images/pxeboot/

    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.

Example Fedora /boot Permissions:

drwxr-xr-x  root     root     system_u:object_r:boot_t         .
-rw-r--r--  root     root     system_u:object_r:boot_t         vmlinuz-2.6.15-1.1831_FC

Example Centos /boot Permissions:

drwxr-xr-x  root     root     system_u:object_r:boot_t         .
-rw-r--r--  root     root     system_u:object_r:boot_t         vmlinuz-2.6.9-22.ELsmp

Example Debian (woody) /boot Permissions:

drwxr-xr-x    3 root     root         4096 Sep 30 19:36 .
-rw-r--r--    1 root     root       678495 Jul 13  2001 vmlinuz-2.2.17

This is my personal way to get the images onto a running server. This needs to be done as root.

mkdir /newsystem
cd /newsystem
wget http://mirror.centos.org/centos/4/os/i386/images/pxeboot/initrd.img
wget http://mirror.centos.org/centos/4/os/i386/images/pxeboot/vmlinuz
cp vmlinuz /boot/vmlinuz.cent.pxe
cp initrd.img /boot/initrd.img.cent.pxe

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:

IP: 192.168.1.2
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DNS: 192.168.1.1
Server Network Interface: eth0
Workstation Machine: 192.168.1.23
Hostname: test.mydomain.com
VNC Password: yourPass

Note: Make sure your password is between 6-11 characters in length.

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:

kernel /vmlinuz.cent.pxe vnc vncpassword=yourPass headless ip=192.168.1.2 netmask=255.255.255.0 gateway=192.168.1.1 dns=192.168.1.1 hostname=test.mydomain.com ksdevice=eth0 method=http://mirror.centos.org/centos/4/os/i386/ lang=en_US keymap=us

Another way to run with a static network config, using vncconnect:

kernel /vmlinuz.cent.pxe vnc vncconnect=192.168.1.23 headless ip=192.168.1.2 netmask=255.255.255.0 gateway=192.168.1.1 dns=192.168.1.1 hostname=test.mydomain.com ksdevice=eth0 method=http://mirror.centos.org/centos/4/os/i386/ lang=en_US keymap=us

You may also use DHCP, just make sure you will know the IP address when the server reboots:

kernel /vmlinuz.cent.pxe vnc vncpassword=yourPass headless ip=dhcp ksdevice=eth0 method=http://mirror.centos.org/centos/4/os/i386/ lang=en_US keymap=us

Yet another way to use DHCP, this might be the best option if you do not know what the IP will be:

kernel /vmlinuz.cent.pxe vnc vncconnect=192.168.1.23 headless ip=dhcp ksdevice=eth0  method=http://mirror.centos.org/centos/4/os/i386/ lang=en_US keymap=us

Note: If you use the vncconnect you must also follow Step 3d.
Tip: I have had issues using lang=en_GB keymap=uk. I will try to look into this further.

The following options are for the LILO boot loader:

append="vnc vncpassword=yourPass headless ip=192.168.1.2 netmask=255.255.255.0 gateway=192.168.1.1 dns=192.168.1.1 hostname=test.mydomain.com ksdevice=eth0 method=http://mirror.centos.org/centos/4/os/i386/ lang=en_US keymap=us"
initrd=/boot/initrd.img.cent.pxe

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 Centos
Added 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.

Examples:

LILO:

image=/boot/vmlinuz.cent.pxe
label=Centos
append="vnc vncpassword=yourPass headless ip=192.168.1.2 netmask=255.255.255.0 gateway=192.168.1.1 dns=192.168.1.1 hostname=test.mydomain.com ksdevice=eth0 method=http://mirror.centos.org/centos/4/os/i386/ lang=en_US keymap=us"
read-only
initrd=/boot/initrd.img.cent.pxe

GRUB:

(this assumes your '/boot' is at root (hd0,0))

title Centos Install (PXE)
        root (hd0,0)   
kernel /vmlinuz.cent.pxe vnc vncpassword=yourPass headless ip=192.168.1.2 netmask=255.255.255.0 gateway=192.168.1.1 dns=192.168.1.1 hostname=test.mydomain.com ksdevice=eth0 method=http://mirror.centos.org/centos/4/os/i386/ lang=en_US keymap=us
        initrd /initrd.img.cent.pxe
Document Actions