Booting into grub rescue

Solved
letroolldu67 Posted messages 39 Status Membre -  
mamiemando Posted messages 33537 Registration date   Status Modérateur Last intervention   -
Hello,

Since a reinstallation of Ubuntu, I find myself in grub rescue.
The ls command doesn’t work! It says “Unknown file system”
What should I do?
I also read that with a Windows 10 bootable USB (Windows 10 being installed) I could do “bootrec /fixmbr” to which the prompt responds “Operation completed successfully” then I do “bootrec /fixboot” but the prompt responds “Access denied”! I don’t know what to do anymore!

Configuration: Android / Chrome 94.0.4606.71

2 réponses

mamiemando Posted messages 33537 Registration date   Status Modérateur Last intervention   7 927
 
Hello,

I confirm what Gribouille says, the simplest thing in your case is to use
boot-repair
.

However, Windows approaches will not help you reinstall
grub
, you can forget about them.

Finally, note that in absolute terms, any live USB is sufficient to repair
grub
. But this requires some knowledge (and it's similar to what
boot-repair
does for you).

Repairing grub without boot-repair

1) Boot the computer from a live USB (for example, a USB stick that allows you to install Ubuntu).

2) Open a terminal and switch to root mode, using
sudo -s
(Ubuntu) or
su -
(other distributions).

Then, identify with the command
fdisk -l
or
parted -l
the partition associated with the
/
partition of the Linux system to boot. If
/boot
is on a separate partition, you will also need to identify it.

Example: Here we are looking for a partition associated with a Linux file system. You might hesitate between
/dev/sda6
and
/dev/sda7
, but since
/
is generally significantly smaller than
/home
, we deduce that it is probably
/dev/sda6
that we are interested in.

Note that on a live USB,
/dev/sda
will probably correspond to the live USB and
/dev/sdb
to the hard disk containing your Linux, and for a standard Ubuntu installation, the / partition will likely be
/dev/sdb5
.

Example:

(root@silk) (~) # fdisk -l
[sudo] mando password:
Disk /dev/sda: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: Micron_1100_MTFD
Units: sectors of 1 × 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimal/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: F7977EE1-814B-4FC2-BD0B-4F0E9F0D433D

Device Start End Sectors Size Type
/dev/sda1 2048 534527 532480 260M EFI System
/dev/sda2 534528 567295 32768 16M Microsoft Reserved
/dev/sda3 567296 501470811 500903516 238.8G Microsoft Basic Data
/dev/sda4 501471232 503234559 1763328 861M Windows Recovery Environment
/dev/sda5 503234560 511047679 7813120 3.7G Linux Swap Partition
/dev/sda6 511047680 608704511 97656832 46.6G Linux File System
/dev/sda7 608704512 1000214527 391510016 186.7G Linux File System


Important note: in what follows, I assume that
/
corresponds to
/dev/sda6
, you must of course replace
/dev/sda6
with the device associated with your own partitioning (e.g.
/dev/sdb5
).

Note: if you installed Linux with LVM, you will also see the names of the logical volumes (the devices whose name starts with
/dev/mapper
), which we will need later. In my example, they are not visible, so it’s a non-LVM installation. If Linux is installed on the same hard disk as Windows, it is a non-LVM installation. For more information on what LVM is and what it is used for, I refer you to this page.

3) Mount the Linux system from the hard drive in the folder
/linux
(which we will create) of the live USB. We will also mount
/dev
in
/linux/dev
because the
update-grub
command will need it.

There are then some variations depending on whether you installed Linux with or without LVM.

a) If it’s a non-LVM installation:

mkdir /linux mount /dev/sda6 /linux mount --bind /dev /linux


b) If it’s an installation with LVM (unencrypted):

mkdir /linux mount /dev/mapper/vg-root /linux mount --bind /dev /linux


(the name
vg-root
may vary: it corresponds to the name of the logical volume that contains
/
).

c) If it’s an installation with LVM (encrypted):

cryptsetup luksOpen /dev/sda6 sda6_crypt # This creates /dev/mapper/sda6_crypt # Enter the LUKS password for the partition apt install lvm2 modprobe dm-mod vgchange -ay lvscan # Here we should see the device associated with the decrypted partition, e.g. /dev/mapper/vg-root mount /dev/mapper/vg-root /linux mount --bind /dev /linux 


4) At this stage, it is important to verify that you have mounted the correct partition in
/linux
by looking at the result of
ls /linux
. You should see the subdirectories
/linux/dev
,
/linux/boot
,
/linux/home
, etc...).

If
/boot
is installed on a dedicated partition, it needs to be mounted in
/linux/boot
. Note that this is generally not the case for a standard installation. We can check the content of
/linux/boot
with the command
ls /linux/boot
to confirm.

5) Reposition
/
at the level of
/linux
, so everything works "as if" we had booted normally. Then mount the last necessary parts for the proper functioning of
update-grub
.

chroot /linux/ mount -t proc proc /proc mount -t sysfs sys /sys mount -t devpts devpts /dev/pts


6) If it’s an LVM installation, start the associated service:

/etc/init.d/lvm2 start


7) Repair grub:

update-grub


If a grub module is not found (e.g.
normal.mod
), copy it into
/boot
(e.g.
cp /usr/lib/grub/i386-pc/* /boot/grub/i386-pc/
). Note that this kind of error should not happen.

8) If it’s an LVM installation, list the associated services (see
ls /etc/init.d/lvm*
) and stop each of them:

/etc/init.d/lvm2 stop # Same for each lvm service


9) Exit properly:

umount /proc umount /sys umount /dev/pts exit umount /linux/dev umount /linux reboot


Good luck!
2
Gribouille
 
If you have the installation media (disk or USB stick), boot from it and select "Try Ubuntu"
then you can attempt the boot repair in a terminal
sudo add-apt-repository -y ppa:yannubuntu/boot-repair && sudo apt update && sudo apt install -y boot-repair ; boot-repair
then recommended repair
your computer needs to be connected to the network
0