Someone who has any idea of why and how to fix this error?
and after executing the commands of the end dpkg --configure -a shows the following
First try doing the following:
sudo dpkg-reconfigure grub-pc
then select the correct disk (/dev/sda/) when prompted. In that way, if the error does come back again try the following solution:
sudo grub-install /dev/sda
then
sudo update-grub