Is it possible to put root in LVM without using initrd

bootinitrdkernellvmroot

I have just set up a Gentoo base system (which means I can boot and log in and do stuff with it now). My root partition is in an LVM2 virtual group (with a separated /boot partition). In order to boot I need to pass the parameters below to the kernel:

root=/dev/ram0 real_root=/dev/vg/rootlv init=/linuxrc dolvm

Apparently it is using an initial ramdisk to do something (I guess loading the LVM things) before mounting root. Is there a way that I can put this code into the kernel itself so that no initrd is needed? If not, how can I make the initrd myself?

It might be useful to add that I had tried compiling the kernel for non-LVM root, without initrd and it worked perfectly. Then I tried to put the whole thing under LVM and couldn't get the machine to boot (I guess it cannot deal with the LVM stuff). Then I used the genkernel tool with the --lvm option and it creates the working kernel and initrd that I am currently using.

Now I want to skip genkernel and do everything on my own, preferably without initrd so that the machine will boot somewhat faster (I don't need the flexibility anyway).

Best Answer

Simple answer: No. If you want LVM you need an initrd.

But as others have said before: LVMs don't slow your system down or do anything bad in another way, they just allow you to create an environment that allows your kernel to load and do its job.

The initrd allows your kernel to be loaded: If your kernel is on an LVM drive the whole LVM environment has to be established before the binary that contains the kernel can be loaded.

Check out the Wikipedia Entry on initrd which explains what the initrd does and why you need it.

Another note: I see your point in wanting to do things yourself but you can get your hands dirty even with genkernel. Use genkernel --menuconfig all and you can basically set everything as if you would build your kernel completely without tool support, genkernel just adds the make bzImage, make modules and make modules_install lines for you and does that nasty initrd stuff.

You can obviously build the initrd yourself as it is outlined here for initramfs or here for initrd.

Related Question