Home >Operation and Maintenance >Linux Operation and Maintenance >How to quickly and easily install GRUB for a Linux server
The content of this article is about how to quickly and easily install GRUB for Linux servers. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
How to install GRUB for a Linux server
When you cannot migrate a Linux server with a lower kernel version and a system boot program GRand Unified Bootloader (GRUB) version below 1.99 through the cloud migration tool, For example, CentOS 5 and Debian 7. And when the log file prompts Do Grub Failed, it may be because the system boot program GRUB of version 1.99 or above is not installed.
This article mainly introduces how to install the system boot program GRUB 1.99 version for your source server. The process of installing GRUB 1.99 and above, such as 1.99 and 2.02, is the same. The main difference is that the GRUB version source code package downloaded during the installation process is different. You can visit https://alpha.gnu.org/gnu/grub/ to obtain the download of the new version. address.
Install GRUB 1.99 version
Log in to the source server.
Run the following command to view the paths of the original grub, grub-install and grub-mkconfig:
which grub which grub-install which grub-mkconfig
Use the mv command to rename the old versions of grub, grub-install and grub-mkconfig to back up the files. After migrating the server using the cloud migration tool, you can restore the original name to use the original configuration.
mv /sbin/grub /sbin/grub-old mv /sbin/grub-install /sbin/grub-install-old mv /sbin/grub-mkconfig /sbin/grub-mkconfig-old
Run yum install -y bison gcc make to install the bison, gcc and make tools that GRUB depends on.
Run the following command to install flex.
test -d /root/tools || mkdir -p /root/tools cd /root/tools wget https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz tar xzf flex-2.6.4.tar.gz cd flex-2.6.4 mkdir -p build cd build ../configure make && make install ln -s /usr/local/bin/flex /usr/bin/flex
Run the following command to install GRUB 1.99 dependencies.
test -d /root/tools || mkdir -p /root/tools cd /root/tools wget https://alpha.gnu.org/gnu/grub/grub-1.99~rc1.tar.gz tar xzf grub-1.99~rc1.tar.gz cd grub-1.99~rc1 mkdir -p build cd build ../configure sed -i -e "s/-Werror//" ./grub-core/Makefile make && make install ln -s /usr/local/sbin/grub-install /sbin/grub-install ln -s /usr/local/sbin/grub-mkconfig /sbin/grub-mkconfig
Note: If a -Werror error occurs during the compilation process, you can locate the compilation file makefile of the compilation object, remove the -Werror option and recompile.
Run grub-install --version to check whether the GRUB version is updated to 1.99.
Next step
After successfully updating the system boot program GRUB 1.99 version, you can use the cloud migration tool to migrate the server to Alibaba Cloud.
(Optional) After the cloud migration is successful, run the following command to restore the old version of GRUB:
rm /sbin/grub-install rm /sbin/grub-mkconfig rm /boot/grub/grub.cfg mv /sbin/grub-old /sbin/grub mv /sbin/grub-install-old /sbin/grub-install
The above is the detailed content of How to quickly and easily install GRUB for a Linux server. For more information, please follow other related articles on the PHP Chinese website!