Steps to install GRUB on Linux server

Steps to install GRUB on Linux server

How to Install GRUB for Linux Server

You cannot use the cloud migration tool to migrate Linux servers with lower kernel versions and built-in system boot loader GRand Unified Bootloader (GRUB) versions lower than 1.99, such as CentOS 5 and Debian 7. And when the log file prompts Do Grub Failed, it may be because the system boot program GRUB version 1.99 or above is not installed.

This article mainly describes how to install the system boot program GRUB 1.99 version for your source server. The installation process for GRUB 1.99 and above is the same as that for 1.99 and 2.02. The main difference is that different GRUB source packages are downloaded during the installation process. You can visit https://alpha.gnu.org/gnu/grub/ to obtain the download address of the new version.

Install GRUB version 1.99

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 compilation, you can locate the compile 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, you can use the cloud migration tool to migrate the server to Alibaba Cloud.

(Optional) After successful migration, 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

You may also be interested in:
  • Delegating Privileges in Linux Using Sudo
  • Friendly Alternatives to Find Tool in Linux
  • 8 Reasons Why You Should Use Xfce Desktop Environment for Linux
  • Historical Linux image processing and repair solutions
  • How to solve the timeout during pip operation in Linux
  • An audio-visual Linux distribution that appeals to audiophiles
  • 10 Handy Bash Aliases in Linux
  • Use iptables and firewalld tools to manage Linux firewall connection rules
  • Introduction to Linux system swap space
  • Linux system disk formatting and manually adding swap partition
  • Tips for using top command in Linux
  • 4 Scanning Tools for the Linux Desktop

<<:  Related operations of adding and deleting indexes in mysql

>>:  How to visualize sketched charts in Vue.js using RoughViz

Recommend

How to optimize MySQL performance through MySQL slow query

As the number of visits increases, the pressure o...

HTML simple web form creation example introduction

<input> is used to collect user information ...

Use Navicate to connect to MySQL on Alibaba Cloud Server

1. First enter the server's mysql to modify p...

Detailed explanation of the relationship between Vue and VueComponent

The following case reviews the knowledge points o...

React Fiber structure creation steps

Table of contents React Fiber Creation 1. Before ...

CSS3 Bezier Curve Example: Creating Link Hover Animation Effects

We will use CSS3 animated transitions to create a...

Detailed explanation of the JVM series memory model

Table of contents 1. Memory model and runtime dat...

Node uses koa2 to implement a simple JWT authentication method

Introduction to JWT What is JWT The full name is ...

MySQL database rename fast and safe method (3 kinds)

Table of contents How to rename MySQL database Th...

How to use Nginx to realize the coexistence of multiple containers in the server

background There is a Tencent Linux cloud host, o...

VUE+SpringBoot implements paging function

This article mainly introduces how to implement a...

WeChat applet realizes the effect of swiping left to delete list items

This article shares the specific code for WeChat ...

How to use selenium+testng to realize web automation in docker

Preface After a long time of reading various mate...