In this tutorial, we will explain the Linux boot process in general, and how it works when Linux is installed on an LVM volume. It’s recommended to read the previous chapter about LVM if you are not already familiar with LVM. This section will also give you a good understanding of the Linux boot process in general even if you don’t use LVM, so it’s worth reading. It is recommended that you read the previous pages about LVM before reading this one.
Many linux distributions such as Redhat/Fedora allow you to install the root filesystem on an LVM Logical Volume. This way you get the flexibility of LVM for this filesystem and not just for the data. The down side is that the boot procedure is a bit more complex, and you need to understand how its boots so that you are able to fix it in case of problems.
Booting using a root filesystem located on an LVM Logical Volume is more
complicated because the kernel does not know anything about LVM. So it needs the
LVM binary to mount the root filesystem. But the LVM binary is installed on the
root filesystem that we want to mount… The solution to this egg and chicken
problem is to boot with an initramfs. This is a compressed archive that contains
all the kernel modules and programs that are required to mount the root
filesystem at boot time. In general, it’s located in /boot
, and it is
called initramfs-x.y.z.gz
. The other important file is the linux kernel
image which is called vmlinuz-x.y.z
.
root=/dev/volgroup/lvroot
.vgchange --available y
or vgchange -ay
./proc/cmdline
to see what
is the name of the root filesystem specified on the boot command line./rootfs
and other things such as /rootfs/proc
and /rootfs/dev
may also be
mounted./rootfs
. This means that this
directory becomes the new root for the processes which will be executed. When
a process reads /bin/something
it will read /rootfs/bin/something
in reality.There are good reasons for using LVM for the root filesystem:
You may not want your root filesystem to be on an LVM Logical Volume if you don’t want to boot with a ramdisk. If you compile your own kernel with all the important disk and filesystem drivers built in the linux image, it will be possible to boot with no initramfs as long as linux is installed on a standard disk partition that the kernel will be able to mount.
An initramfs contains the files necessary to obtain access to the root filesystem at boot time. It is possible to read its contents if you want to have a look at its contents. There are two sorts of such files: the old ones are called initramdisk and the new ones are called initramfs.
Most linux distributions provide initramfs along with kernel images. They are compressed cpio archives. Here is how to extract it
mkdir /var/tmp/ramdiskfiles
cd /var/tmp/ramdiskfiles && zcat /boot/initrd-x.y.z.gz | cpio -id
The following command will create a new initramfs using files located in /var/tmp/ramdiskfiles-new
:
find /var/tmp/ramdiskfiles-new | cpio -H newc -o | gzip -9 > boot/initrd-x.y.z-new.gz