Posts Tagged “remote”

In the datacentre I have a Fedora 7 machine with IPMI capabilities. But I have to replace it with CentOS 5.

Hmm. I don’t really want to burn CentOS to a DVD, drive (aprox. 1 hour) to the data centre to reboot the server, place the CentOS installation DVD, run the installation, and drive back to the office. Because all other administration can be done remote through ssh.

So after some searching on the internet, I found a way to do a remote installation.
Thnx for the guys which placed their info online!
Hampus and Karanbir Singh

So how to start?

The server has two network cards. One attached directly to a switch connected to internet (eth1) and one attached to a seperate switch, which connects all servers in the rack on a private ip-range (eth0)

On the private ip-range I already have dhcp running (not for the servers, they have static ip-addressen, but to make life a bit easier. When I’m with my notebook in the datacentre, I can just plug in, and access all my server through the private lan and also use internet through one gateway with NAT).
I just added a few extra commands to make booting through the network possible.
My current /etc/dhcpd.conf:

server-identifier server01.private.bb.exa-omicron.nl;
default-lease-time 43200;
max-lease-time 86400;
option domain-name “exa-omicron.nl”;
option domain-name-servers 10.99.1.1;

ddns-update-style none;

use-host-decl-names on;

allow booting;
allow bootp;

subnet 10.99.1.0 netmask 255.255.255.0 {
authorative;

range 10.99.1.201 10.99.1.230;
option routers 10.99.1.1;

next-server server01.private.exa-omicron.nl;
filename “/pxelinux.0”;
}

Most important here is the next-server and the filename tag.
It points to the tftp server, and the file to download and boot.

TFTP server

A tftp server wasn’t installed on this server yet, so I installed it through (it’s fedora core)

yum install tftp-server

This will give you an /tftpboot directory, if not, create it.

Don’t forget to also enable the tftp server in the /etc/xinet.d/tftp file through changing the ‘disable = yes’ to ‘disable = no’
And restart the xinet.d daemon through ‘service xinetd restart’

pxelinux

So now the file, which will be downloaded to boot by the server which must install CentOS. pxelinux is maintained by H. Peter Anvin. You have to download syslinux to a temporary directory, unpack it, and copy the pxelinux file to the /tftpboot directory

wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.51.tar.bz2
tar xvjf syslinux-3.51.tar.bz2
cp syslinux-3.51/pxelinux.0 /tftpboot/

And now linux kernel to start the CentOS installation

From the CentOS mirror file server you can download special vmlinuz and initrd.img files, which can be used for starting the CentOS installation.

cd /tftpboot
mkdir CentOS
cd CentOS
mkdir 5.0
cd 5.0
wget ftp://ftp.surfnet.nl/pub/os/Linux/distr/CentOS/5.0/os/x86_64/images/pxeboot/vmlinuz
wget ftp://ftp.surfnet.nl/pub/os/Linux/distr/CentOS/5.0/os/x86_64/images/pxeboot/initrd.img

And configuring the pxelinux to start the CentOS installation kernel

After pxelinux is loaded on the booting server, it will try to retrieve a config file from the tftpserver which holds the next steps to take. It will try different files, based on (for instance) the mac-address, IP addres, or a part of the IP address. This way you could setup different kernels to load for different computers or ip ranges. I don’t use that here, so I just place one default config file as /tftpboot/pxelinux.cfg/default with the following content:

default centos50
timeout 5
prompt 1
serial 0 9600

label centos50
kernel CentOS/5.0/vmlinuz
append initrd=CentOS/5.0/initrd.img headless lang=en_US keymap=us \
vnc vncpassword=MyPass ip=dhcp ksdevice=eth0 \
method=http://ftp.surfnet.nl/pub/os/Linux/distr/CentOS/5.0/os/x86_64/

The extra parameters behind the append are needed by anaconda, to pass phase 1 of the installation without any questions. Then the installation starts an X-server to start phase 2 (the graphical part). This X-server also support vnc 🙂 So with the configuration above, the X-server will be started with VNC, waiting for you to connect to it’s ip-address with the mentioned password. From that stage, you will see the graphical installation on your local computer (where the VNC viewer is running).

Do the magic

So we’ve got everything in place now. Time to do the magic!
with IPMI, I can reboot the server and force it into the BIOS.
I ran these commands on the dhcp server, and used the ip address of the server, which must be reinstalled.

ipmitool -I lanplus -H 10.99.1.45 -A Admin -P IMPIPasswd chassis bootdev bios
ipmitool -I lanplus -H 10.99.1.45 -A Admin -P IMPIPasswd chassis power reset

With IPMI I also have the possibility of Serial-Over-Lan. This gives me the opportunity to change settings inside the BIOS through the IPMI card located in the server and listening on the first networkcard.

ipmitool -I lanplus -H 10.99.1.45 -A Admin -P IMPIPasswd sol activate

So after I changes the bootorder in the BIOS, saved the settings and rebooted the machine, I could see in logfile of the dhcp server, that the machine gets a dynamic ip-addres. After that the configfile and kernel files are downloaded from the tftp server. Then it takes a moment to start the phase 1 of the installation, places a second dhcp request (this time by the OS, not by the BIOS/LAN card). Then it checks if it can reach the installation files from the method given in the pxelinux.cfg/default config file. The X-server with vns is started. Then you can connect with a vnc viewer to the dynamic ip-address.
This way I could successfully install CentOS, just like I was in the datacentre with a monitor hooked up on the server itself.
Don’t forget to change the BIOS settings after the installation back so it will not try to reboot through the networkcard every time 🙂

Post to Twitter

Comments No Comments »