# Mounting LVM on boot?!

## Guest

I am currently "converting" my partition to LVM. Backuped all files to another parition, created the volume group and logical volume and copied all files back. The big question now is though ... how do I mount the LVM on system boot? 

The old config looked like this

/dev/hda1   ext3    /boot

/dev/hda2   swap   none

/dev/hda3   ext3    /

hda is now a LVM drive (reiserfs) with all the root files on it... The volume group is called vg01, the logical volume lv01 so I can mount the hd with /dev/vg01/lv01 in the rescue system. 

LVM support is compiled into the kernel but what options do I have to set in grub/menu.lst for example? I tried kernel /boot/bzImage root=/dev/vg01/lv01 but that gives a kernel panic, "can not mount root file system".

I am not a guest btw ... I have an account but I am using another computer at the moment...  :Sad: 

----------

## Guest

Uhm, it should be:

hda3 is now LVM drive ...

sorry for the typo

----------

## Nitro

I just rebuilt my box and am running LVM + XFS + Reiserfs, and all seems fine.  On my box I created a root partition of using XFS and it occupies about 200 MB. My partition table:

```
   Device Boot    Start       End    Blocks   Id  System

/dev/hda1             1         6     48163+  83  Linux

/dev/hda2             7        32    208845   83  Linux

/dev/hda3            33      1435  11269597+  8e  Linux LVM

/dev/hda4   *      1436      2482   8410027+   7  HPFS/NTFS
```

You have to initalize your LVM VG's (virtual groups) in order to use them, mine are enabled using the boot scripts.  So, this leads us to our solution (one I haven't tried, yet): create an initrd.  I'm not 100% sure about how you'd do this, but takea  peak at the man page for 

'lvmcreate_initrd'.  After you make a ramdisk you need to tell your kernel to load the ramdisk, which you should probably put on a /boot partition or something.  Again, I'm not sure how to use the initrd yet, I wanted to mess with LVM a little before plunging face first in to it.

I would be very interested in hearing if/how you get this to work.

----------

## Guest

I actually was able to get LVM as my root directory with little effort.

In my case what i did I created a small 20MB partition as the boot partition.  Here's an example of my current partition table with LVM.

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/serverdrive/lvol1 

                       7639928   1901224   5350608  27% /

/dev/hda1                23302      3516     18583  16% /boot

I ran this command after i got the boot partition set up with all the kernel files and grub

lvmcreate_initrd 2.4.19-gentoo 

(2.4.19-gentoo is the name of the kernel I'm using yours might be different)

it will place the file initrd-lvm-2.4.19-gentoo.gz in your /boot directory

in my menu.lst file this is what i put down:

default 0

timeout 1

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title=Gentoo Linux on Marius

root (hd0,0)

kernel /boot/bzImage apm=on apm=power-off

initrd /boot/initrd-lvm-2.4.19-gentoo.gz

the lines in bold minus the apm stuff is what you need to put into grub to get it to work without any problems

don't worry about specifing root=/dev/whatever the ramdisk loads the LVM volume for you.

I hope I made some kind of sense   :Smile: 

Mario

tekwolfnyc@latinwolf.com

----------

## Guest

So far so good... initrd created, grub modified.

I can not read if the initrd is successfully loaded, the messages are scrolling to fast and I can't pause them with the pause key  :Sad:  I also cannot scroll up...

Now when the kernel tries to mount the root partition it says it cannot find a reiserfs partition?!  :Crying or Very sad: 

My root LVM parition is /dev/vg/root with reiserfs.

How does the initrd "know" what my root partition is if I don't define it in grub or somewhere?

----------

## Guest

I think I know what the problem is. The kernel does not decompress the initrd image  :Sad:  It says "RAMDISK: compressed image found at 0" but the next line is "freeing initrd..."

Huhm?!

----------

## mossmann

Is your kernel compiled with:

CONFIG_BLK_DEV_RAM=y

CONFIG_BLK_DEV_INITRD=y

?

----------

## Guest

Yes, it is.

----------

## tekwolfnyc

Did you build reiserfs support into the kernel instead of a module

I know I know but it doesn't hurt to ask  :Smile: 

Mario

----------

## Guest

Yep, reiserfs is also compiled into the kernel. And before you ask, LVM is also compiled into the kernel  :Wink: 

----------

## tekwolfnyc

Is the kernel booting up at all would be the next question

if so is this line in your /etc/fstab

tmpfs                   /dev/shm        tmpfs           defaults               $

CONFIG_DEVFS_FS=y

CONFIG_DEVFS_MOUNT=y

make sure these are enabled too gentoo wigged out on my about those two options. 

Since I set up my LVM with ext3 i guess my case might be different but it shouldn't be.  In anycase maybe the above might help.

Mario

----------

## sven

This was me all the time. I gave up on LVM. I am using normal reiserfs again.

The kernel did not decompress the initrd image though it did found an image in the ram. ram disk and initrd support was compiled into the kernel.

----------

## arkane

 *sven wrote:*   

> This was me all the time. I gave up on LVM. I am using normal reiserfs again.
> 
> The kernel did not decompress the initrd image though it did found an image in the ram. ram disk and initrd support was compiled into the kernel.

 

Well if you ever try again, there is a howto on LVM now....

--

Dan

----------

