Jump to content
funtoo forums
  • 0
mauricev

lvm trips up grub

Question

I run a script regularly on my computer that prepares all the configuration. It also reinstalls grub. But recently, it occasionally has a problem with lvm and that causes the machine, which is virtual, to get stuck at the grub screen unable to find the kernel. 

When I install grub

/usr/sbin/grub-install --target=i386-pc --no-floppy /dev/sda

And it happens to respond

Installing for i386-pc platform.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
Installation finished. No error reported.

Grub will get stuck and not be able to find the kernel.

Boot.conf looks like this

boot {
	generate grub
	default "Funtoo Linux genkernel" 
	timeout 3 
}


"Funtoo Linux genkernel" {
	kernel kernel-debian-sources-x86_64-4.8.15-1
	initrd initramfs-debian-sources-x86_64-4.8.15-1
	params += dolvm real_root=auto rootfstype=ext4 resume=swap:/dev/mapper/funtoo-swap quiet
} 

 

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

 

On 31.1.2018 at 11:43 PM, mauricev said:

I run a script regularly on my computer that prepares all the configuration. It also reinstalls grub.

did you forcibly unmount /boot? if yes, then don't do it. if you don't want your /boot mounted then modify your script to mount /boot before running the stuff and reinstalling grub.

reinstalling grub is not needed on regular basis (only after grub version update), all you need to modify is /boot/grub/grub.cfg, but also only if your kernels change. correct your /etc/fstab it is actually all working as it should be.

what is probably going on here is if /boot is not mounted then grub-install installs and makes a reference to /boot that is on / (root partition)  putting all the files there etc, with no error - which is ok.

when boot-update is run it mounts /boot over the /boot directory that is containing the install of grub and puts the grub.cfg there with reference to /boot on separate partition. setting the root device for grub to /boot that doesn't contain a correct grub installation, because it got installed to root partition and not /boot partition. But this is also expected.

to check my theory run ls -alF /boot when boot mounted and when not mounted.

To sum up - it works as expected, if you want to run regularly this script that reinstalls grub and does all the fancy things... , make sure boot is mounted.

Share this post


Link to post
Share on other sites
  • 0

ls -alF /boot shows nothing when /dev/sda1 is not mounted. grub.cfg and the kernels reside on /dev/sda1, not in the empty /boot directory.

When /dev/sda1 is not mounted and grub is installed, it spews bogus errors about lvm but no other errors. However, the machine loses the ability to boot because it now can’t find the kernel.

bcowan seems to be claiming this behavior is impossible. But you’re claiming that it’s normal? That /dev/sda1 must be mounted when grub is installed or am I misunderstanding?

Please disregard my mention of any custom script. I'm talking exclusively about installing grub.

Share this post


Link to post
Share on other sites
  • 0

how do you know it can't find kernel? ever tried to do manual grub start. selecting root device and loading the kernel ...

grub> set root=(hd0,msdos1) #probably, I am just guessing here, but tab complete works in grub

grub> linux /kernel real_root=/dev/mapper/funtoo

grub> initird /initrd

grub> boot

these lines are just guesses take a look at grub.cfg and make note of those lines.

Or just try ls (hd<TAB><TAB> should autocomplete to something sane like hd0,msdos1)/

so for example

ls (hd0,msdo1)/

should list some files if it is /boot (sda1)

if it sees the files there all you are missing is grub.cfg which gets lost somewhere.

I think you just need to make sure /boot is mounted then.

what is the output of boot-update when /boot not mounted?

Share this post


Link to post
Share on other sites
  • 0

It does find the kernel if I enter the info manually at the grub prompt. But what does that tell us? If it's not finding it automatically, it's effectively the same as not finding it unless you consider it normal for users to have to manually enter the kernel information at every startup.

Running boot-update with /dev/sda1 not mounted has no effect on grub failing. It still fails. 

Share this post


Link to post
Share on other sites
  • 0

what is the output of boot-update with un/mounted boot

 

what versions of grub, boot-update do you have

 

what gets displayed when you type

 

configfile /grub/grub.cfg

 

in grub prompt

 

 

Share this post


Link to post
Share on other sites
  • 0

With /dev/sda1 mounted or not, I get the same output from boot-update

Copyright 2009-2017 Funtoo Technologies

 [use option "-l" for license info, "-h" for help]



  * Generating config for grub...


  DEFAULT > Funtoo Linux genkernel - kernel


  * NOTE: Detected MBR boot. Configuring for Legacy MBR booting.

  * WARN: Intel system detected - please emerge sys-firmware/intel-microcode and sys-apps/iucode-tool and run

          boot-update again; boot-update will then patch your system with the latest Intel CPU and chipset microcode patches

          at boot-time, protecting you against important vulnerabilities and errata.


  * Completed successfully with warnings.

When /dev/sda1 is not mounted, boot-update enters this in the system log

Feb 04 00:32:16 [kernel] [  231.913202] EXT4-fs (sda1): mounting ext2 file system using the ext4 subsystem

Feb 04 00:32:16 [kernel] [  231.928341] EXT4-fs (sda1): mounted filesystem without journal. Opts: (null)

Grub is at 2.02_beta3-r2. boot-update is 1.8.2.

At the failed grub prompt, configfile grub/grub.conf results in no output. It just gives me another blank prompt. It's not that it can't find the kernel; it can't find grub.conf

Share this post


Link to post
Share on other sites
  • 0

Your last post shows the output of boot-update not finding a kernel and the second output shows it automounting sda1 as your /boot when not mounted. Also its grub.cfg not grub.conf if that is not just a typo you wrote in the post.

Share this post


Link to post
Share on other sites
  • 0
8 minutes ago, bcowan said:

761A06EE-8EFE-4D85-9981-9323CC0C6BA7.jpeg.38da45d110bee0a99799a3dd0be0349d.jpeg

It should print the name of the kernel it finds after label your kernel- is blank

No, it's not blank. I just changed the name of the kernel to "kernel", so I wouldn't have to worry about mistyping it manually in the grub command line.

Share this post


Link to post
Share on other sites
  • 0
3 minutes ago, palica said:

try

 

configfile (hd0,msdos1)/grub/grub.cfg

 

deos that do something?

Yes, it boots the machine! So whatever makes grub work automatically gets blocked somehow by not having /dev/sda1 mounted at install time.

Share this post


Link to post
Share on other sites
  • 0
8 hours ago, mauricev said:

Now that you have concisely written down the steps you were doing and what you expected vs. what was happening, I do not see this as a bug but expected behavior.  Grub-install indeed needs a mounted /boot or passed another writeable directory with the —boot-directory argument.  This is done one single time only during your initial install. ( it writes a few files, notably grub.env and device.map ) You should not have to run grub-install again unless you corrupted something or another OS etc overwrites it.  You then can run boot-update.  It seems you are doing these steps in the wrong order.  The install page documents these steps in the correct  order.  Boot should not need to be mounted for a working startup. The only thing that should need ran again is boot-update when you change kernels etc, never a grub-install.  

weird that the forum top posted my reply a couple hours ago????

Share this post


Link to post
Share on other sites
  • 0

Wow, all those messages to come here. Thanks for everyone's efforts.

Does grub require anything to be read from /dev/sda1 when it's installed? If it does and that stuff isn't present because /dev/sda1 is not mounted, then it should report an error. All this time, I was getting warnings about LVM, but there was never any error reported.

Share this post


Link to post
Share on other sites
  • 0

I was getting "failed to connect to lvmetad", so I tried the (theoretically inert) fix of taking "noauto" away from my boot line in /etc/fstab.

The error is gone. So I put the "noauto" back in, and it is still "fixed".

Is there some one-time function that needs to read /boot when a new kernel is built?

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×