This topic describes how to install GRand Unified Bootloader (GRUB) in a Linux server by using GRUB v1.99 as an example. To install GRUB of a later version, you need to download the relevant GRUB package.
When you migrate a source Linux server by using the Cloud Migration tool, if the source
Linux server has a low kernel version (such as CentOS 5 and Debian 7), and the version
of the built-in system boot program GRUB is lower than v1.99, the log file indicates
Do Grub Failed. In this case, you need to upgrade GRUB to v1.99 or later.
- Log on to the source Linux server.
- Run the following commands to view the directories of the original grub, grub-install, and grub-mkconfig:
# which grub # which grub-install # which grub-mkconfig
- Run the
mvcommand to rename the original grub, grub-install, and grub-mkconfig files for backup.Note After you migrate your server by using the Cloud Migration tool, you can reinstate the original files by changing their names back to the original ones.
# mv /sbin/grub /sbin/grub-old # mv /sbin/grub-install /sbin/grub-install-old # mv /sbin/grub-mkconfig /sbin/grub-mkconfig-old
- Run the
yum install -y bison gcc makecommand to install the dependencies of GRUB, which include bison, gcc, and make.
- Run the following commands 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 commands to install the dependencies of GRUB v1.99.
# 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 # sed -i -e "s/-Werror//" ./Makefile # make && make install # ln -s /usr/local/sbin/grub-install /sbin/grub-install # ln -s /usr/local/sbin/grub-mkconfig /sbin/grub-mkconfigNote If the error
-Werroroccurs, we recommend that you locate the error in the makefile, remove the
-Werroroption, and then try again.
- Run the
grub-install --versioncommand to verify GRUB is updated to v1.99.
What to do next
- After you update GRUB to v1.99, you can migrate your server to Alibaba Cloud by using the Cloud Migration tool.
- (Optional) After your servers are successfully migrated to Alibaba Cloud, run the
following commands to use the earlier 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