Steps to revert back to a previous kernel version:

You will need to do the following prior to changing the kernel:

-Detach the root volume of the instance which is failing instance health checks after the update was performed

-Attach the instance to a recovery instance

-Prepare the volume using the following commands:

 

The following command verifies that the root volume has successfully been attached to your recovery instance:

[ec2-user@bastian ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 100G 0 disk
└─xvda1 202:1 0 100G 0 part /
xvdf 202:80 0 8G 0 disk
└─xvdf1 202:81 0 8G 0 part

The following command creates a temp mount point called /mount (You can name this to whatever you want though):

[ec2-user@bastian ~]$ sudo mkdir /mount

We use the mount command to mount the volume:

[ec2-user@bastian ~]$ sudo mount /dev/xvdf1 /mount

 

We then use df to confirm the volume has been mounted:

[ec2-user@bastian ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 231M 68K 231M 1% /dev
/dev/xvda1 99G 5.3G 93G 6% /
/dev/xvdf1 8.0G 3.4G 4.7G 43% /mount

Next, we will need to mount the following from our recovery instance to our mount point( /dev, /dev/shm, /proc, /sys ):

[ec2-user@bastian ~]$ sudo mount -o bind /dev /mount/dev

[ec2-user@bastian ~]$ sudo mount -o bind /dev/shm /mount/dev/shm

[ec2-user@bastian ~]$ sudo mount -o bind /proc /mount/proc

[ec2-user@bastian ~]$ sudo mount -o bind /sys /mount/sys

Next, we isolate the volume using chroot:

[ec2-user@bastian ~]$ sudo chroot /mount

 

After doing the above, you volume is now ready to run the following based on the flavor you are using:

 

REDHAT 6 AND AMAZON LINUX 1:::

[ec2-user@bastian ~]$ sudo awk ‘/\s*kernel/{print}’ /boot/grub/menu.lst

[ec2-user@bastian ~]$ sudo sed -i ‘/^default/ s/0/1/’ /boot/grub/grub.conf

[ec2-user@bastian ~]$ exit

 

FOR UBUNTU::::

[ubuntu@bastian ~]$ sudo awk -F\’ /\s*menuentry/{print\$2}’ /boot/grub/grub.cfg

[ubuntu@bastian ~]$ sudo grub-set-default 1

[ubuntu@bastian ~]$ cat /boot/grub/grubenv | grep saved

saved_entry=1

[ubuntu@bastian ~]$ sudo grub mkconfig -o /boot/grub/grub.cfg

[ubuntu@bastian ~]$ exit

 

REDHAT AND AMAZON LINUX 2::::

@bastian ~]$ sudo awk -F\’ /\s*menuentry/{print\$2}’ /boot/grub/grub.cfg

@bastian ~]$ sudo grub2-set-default 1

@bastian ~]$ sudo cat /boot/grub2/grubenv | grep saved

saved_entry=1

@bastian ~]$ sudo grub2 mkconfig -o /boot/grub/grub.cfg

@bastian ~]$ exit

 

 

 

 

 

No token or token has expired.

Leave a Reply

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

What is a Hypervisor?

26th Mar 2019