Score:0

Cloning an Ubuntu 22.04 instance that uses a compact flash drive seems to lead to an empty /boot/grub directory

at flag

We have an Ubuntu 22.04 setup that runs and works fine. When we clone the compact flash drive and put into an identical system it fails to boot with a file '/grub/i386-pc/normal.mod' not found error message. We have been using grub recovery to try and see why and it appears (but we might be using grub recovery wrong as we are new to this) that the /boot/grub directory is empty despite a verified clone being taken.

On the working system df-h shows the following:

Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              377M  1.4M  376M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  5.6G  4.7G  644M  88% /
tmpfs                              1.9G     0  1.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          1.7G  247M  1.4G  16% /boot
tmpfs                               16M   16K   16M   1% /opt/intellair/db
tmpfs                              377M  4.0K  377M   1% /run/user/1000

Using grub recovery on the non-bootable system the ls command gives the following results:

(hd0) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1)

set gives:

cmdpath=(hd0)
prefix=(hd0,gpt2)/grub
root=hd0,gpt2

If we try to ls any of the other drives we get Filesystem is unknown, but gpt2 (corresponding to /dev/sda2) works and if we run ls / we get

config-5.15.0-52-generic
lost+found
System.map-5.15.0-52-generic
grub/
initrd.img
vmlinuz
initrd.img-5.15.0-52-generic 
vmlinuz-5.15.0-52-generic
initrd.img.old
vmlinuz.old

Critically when we issue the command ls /grub it runs OK but returns nothing. We take this to mean the grub folder is empty. This is supported also by being unable to load any modules (e.g. linux, kernel, normal, etc.) that we would expect to be in the grub folder.

Two specific questions:

  1. In grub recovery if the /grub directory contained files should ls /grub list them?

  2. Assuming /grub is indeed empty, has anyone else had this issue before? It's almost like the clone of the compact flash drive specifically omitted the grub directory's contents?

It's worth noting this process worked fine for us on an old Ubuntu 18.04 setup. It's only on the newer Ubuntu 22.04 that the clone process gives this issue.

Kit Kline avatar
at flag
@guiverc - many thanks - for the record the OS in question is Ubuntu 22.04.1 LTS - sorry I was lazy in typing in my OP
starkus avatar
de flag
Did you already try `ls /boot/grub/`?
starkus avatar
de flag
Maybe this info pages could help you a little: https://phoenixnap.com/kb/grub-rescue https://wiki.ubuntuusers.de/GRUB_2/Shell/#Rettungs-Modus The second one is written in german.
Kit Kline avatar
at flag
@starkus may thanks - yeah ls of / (hd0,gpt2) shows grub/ at the highest level (ie not /boot/grub)..... so ls /boot/grub/ give no such file. ls /grub returns empty. I am right aren't I that the command: ls /grub would list what is inside that directory if it had anything in there? So weird as the CF clone seemed to copy everything else just fine ..why would it just omit all the *.mod files inside grub folder !?! Thanks for the link - will check that out !!
starkus avatar
de flag
Sounds a little strange to me too. As the german site tells: GRUB 2 automatically reverts to rescue mode if GRUB 2 has no or only incomplete access to the /boot/grub directory or the modules there required for executing the command line - in particular the normal.mod module. Its appearance always indicates problems with the installation of GRUB 2. This can have the following causes: Due to a faulty GRUB 2 package installation, the modules are not stored in the /grub directory or have been stored corrupted.
starkus avatar
de flag
The variable prefix that is stored in the MBR and the hidden area following the MBR when GRUB 2 is installed and that contains the path to the /grub directory with the modules contained there has an incorrect path. GRUB can not read the file system of the partition containing the /grub directory. The basic installation in the MBR worked, but the code written there contains errors, so that it is not possible to read the variables prefix and/or root due to malfunctions.
starkus avatar
de flag
Maybe it's because of faulty UUIDs and/or filesystem generated on the ssd chip due to shrinking. Or maybe due to a first boot. I don't know.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.