Jump to content
Forums in Read-Only Mode - Please use Reddit ×
  • 0

lvm trips up grub


mauricev

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
} 

 

Link to comment
Share on other sites

Recommended Posts

  • 1
/dev/sda1: LABEL="boot" UUID="2149e6d9-3d79-492d-9d6f-db6b952852a5" TYPE="ext2" PARTUUID="4f090ca0-01"
/dev/sda2: UUID="awsCeO-ZbWl-OO0i-zxsF-E22P-9WZb-08aoG1" TYPE="LVM2_member" PARTUUID="4f090ca0-02"
/dev/mapper/funtoo-swap: LABEL="swap" UUID="1eca2d56-9c4b-4673-94a3-a9c76cca4967" TYPE="swap"
/dev/mapper/funtoo-log: LABEL="log" UUID="92c90ca6-216f-4b77-9338-07f17073377b" TYPE="ext4"
/dev/mapper/funtoo-root: LABEL="root" UUID="1fb6792e-fc44-49cb-aa57-9fcd42ee1979" TYPE="ext4

 

Link to comment
Share on other sites

  • 1

This post still confuses me.  /boot not being mounted has nothing to do with grub. Grub uses its own abstraction layer to read grub.cfg which points it to a initrd/kernel.  This "abstraction layer" never "mounts" anything, grub has no knowledge of mounts.  So only your grub.cfg could be wrong, or not written because you didn't manually mount /boot, but pretty sure boot-update automounts /boot so grub-mkconfig can write grub.cfg unless specified to not automount.

Link to comment
Share on other sites

  • 1

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.  

Link to comment
Share on other sites

  • 0

I'm not sure what problem your answer is trying to address, 1) grub tripping up when it's installed and /boot isn't mounted, or 2) why /boot doesn't mount at boot time.

On other systems without LVM, there isn't either problem. You certainly don't need the --disklabel argument or an actual root passed.

Link to comment
Share on other sites

  • 0

I don't understand what you mean that /boot is never mounted at boot time. I have a bunch of funtoo machines and when they startup, /boot is mounted. Only on the machine with lvm does it not mount.

The original problem was that on the lvm machine, the /etc/fstab entry for mounting /boot is being ignored. Installing grub with /boot not mounted results in those LVM errors and grub being unable to load the kernel. Manually mounting /boot seems to fix this problem.

Link to comment
Share on other sites

  • 0

It seems to make sense that in order to run boot-update, /boot must be mounted. How else would save the grub.cfg file? But does grub installation require access to the grub.cfg file at the precise time it's being installed? If there the answer is no, then there is a bug in the installation of grub. However, either way, it shouldn't be complaining about LVM.

If the answer is yes, then the only bug is that utilizing LVM blocks the mount of /boot in /etc/fstab at boot time.

Here is the contents of grub.cfg

set timeout=3

  insmod part_msdos
  insmod ext2
  set root=(hostdisk//dev/sda,msdos1)
  search --no-floppy --fs-uuid --set 2149e6d9-3d79-492d-9d6f-db6b952852a5
if loadfont /grub/unifont.pf2; then
   set gfxmode=text
   insmod all_video
   terminal_output gfxterm
fi

set menu_color_normal=cyan/blue
set menu_color_highlight=blue/cyan

menuentry "Funtoo Linux genkernel - kernel-debian-sources-x86_64-4.8.15-1" {
  insmod part_msdos
  insmod ext2
  set root=(hostdisk//dev/sda,msdos1)
  search --no-floppy --fs-uuid --set 2149e6d9-3d79-492d-9d6f-db6b952852a5
  linux /kernel-debian-sources-x86_64-4.8.15-1 dolvm rootfstype=ext4 resume=swap:/dev/mapper/funtoo-swap quiet real
_root=/dev/funtoo/root rootfstype=ext4
  initrd /initramfs-debian-sources-x86_64-4.8.15-1
	set gfxpayload=keep
}
set default=0

 

Link to comment
Share on other sites

  • 0

so to sum up:

  • grub install ok
  • lvm is not the culprit (those warning can be ignored /run/lvm/lvmetad.socket ...)
  • /boot not being automounted from openrc is causing the problem

unable to reproduce in virtualbox, boot gets mounted. After reboot what do you get when running

mount |grep boot

try rebuilding openrc, when that doesn't help, then I don't know.

Link to comment
Share on other sites

  • 0

Not exactly. There are two scenarios, running the grub installation and /boot mounted and one where it’s not mounted.

With /boot not mounted

1) grub will report bogus LVM warnings and no actual error.

2) At the subsequent startup, grub will not find the kernel and get stuck at the grub command prompt.

With /boot mounted (The rc logs represent this scenario.)

1) grub will install fine with no warnings, and the machine will boot up fine

2) /boot mount entry in /etc/fstab gets ignored and /boot is never mounted (no output from mount |grep boot)

To reproduce all this, did you create a disk formatted to follow what you see in blkid? I believe this exact configuration is critical to reproducing these bugs.

Link to comment
Share on other sites

  • 0

I actually changed it to device name

/dev/funtoo/root        /               ext4            noatime         0 1

/dev/sda1 /boot ext2 noauto,noatime 1 2

/dev/funtoo/swap none swap sw 0 0

/dev/funtoo/log /var/log ext4 noatime 0 1

/dev/funtoo/root        /               ext4            noatime         0 1
/dev/sda1		/boot		ext2		noauto,noatime	1 2
/dev/funtoo/swap	none		swap		sw		0 0
/dev/funtoo/log		/var/log	ext4		noatime		0 1

And that has no effect. /boot doesn't get mounted.

Link to comment
Share on other sites

×
×
  • Create New...