How to Remotely Initiate Netinstall of CentOS 7

centosgrub2installation

I've got 50+ machines running either CentOS 6.4 or 6.8. I wish to re-install these machines with CentOS 7 using a configuration script (for example using the "basic server" template and setting hostname/static IP based on hardware ID), using installation media sitting on a public NFS and/or CIFS share on my local network. Later on, I intend to remote control these machines with Ansible, so I would want to run a post-installation script as well.

How can I remotely (via SSH) trigger this re-installation?


Based on Iain's answer and doing some googling, here's how to perform this kind of installation from CentOS 7:

Download vmlinuz and initrd.img into boot:

sudo curl -o /boot/vmlinuz http://mirror.zetup.net/CentOS/7/os/x86_64/isolinux/vmlinuz
sudo curl -o /boot/initrd.img http://mirror.zetup.net/CentOS/7/os/x86_64/isolinux/initrd.img

Add a custom menu entry into /etc/grub.d/40_custom:

menuentry "My custom boot entry" {
    set root=(hd0,1)
    linux /vmlinuz ks=http://my-server/ks.cfg
    initrd /initrd.img
}

Add any additional options on the linux line above.

Make the custom entry the default choice in /etc/default/grub:

GRUB_DEFAULT="My custom boot entry"

Then run:

grub2-mkconfig --output=/boot/grub2/grub.cfg

Grab a cup of coffe and reboot:

reboot

Best Answer

You can reinstall from grub by booting a kernel with suitable command line parameters. I outlined the process for EL6 here but there are some changes that need to be made for EL7. This is just an outline but it should get you going in the right direction.

Download /centos/7/os/x86_64/isolinux/vmlinuz to /boot from a repo of your choice
Download /centos/7/os/x86_64/isolinux/initrd.img to /boot

Configure a grub entry - put this first.

title Install CentOS7
kernel /vmlinuz ro upgradeany biosdevname=0 net.ifnames=0 ip=192.168.254.44::192.168.254.220:255.255.255.0:somehost.tld:eth0:none ks=http://server.tld/ks/kickstart.ks  nameserver=8.8.8.8 headless vnc vncpassword=SomePassword
initrd /initrd.img

The above would boot the installation kernel and configure it's IPv4 as described, this then pulls down the kickstart script and installs the system from there.

Notes: When I did this it was a requirement that the system use old style ethN interface names. If you want the new consistent naming then you may have to figure out how to provide interface to the ip stanza

ip=address::gateway:netmask:hostname:interface:method

you may get away with

ip=dhcp

It may be is possible to omit the interface e.g.

ip=address::gateway:metmask:hostname::none

Once you get this working it works well. You'll probably want to have a look at the options in the relevant documentation.

I start up a VNC server so I can see what's happening if I need to it can be omitted.

The headless parameter stops the system from looking for and initializing video hardware you may want to omit that and watch on the IPMI console.