How to Install CentOS or Fedora Remotely

The recently posted article describes how to remotely reinstall Debian Linux. In this post I’d like to share a quick and easy way to remotely install CentOS or Fedora. Anaconda installer can considerably simplify the procedure of installing or updating the operating system on a remote server.
Here is a quotation from the web page of the project where the anaconda options we’ll use are described:

anaconda is a fairly sophisticated installer. It supports installation from local and remote sources such as CDs and DVDs, images stored on a hard drive, NFS, HTTP, and FTP. Installation can be scripted with kickstart to provide a fully unattended installation that can be duplicated on scores of machines. It can also be run over VNC on headless machines.

Everything described below also fits for any Linux distribution package which uses grub to boot. Examples from the article were tested on grub 0.97, but grub2 can be used as well after making minor changes. Besides, I used this method when I replaced FreeBSD with Linux, after installing grub as a loader instead of regular Boot Manager.

Preparation involves four steps:

  1. Determining network settings of the server;
  2. Loading images for the selected OS;
  3. Preparing the configuration and adding it to grub.conf;
  4. Server restart and connection to it through VNC.

Determining network settings of the server

You will need the gateway address, as well as server’s and DNS IP addresses. You also will need MAC address of the main network card. It is essential to specify the latter, because if the server has two network cards, it is likely that the installer will choose the wrong one. To determine the network settings, you can use the following commands:

ifconfig
ip route show
cat /etc/sysconfig/network-scripts/ifcfg-eth0
cat /etc/sysconfig/network
cat /etc/resolv.conf

in our case they are the following:

IP 172.17.17.232
Gateway 172.17.17.1
DNS 172.17.17.1
MAC 52:54:00:4a:25:b5

Loading images

CentOS and Fedora use different images to boot the installer. You should pick the right images, depending on what distribution package you’re going to install. In addition, if are going to install a 32-bit version, you should replace x86_64 in url with i386.

Images for centos 5.6 (x86_64):

wget -O /boot/vmlinuz_remote http://mirrors.supportex.net/centos/5.6/os/x86_64/isolinux/vmlinuz
wget -O /boot/initrd_remote.img http://mirrors.supportex.net/centos/5.6/os/x86_64/isolinux/initrd.img

Images for fedora 15 (x86_64):

wget -O /boot/vmlinuz_remote http://download.fedora.redhat.com/pub/fedora/linux/releases/15/Fedora/x86_64/os/isolinux/vmlinuz
wget -O /boot/initrd_remote.img http://download.fedora.redhat.com/pub/fedora/linux/releases/15/Fedora/x86_64/os/isolinux/initrd.img

Preparing the configuration and adding it to grub.conf

Specify the gateway address, server’s and DNS IP addresses you saved earlier, as well as the URL where the installer will download rpm packages from. Also, specify optional parameters like absence of a monitor, selection of the particular network card, and a password for vnc.

If /boot partition isn’t the first one on the disk, correct the line root(hd0,0), so that it corresponds to the number of the partition.

Now add these lines to grub.conf for Centos 5.6:

title Remote Install
root (hd0,0)
kernel /vmlinuz_remote lang=en_US keymap=us method=http://mirrors.supportex.net/centos/5.6/os/x86_64/  vnc vncpassword=SuperSecret ip=172.17.17.232 netmask=255.255.255.0 gateway=172.17.17.1 dns=172.17.17.1 noselinux ksdevice=52:54:00:4a:25:b5 headless xfs panic=120
initrd /initrd_remote.img

or for fedora 15:

title Remote Install
root (hd0,0)
kernel /vmlinuz_remote lang=en_US keymap=us method=http://download.fedora.redhat.com/pub/fedora/linux/releases/15/Fedora/x86_64/os/ vnc vncpassword=SuperSecret ip=172.17.17.232 netmask=255.255.255.0 gateway=172.17.17.1 dns=172.17.17.1 noselinux ksdevice=52:54:00:4a:25:b5 headless xfs panic=120
initrd /initrd_remote.img

It is assumed that this configuration is the second item in the menu. You’ve specified that grub should make one attempt to load it. If something goes wrong, you’ll go back to the pre-set distribution after a restart, in 120 seconds.

[root@localhost ~]# echo 'savedefault --default=1 --once' | grub --batch

You can read about boot options of anaconda in more detail here http://fedoraproject.org/wiki/Anaconda/Options

Server restart and connection to it through VNC

Reboot the server and wait until it begins to respond to ping. Additional packages will take some time to load, then it will be possible to connect through VNC. If the network isn’t fast enough, it may take about 20-30 minutes.

Now connect to the server and do the same as on the local console: vncviewer 172.17.17.232:1
If you’re working from Windows, you can use TightVNC.

Tips

A VNC server starts without keep-alive, so if you are connected through nat, there is a chance to lose a session and no longer recover it due to unactivity. You’d better disconnect from vnc and then connect again, if VNC console isn’t going to be used for a long time.

You needn’t format boot section as ext4, though both Fedora and Centos offer it by default. Sometimes, installed operating system doesn’t load from this section. It happens extremely rarely, but it’s better not to run the risk.

If Fedora is installed in minimum configuration, ‘network’ service turns out to be not activated. It can be fixed by adding sshd and sshpw=password to anaconda settings, specifying a password for ssh. Access the remote server through ssh and activate ‘network’ service after the interactive installation is completed and before the installer is restarted:

# chroot /mnt/sysimage
# chkconfig network on
# exit

External links

Didn’t find the answer to your question? Ask it our administrators to reply we will publish on website.

Leave a Reply

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