# initramfs still required for LVM root partition with GRUB2?

## Thomas Carrie

Hello,

I have /boot partition on /dev/sda1 (ext3 partition)

I have / partition on /dev/mapper/vg-r64, it is a ext4 partition managed by LVM.

I am using GRUB2, I have plain vanilla grub2 conf:

```

# grep -v  ^# /etc/default/grub | grep -v '^$'

GRUB_DISTRIBUTOR="Gentoo"

GRUB_DEFAULT=0

GRUB_HIDDEN_TIMEOUT=0

GRUB_HIDDEN_TIMEOUT_QUIET=true

GRUB_TIMEOUT=10

```

Until now I am booting with an initramfs in the kernel that takes care of mounting /dev/mapper/vg-r64 and root switching:

```

# cat /usr/src/initramfs/init 

#!/bin/busybox sh

mount -t proc none /proc

mount -t sysfs none /sys

mount -t devtmpfs none /dev

lvm vgscan -v --mknodes

lvm lvchange -aly vg/r64

mount -o ro /dev/mapper/vg-r64 /mnt/root

umount /proc /sys /dev

exec switch_root /mnt/root /sbin/init

```

Wiki Gentoo GRUB2 points out that GRUB2 is LVM aware, so I:

 add GRUB_PRELOAD_MODULES=lvm to /etc/default/grub

 remove my built-in initramfs of kernel

 redeploy my kernel, re-generate grub config and reboot

Unfortunately it does not boot. From the GRUB shell I can see my LVM root partition, his name is (lvm/vg-r64)

Do you think GRUB2 is enough to boot / partition managed by LVM without initramfs ? If yes what else should be done ?

I have tried also to create manually my entry such as

```

menuentry "rootLVM" {

        load_video

        insmod gzio

        insmod part_msdos

        insmod ext2

        insmod lvm

        set prefix=(hd0,msdos1)/grub

        set root=(hd0,msdos1)

        linux   /kernel-3.10.17-gentoo root=/dev/mapper/vg-r64 ro

}

```

it fails to boot with kernel panic

----------

## Roman_Gruber

Hi.

https://wiki.archlinux.org/index.php/GRUB

 *Quote:*   

> LVM
> 
> If you use LVM for your /boot, add the following before menuentry lines:
> 
> insmod lvm
> ...

 

I think you should set the lvm_volume name in the set root= line in your grub config.

As I still use an initrd which I always reuse without rebuilding for ages here on my lvm/luks volume I can just give you a guess in this issue.

Just my guess and an example: 

my mapping on my box is this: /dev/mapper/vg_root_volume-lv_real_root

so something around set root=/dev/mapper/vg_root_volume-lv_real_root or set root=vg_root_volume-lv_real_root if you had the same mappings as myself.

Please consider you can change the boot configuration in grub2 and than boot with these changes to test things out.

----------

## Thomas Carrie

I understand the structure of the LVM related commands from tw04l124 response and Arch's wiki, 

The first root to set (in grub script) is the boot partition for GRUB2

The second root to set (as kernel parameter) is the linux root partition for the kernel.

Although I still have an error when the kernel is trying to mount the real root, the log is incomplete because resolution is so low (maybe 24 lines displayed) that I haven't got detailed explanation of what is wrong with the device it is looking for.

I think I will stay with initramfs, I was hoping that GRUB2 could eliminate it because the scripting capabilities looks similar at first glance with initramfs.

----------

## frostschutz

Aren't you mixing some things?

Grub 2 may be able to load a kernel image from a LVM filesystem.

The kernel itself still needs initramfs to see the LVM and subsequently mount it. The boot loader is no longer involved at this point.

----------

