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 choiceDownload
/centos/7/os/x86_64/isolinux/initrd.img
to/boot
Configure a grub entry - put this first.
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
you may get away with
It
may beis possible to omit the interface e.g.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.