Grub update issue after AWS instance change
Due to the recent updates we were performing in our client’s infrastructure, we had to adjust the instance size, so we also upgraded from the older instance type to the newer one. To be precise – from T2 to T3. As usual, in such a case, we encountered an issue with the drives, which were not able to map properly. The solution to this issue, which symptom is that the server is not booting up properly, was described in one of my previous posts: “Unable to start AWS Linux instance after instance type change“.
Once the instance was upgraded to T3, there was a time to perform a release upgrade on the Ubuntu 18.04 that was installed on the server. During the upgrade, the process was interrupted with the following message:
Exception during pm.DoInstall(): E:Sub-process /usr/bin/dpkg returned an error code (1)
When I try to re-run the process, I also noticed that the grub update script is throwing an error:
grub-install: error: cannot find a GRUB drive for /dev/xvda
As you can see, there is an “old” device address displayed instead of /dev/nvme0n1
which is used in Ubuntu on T3 instances.
The solution was rather simple – we had to reinstall grub using the proper drive address. In order to do this, run the following command as root:
DEBIAN_FRONTEND=dialog dpkg --configure grub-pc
This will display the dialog in which you can select the drive to install grub to. Once installed, you should also run this command:
dpkg --configure -a
This way the configuration is applied and you can perform a release upgrade without further issues.