Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
initramfs still required for LVM root partition with GRUB2?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Thomas Carrie
n00b
n00b


Joined: 19 Apr 2004
Posts: 70

PostPosted: Mon Dec 23, 2013 2:57 pm    Post subject: initramfs still required for LVM root partition with GRUB2? Reply with quote

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:

Code:

# 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:

Code:

# 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

Code:

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
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Mon Dec 23, 2013 4:47 pm    Post subject: Reply with quote

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

and specify your root in the menuentry as:

set root=lvm/lvm_group_name-lvm_logical_boot_partition_name

Example:

# (0) Arch Linux
menuentry "Arch Linux" {
insmod lvm
set root=lvm/VolumeGroup-lv_boot
# you can only set following two lines
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro
initrd /initramfs-linux.img
}


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.
Back to top
View user's profile Send private message
Thomas Carrie
n00b
n00b


Joined: 19 Apr 2004
Posts: 70

PostPosted: Mon Dec 23, 2013 6:18 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2971
Location: Germany

PostPosted: Mon Dec 23, 2013 9:38 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum