[Solved] How to mount '/boot' which is rooted inside '/' covered within LVM?

Ask for help with issues regarding the Installations of the Debian O/S.
Post Reply
Message
Author
User avatar
nikobit
Posts: 154
Joined: 2009-02-08 19:40
Location: Moscow, Russia
Has thanked: 20 times
Been thanked: 1 time
Contact:

[Solved] How to mount '/boot' which is rooted inside '/' covered within LVM?

#1 Post by nikobit »

Hi all!
Due to PCR failure my PC have lost something in UEFI and I haven't got Debian 11 installation but Win10 instead.
One fine day I have lost GRUB from Secure UEFI and got only Win10 left.
Luckily I still have LiveUSB with installation menu and could boot into the system to find out there's no more GRUB in UEFI list:

Code: Select all

user@debian:~$ efibootmgr
BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0001,0000
Boot0000* Windows Boot Manager
Boot0001* UEFI: Generic Flash Disk 8.07
The main problem to get use of GrubEFIReinstallation manual is the fact that I had managed my disk partitions with encrypted LVM and got '/boot' directory to be kept within '/' LVM.
So using above mentioned wiki source gets me stuck at the Third Check Point where the partition mounting starts.
I just can't mount '/boot' partition hidden inside LVM covered '/'
Any thoughts how to do it?
I've tried everything from the wiki.debian.org/GrubEFIReinstall and got some results.
Like '/sys/firmware/efi/efivars/' is safe and kept where it should be.
Here is my 'fdisk -l' output
Followed by ' vgdisplay && lgdisplay' combined.
Is there a chance to restore GRUB by mounting /boot partition back and simply following on wiki.debian.org/GrubEFIReinstall?
!!!
!!!
!!!
UPDATE: I could manage to join the partition '/dev/sda1' to '/mnt/boot' and by LVM wiki study to organize remaining of '/mnt/' folder from the GrubEFIReinstallation manual by use of 'KDE partitionmanager' from this location.
But here comes tricky part of article 4 in it:

Code: Select all

# for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
It just doesn't run in my case. Keeps giving me

Code: Select all

'user@debian:~$ sudo for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
bash: syntax error near unexpected token `do'
How to correct the command above so it performs in the shell?
Last edited by nikobit on 2024-04-08 09:30, edited 1 time in total.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • OS: Debian 11 bullseye
  • Kernel: x86_64 Linux 5.10.0-32-amd64
  • DE: GNOME 3.38.6
  • CPU: Intel Core i7-4790 @ 8x 4GHz
  • GPU: llvmpipe (LLVM 11.0.1, 256 bits) / NVE4
  • RAM: 2384MiB / 15925MiB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lindi
Debian Developer
Debian Developer
Posts: 571
Joined: 2022-07-12 14:10
Has thanked: 2 times
Been thanked: 114 times

Re: How to mount '/boot' which is rooted inside '/' covered within LVM?

#2 Post by lindi »

sudo takes a command as a an argument, "for" is not a command, it is builtin of your shell.

User avatar
nikobit
Posts: 154
Joined: 2009-02-08 19:40
Location: Moscow, Russia
Has thanked: 20 times
Been thanked: 1 time
Contact:

Re: How to mount '/boot' which is rooted inside '/' covered within LVM?

#3 Post by nikobit »

lindi wrote: 2024-04-08 04:44 sudo takes a command as a an argument, "for" is not a command, it is builtin of your shell.
I can't quite understand that.

Code: Select all

# for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
describes folders ment to be consider as placed in '/' while actually are present in '/mnt'.
As soon as LiveUSB can't provide '#' environment and one should use 'sudo' instead is there a way out of this?
I tried to follow articles 5, 6 and 7 in GrubEFIReinstallation and got only this:

Code: Select all

user@debian:/mnt$ sudo chroot /mnt
root@debian:/# grub-install /dev/sda
grub-install: error: /usr/lib/grub/i386-pc/modinfo.sh doesn't exist. Please specify --target or --directory.
root@debian:/# update-grub        
/usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).
root@debian:/# 
exit
Should I run:

Code: Select all

$ sudo chroot for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
in that way?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • OS: Debian 11 bullseye
  • Kernel: x86_64 Linux 5.10.0-32-amd64
  • DE: GNOME 3.38.6
  • CPU: Intel Core i7-4790 @ 8x 4GHz
  • GPU: llvmpipe (LLVM 11.0.1, 256 bits) / NVE4
  • RAM: 2384MiB / 15925MiB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lindi
Debian Developer
Debian Developer
Posts: 571
Joined: 2022-07-12 14:10
Has thanked: 2 times
Been thanked: 114 times

Re: How to mount '/boot' which is rooted inside '/' covered within LVM?

#4 Post by lindi »

Don't run "sudo for", just run "for"?

lindi
Debian Developer
Debian Developer
Posts: 571
Joined: 2022-07-12 14:10
Has thanked: 2 times
Been thanked: 114 times

Re: How to mount '/boot' which is rooted inside '/' covered within LVM?

#5 Post by lindi »

Actually, you are already calling sudo inside the loop. There is no need to call sudo two times in this case. So just running

Code: Select all

for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
should work. That said, you really should make sure you understand everything you run as root before you try to run it. Otherwise you may unfortunately easily end up breaking things badly.

User avatar
nikobit
Posts: 154
Joined: 2009-02-08 19:40
Location: Moscow, Russia
Has thanked: 20 times
Been thanked: 1 time
Contact:

Re: How to mount '/boot' which is rooted inside '/' covered within LVM?

#6 Post by nikobit »

lindi wrote: 2024-04-08 06:24 Don't run "sudo for", just run "for"?
It worked like charm!

Code: Select all

user@debian:~$ ls -a /mnt/
.   bin   .cache  etc   initrd.img      lib    lib64   lost+found  mnt  proc  run   srv  tmp  var      vmlinuz.old
..  boot  dev     home  initrd.img.old  lib32  libx32  media       opt  root  sbin  sys  usr  vmlinuz
user@debian:~$ ls -a /mnt/boot/efi
 .    EFI     FSCK0000.REC   ST10557.8817    ST29409.16675   ST433.24930                  Temp
 ..   en-us   PRELOAD        ST27041.14642   ST3407.18173   'System Volume Information'
user@debian:~$ for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
user@debian:/$ sudo chroot /mnt
root@debian:/# grub-install /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.
root@debian:/# update-grub
Generating grub configuration file ...
using custom appearance settings
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-5.10.0-28-amd64
Found initrd image: /boot/initrd.img-5.10.0-28-amd64
Found linux image: /boot/vmlinuz-5.10.0-27-amd64
Found initrd image: /boot/initrd.img-5.10.0-27-amd64
Found linux image: /boot/vmlinuz-5.10.0-25-amd64
Found initrd image: /boot/initrd.img-5.10.0-25-amd64
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
grub-probe: error: cannot find a GRUB drive for /dev/sdc1.  Check your device.map.
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done
root@debian:/# 
exit
followed by Ctrl+D to exit '#'
Finally I had to 'umount' both '/' and '/boot/efi' folders. But I perform it via 'KDEPartitionmanager' interface as the easiest one. Finally - reboot.
Thank you so much!
But shouldn't the wiki be corrected in a way that article 4 will look like this?

Code: Select all

$ for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
Exactly like it is shown in shell?
Last edited by nikobit on 2024-04-14 12:38, edited 1 time in total.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • OS: Debian 11 bullseye
  • Kernel: x86_64 Linux 5.10.0-32-amd64
  • DE: GNOME 3.38.6
  • CPU: Intel Core i7-4790 @ 8x 4GHz
  • GPU: llvmpipe (LLVM 11.0.1, 256 bits) / NVE4
  • RAM: 2384MiB / 15925MiB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lindi
Debian Developer
Debian Developer
Posts: 571
Joined: 2022-07-12 14:10
Has thanked: 2 times
Been thanked: 114 times

Re: How to mount '/boot' which is rooted inside '/' covered within LVM?

#7 Post by lindi »

The "#" means, "run as root". In this case the way to do that would be

Code: Select all

sudo bash -c "for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done"
or by first running

Code: Select all

sudo -i
to get a root shell and then running

Code: Select all

for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
.

Just adding "sudo " in front of a shell snippet that should be run as root won't work. For example think about why "sudo cat /etc/motd > /root/motd" fails but running "cat /etc/motd > /root/motd" as root works?

User avatar
nikobit
Posts: 154
Joined: 2009-02-08 19:40
Location: Moscow, Russia
Has thanked: 20 times
Been thanked: 1 time
Contact:

Re: How to mount '/boot' which is rooted inside '/' covered within LVM?

#8 Post by nikobit »

lindi wrote: 2024-04-08 06:59 Just adding "sudo " in front of a shell snippet that should be run as root won't work. For example think about why "sudo cat /etc/motd > /root/motd" fails but running "cat /etc/motd > /root/motd" as root works?
Last things first:
May I solve your riddle in a way:

Code: Select all

sudo cat /etc/motd > sudo /root/motd
?
As LiveUSB has no 'user' at all and everything is performed there under "cut" root authority I was able to run the command with simple '$' prefix. That is why I got so confused performing Wiki directions strictly.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • OS: Debian 11 bullseye
  • Kernel: x86_64 Linux 5.10.0-32-amd64
  • DE: GNOME 3.38.6
  • CPU: Intel Core i7-4790 @ 8x 4GHz
  • GPU: llvmpipe (LLVM 11.0.1, 256 bits) / NVE4
  • RAM: 2384MiB / 15925MiB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lindi
Debian Developer
Debian Developer
Posts: 571
Joined: 2022-07-12 14:10
Has thanked: 2 times
Been thanked: 114 times

Re: How to mount '/boot' which is rooted inside '/' covered within LVM?

#9 Post by lindi »

nikobit wrote: 2024-04-08 09:30 May I solve your riddle in a way:

Code: Select all

sudo cat /etc/motd > sudo /root/motd
?
Good try but this won't work either. You need to study how the shell works bit more. The ">" sign is special syntax that is processed before any commands are executed.
nikobit wrote: 2024-04-08 09:30 As LiveUSB has no 'user' at all and everything is performed there under "cut" root authority I was able to run the command with simple '$' prefix. That is why I got so confused performing Wiki directions strictly.
I am pretty sure the liveusb has both a normal user and root. You can see the current user by running for example the command "id".

User avatar
nikobit
Posts: 154
Joined: 2009-02-08 19:40
Location: Moscow, Russia
Has thanked: 20 times
Been thanked: 1 time
Contact:

Re: [Solved] How to mount '/boot' which is rooted inside '/' covered within LVM?

#10 Post by nikobit »

Luckily I had these hints to redo the same thing again as the problem with CMOS battery remained and have kept my 'UEFI' being updated with 'Debian UEFI' deleted every other boot up.
By replacing battery with common CR2032 I got rid of RPC fault. Nevertheless after successfull 'UEFI Debian' setting I've seen something happen over the boot screen:
[ 1.442752] DMAR: DRHD: handling fault status reg 2
[ 1.442757] DMAR: [DMA Read] Request device [01:00.0] PASID ffffffff fault addr 0 [fault reason 06] PTE Read access is not set
mdadm: No arrays found in config file or automatically
### Then follows 19 lines of the same message over the boot screen ###
mdadm: No arrays found in config file or automatically
mdadm: error opening /dev/md?*: No such file or directory
mdadm: No arrays found in config file or automatically
### Then follows 11 lines of the same message over the boot screen ###
mdadm: No arrays found in config file or automatically
Gave up waiting for suspend/resume device
RT: clean, 767984/7398670 files, 7516495/25563215 blocks
fsckd-cancel-msg:Press Ctrl+C to cancel all filesystem checks in progress
_
[ OK ] Finished Tell Plymouth To Write Out Runtime Data.


After which normal boot proceeds as it should.
That info repeats each boot up. Should I take any action to avoid it?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • OS: Debian 11 bullseye
  • Kernel: x86_64 Linux 5.10.0-32-amd64
  • DE: GNOME 3.38.6
  • CPU: Intel Core i7-4790 @ 8x 4GHz
  • GPU: llvmpipe (LLVM 11.0.1, 256 bits) / NVE4
  • RAM: 2384MiB / 15925MiB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

User avatar
sunrat
Site admin
Site admin
Posts: 7365
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 133 times
Been thanked: 649 times

Re: [Solved] How to mount '/boot' which is rooted inside '/' covered within LVM?

#11 Post by sunrat »

mdadm is for RAID. You may be able to remove the package if you don't use RAID. I don't think it is required for LVM.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

User avatar
nikobit
Posts: 154
Joined: 2009-02-08 19:40
Location: Moscow, Russia
Has thanked: 20 times
Been thanked: 1 time
Contact:

Re: [Solved] How to mount '/boot' which is rooted inside '/' covered within LVM?

#12 Post by nikobit »

sunrat wrote: 2024-04-15 04:58 mdadm is for RAID. You may be able to remove the package if you don't use RAID. I don't think it is required for LVM.
There was no need for that. I've no clear understanding but all the way easy solution comes from Ubuntu side:

Code: Select all

$ sudo update-initramfs -u 
and

Code: Select all

$ sudo update-grub
concenquently.
There was no need to touch 'mdadm' package even.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • OS: Debian 11 bullseye
  • Kernel: x86_64 Linux 5.10.0-32-amd64
  • DE: GNOME 3.38.6
  • CPU: Intel Core i7-4790 @ 8x 4GHz
  • GPU: llvmpipe (LLVM 11.0.1, 256 bits) / NVE4
  • RAM: 2384MiB / 15925MiB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Post Reply