Posted on Leave a comment

How can we install a new CentOS7/Almalinux8 from grub initialization of Oracle Linux 7?

In most cases,The vps hosts does not provide the function of mounting custom ISO images.If that,we need to install CentOS7/8 through grub initialization of the server.

Take Oracle Linux 7 as an example
Step One,Install required software

yum -y install wget vim lsof net-tools

Step Two,Execute the following code

cat << EOF >/boot/Reinstall.sh
#!/bin/bash
rm -f /boot/initrd77.img /boot/vmlinuz77
wget -P /boot/ https://mirror.nsc.liu.se/centos-store/7.2.1511/os/x86_64/images/pxeboot/initrd.img -O /boot/initrd77.img
wget -P /boot/ https://mirror.nsc.liu.se/centos-store/7.2.1511/os/x86_64/images/pxeboot/vmlinuz -O /boot/vmlinuz77
#chmod +x /boot/vmlinuz77
cat << EOFEOF>/etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 \\\$0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the ‘exec tail’ line above.
menuentry “VNCInstallCentos7” {
set root=’(hd0,gpt3)’
linuxefi /boot/vmlinuz77 inst.vnc inst.vncpassword=medium inst.headless ip=dhcp nameserver=1.1.1.1 inst.repo=https://mirror.nsc.liu.se/centos-store/7.2.1511/os/x86_64/ inst.lang=en_US inst.keymap=us
initrdefi /boot/initrd77.img
}
EOFEOF
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
grub2-reboot VNCInstallCentos7
reboot
EOF

bash /boot/Reinstall.sh

Step Three,Open TightVNC Viewer and enter your IP address of your server with the PORT of 1

e.g. 152.70.231.53:1
And the password,of course,is ‘medium’.You may change the VNC password of the server 152.70.231.53 by yourself.

Tips:If you want to install a new CentOS7/8 from grub initialization the virtualization of the server must be kvm and be sure the RAM is 1GB or more than that.
Good luck!