The problem:
The USB flash drive takes alot of time to install grub
bootloader, now the grub bootloader is installed in the MBR
, but the /boot/grub/*
files may be missed or corrupted or deleted acdently, and may be a solution that is used as useful way without the need to reinstall the bootloader.
The aim:
Regenerate /boot/grub/*
files.
The question:
What are the commands needed to regenerate /boot/grub/i386-pc/*
files and /boot/grub/grubenv
except grub.cfg
file in a fatest fashion?
Solve the USB flash drive grub files without reinstalling the grub bootloader
To regenerate a new image directory (
/boot/grub/i386-pc
), we assume that the USB flash drive takes/dev/sdc1
and this commands will be applied:After these commands are applied, the USB flash drive was mmounted in
/mnt/sdc1
, the existing/boot/grub
directory in the USB flash drive was renamed to/boot/grub.old
, and the overall/usr/lib/grub/i386-pc
directory was copied to/boot/grub/i386-pc
directory of the USB flash drive. We don't need all of the files included in the directory, but the directory will have a small amount of size. the most important thing is we still need to generate the missed file/i386-pc/core.img
.To generate
/i386-pc/core.img
the following command will be applied:Now the
/core.img
is placed in/tmp
directory. if this command is not worked, try the following instead:Copy the
/tmp/core.img
to/i386-pc/core.img
in the USB flash drive:The latest file is
/boot/grub/grubenv
.The command needed is:
this command while create an empty
grubenv
file, and allow you to continue without the error:The latest thing to do is copy
grub.cfg
file from/grub.old
directory, or create a new one, and reboot to test the USB flash drive boot process.GNU GRUB Manual 2.12
How to Move, Copy, and Rename a Directory in Linux
GRUB Error 'invalid environment block' on booting & updating Ubuntu
Generate core.img file