In this post we will learn how to enable network in rescue mode under Centos 7.

One of our server have a boot loop issue and our last option is to change hardware based on recommendation by software vendor.

The issue when changing hardware is the server sometimes cannot boot even using the same hardware specification. We suspect it is something to do with the device UUID because of hardware change.

So to solve the issue we need to boot in rescue environment to repair boot and try to reinstall grub first. Our server using software raid. If during rescue mode if you cannot mount the disk using option 1 and 2 you still be able to mount the raid. Just list the hardisk using command;

fdisk -l

We can possible to assemble and mount the raid device using below command;

mdadm --assemble --run /dev/md0 /dev/sda1 
mdadm --assemble --run /dev/md1 /dev/sda2 

*No need to mount/assemble swap device

Let assume md1 is / and md0 /boot device

mount /dev/md1 /mnt/sysimage
mount /dev/md0 /mnt/sysimage/boot
mount -o bind /dev /mnt/sysimage/dev
mount -o bind /dev/pts /mnt/sysimage/pts *if required
mount -o bind /proc /mnt/sysimage/proc
mount -o bind /sys /mnt/sysimage/sys
mount -o bind /dev/shm /mnt/sysimage/dev/shm 

Next step may or may not required depending on situation. In our case we need it because we need to reinstall kernel. The next step is try to bring up the network but using local ip since the server is in the office and not using public IP.

If you fire command

ip route show

it supposed to be empty because you not set any setting in the network. Run ;

ifconfig -a

to know the network device name.

Command to add IP to the network is:

ip addr add dev enp6s0 *enp6s0 is your device name

Then add gateway

ip route replace default via dev enp6s0
ip route show *to show current status of network

Now we are ready to login to our problem server. Command below executed:

chroot /mnt/sysimage

Now we are in the server environment and no longer in rescue environment.

We fixed our server by reinstall kernel again. Reinstall kernel require Internet connection.

If this step failed after reboot server, repeat the step again but no need Internet but rather fix the grub by reinstall grub.

One thought on “Enable network in rescue boot environment Centos 7”

Leave a Reply

Your email address will not be published. Required fields are marked *