Does LVM need a /boot to install Grub?

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Incentive I.C

Does LVM need a /boot to install Grub?

Post by Incentive I.C »

I have read that it needs a /boot meaning i guess it cannot install on MBR. I basically get this error eveytime grub tries to install

"WARNING!! Install the GRUB boot loader on a hard disk

Unable to install GRUB in /dev/sda2
Executing 'grub-install /dev/sda2' failed.

This is a fatal error."

Replace the /dev/sda2 with whatever the /boot might be. Trying to do this in a Virtualbox by the way. Any help would be greatly appreciated.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
WinterTroubles

Re: Does LVM need a /boot to install Grub?

Post by WinterTroubles »

I have no expertise and have never installed in a VM, but, I have obviously installed on a regular machine so thought it worth mentioning this observation just in case it sounds relevant...
"WARNING!! Install the GRUB boot loader on a hard disk

Unable to install GRUB in /dev/sda2
Executing 'grub-install /dev/sda2' failed.

/dev/sda2 is a partition

On a regular non VM install you would usually install to /dev/sda which is the actual hard disk. The MBR does not reside within a partition, but, in a 'file' that sits outside of the partitions that the user creates.

I'm not sure if the above is relevant for a VM, but, thought it worth mentioning.
Incentive I.C

Re: Does LVM need a /boot to install Grub?

Post by Incentive I.C »

WinterTroubles wrote:I have no expertise and have never installed in a VM, but, I have obviously installed on a regular machine so thought it worth mentioning this observation just in case it sounds relevant...
"WARNING!! Install the GRUB boot loader on a hard disk

Unable to install GRUB in /dev/sda2
Executing 'grub-install /dev/sda2' failed.

/dev/sda2 is a partition

On a regular non VM install you would usually install to /dev/sda which is the actual hard disk. The MBR does not reside within a partition, but, in a 'file' that sits outside of the partitions that the user creates.

I'm not sure if the above is relevant for a VM, but, thought it worth mentioning.
Thanks. I have installed Mint before in a VBox. No LVM at the time and it installed just fine no complaints from Grub. Just somthing worth mentioning i guess.
WinterTroubles

Re: Does LVM need a /boot to install Grub?

Post by WinterTroubles »

Then my observation was pointless and irrelevant :oops: Apologies.
clfarron4

Re: Does LVM need a /boot to install Grub?

Post by clfarron4 »

Incentive I.C wrote:I have read that it needs a /boot meaning i guess it cannot install on MBR.
If you are using LVM on LUKS or LVM on LUKS (encrypted LVM) then you need a separate /boot.

I'm pretty sure you don't need a separate /boot if you are running plain LVM, though I think a couple of tweaks are needed (the ArchWiki is down right now, so I can't help an further).
srs5694
Level 6
Level 6
Posts: 1386
Joined: Mon Feb 27, 2012 1:42 pm

Re: Does LVM need a /boot to install Grub?

Post by srs5694 »

WinterTroubles wrote:/dev/sda2 is a partition

On a regular non VM install you would usually install to /dev/sda which is the actual hard disk. The MBR does not reside within a partition, but, in a 'file' that sits outside of the partitions that the user creates.
VM != LVM

A virtual machine (VM) is a simulation of a computer, which enables you to run one OS inside another one, such as Windows inside Linux, Linux inside OS X, or even Linux within Linux.

The Logical Volume Manager (LVM) is a Linux tool that supplements or replaces regular disk partitions. LVM is much more flexible than regular partitions; it enables you to split filesystems across physical disks, add a large filesystem that's larger than any one chunk of free space (with the cost of fragmenting the filesystem), and so on.

You're right that, on a BIOS-based computer, GRUB's first stage normally resides in the MBR, which exists outside of any partition or filesystem. GRUB also relies on other code that's stored elsewhere, including inside normal filesystems, and that does create certain limitations -- GRUB needs a way to read the filesystem that holds its configuration and support files. GRUB includes a number of drivers to do this. I'm pretty sure that an LVM driver is among those that GRUB provides, but I personally have never tried an installation in which the GRUB files reside inside an LVM. For that matter, most distributions that use LVM rely on a separate /boot partition to hold the kernel and GRUB support files.

In sum, a BIOS-mode GRUB relies on code stored several places, which normally includes both the MBR and files in the Linux /boot directory. The details vary depending on the installation, though.
WinterTroubles

Re: Does LVM need a /boot to install Grub?

Post by WinterTroubles »

srs5694

I was distracted and misread the subject line, I'm a fool and possibly illiterate.. Thank you for pointing this out with such clarity.. I'm now off to look for a very large hole to hide in until time ends or my desire to learn about Linux goes away :oops: :lol:
Incentive I.C

Re: Does LVM need a /boot to install Grub?

Post by Incentive I.C »

I think i found something that might get it to work. Just got to find the page again. Once i try it I will post if it works or not.
Incentive I.C

Re: Does LVM need a /boot to install Grub?

Post by Incentive I.C »

Is this what LVM is suppose to look like set up? How would you resize it as Gparted doesn't seem to know how...
I made the boot differently this time and that seems to have gotten it to work.
Incentive I.C

Re: Does LVM need a /boot to install Grub?

Post by Incentive I.C »

Don't know if this is a side affect from how i set it up but the package manager is having trouble installing. Its stick on running-post installation trigger initramsfs-tools

in details: update-initramfs: Generating /boot/initrd.img-3.13.0-24 generic

Is this because of the boot partition? My goal is to get a fully working LVM on Vbox before even thinking about taking the time to put it on the actually drive. All the problem i am having thank goodness i decied to do that :)
WharfRat

Re: Does LVM need a /boot to install Grub?

Post by WharfRat »

Incentive I.C

The lvm is assembled and activated by initrd after udev is started. Therefore you can't access a /boot partition on a logical volume since the mapper device hasn't yet been pieced together.

The grub kernel line will have a reference to the device mapper like root=/dev/mapper/mint--vg-root Instead of a partition UUID.

So yes, you have to have /boot residing on a partition that grub can access to start the kernel and initram.

Good luck :wink:
Incentive I.C

Re: Does LVM need a /boot to install Grub?

Post by Incentive I.C »

WharfRat wrote:Incentive I.C

The lvm is assembled and activated by initrd after udev is started. Therefore you can't access a /boot partition on a logical volume since the mapper device hasn't yet been pieced together.

The grub kernel line will have a reference to the device mapper like root=/dev/mapper/mint--vg-root Instead of a partition UUID.

So yes, you have to have /boot residing on a partition that grub can access to start the kernel and initram.

Good luck :wink:
So basically I have to have a boot partition that is not in LVM? I tried that and Grub won't even install.
WharfRat

Re: Does LVM need a /boot to install Grub?

Post by WharfRat »

I don't know exactly how you're doing this as the default installation option for lvm will create a /boot. but did you mount /boot before doing what you're doing :?:
eanfrid

Re: Does LVM need a /boot to install Grub?

Post by eanfrid »

You can have /boot inside an LVM volume but AFAIK it must de done afterwards, in a second step, because grub did not load its own lvm module. You have in this second step to add to /etc/default/grub the parameter:

Code: Select all

GRUB_PRELOAD_MODULES="lvm"
and issue a "sudo update-grub". You will then be able to move /boot inside the LVM volume.
Incentive I.C

Re: Does LVM need a /boot to install Grub?

Post by Incentive I.C »

WharfRat wrote:I don't know exactly how you're doing this as the default installation option for lvm will create a /boot. but did you mount /boot before doing what you're doing :?:
The default installation option wipes everything. I not sure if the boot was mounted during the installation but i think gparted said LVM was mounted so i guess boot was mounted as well

I am following this http://forums.linuxmint.com/viewtopic.php?f=42&t=40961
WharfRat

Re: Does LVM need a /boot to install Grub?

Post by WharfRat »

I'd be interested in seeing the grub entry for this. I read through the installation procedure, but I still don't follow how it can boot before the logical volumes are setup :?

I don't think the chroot is necessary any more as my petra 16 has lvm2 installed and I know I didn't install it since I'm not utilizing lvm on this particular setup.

Boot the live media and mount your root to /mnt.

Code: Select all

sudo -i
mount /dev/mapper/mint--vg-root /mnt
Use whatever name you used for the vg-lv.

Code: Select all

grep vmlinuz /mnt/boot/grub/grub.cfg
Incentive I.C

Re: Does LVM need a /boot to install Grub?

Post by Incentive I.C »

WharfRat wrote:I'd be interested in seeing the grub entry for this. I read through the installation procedure, but I still don't follow how it can boot before the logical volumes are setup :?

I don't think the chroot is necessary any more as my petra 16 has lvm2 installed and I know I didn't install it since I'm not utilizing lvm on this particular setup.

Boot the live media and mount your root to /mnt.

Code: Select all

sudo -i
mount /dev/mapper/mint--vg-root /mnt
Use whatever name you used for the vg-lv.

Code: Select all

grep vmlinuz /mnt/boot/grub/grub.cfg
Alright will do. Just keep in mind this is on a VirtualBox so I don't know if that could cause any different effects with the command.
Locked

Return to “Installation & Boot”