# How to setup LVM (Logical Volume Manager) including root und

## arkane

How to setup LVM (Logical Volume Manager) including root under Gentoo

ChangeLog: 05/20/2002 - Added in need to compile devfs mounted at boot for the kernel and the fact that you can use resize2fs to resize ext3 partitions.

Preface

This document describes how I setup LVM on Gentoo, along with any tiny items you should know along the way.

I used Gentoo 1.1a for this example. This is meant to compliment the Gentoo installation instructions.

This is best done during system installation, as then you don't have to swap around contents of a drive.

However, feel free to explore on your own and try new things!

1. Before going too far, you need to first plot out how your going to setup your partitions. (any partitions

you setup in LVM can be resized)  Mine are as follows:

```

Filesystem      Type      Size  Used Avail Use% Mounted on

/dev/hda6       ext3       23M  4.2M   17M  20% /boot

/dev/nostripevg/rootlv ext3      147M  112M   28M  80% /

/dev/nostripevg/usrlv ext3      1.7G  978M  677M  60% /usr

/dev/nostripevg/varlv   reiserfs  252M   40M  212M  16% /var

/dev/nostripevg/homelv  reiserfs 1000M   40M  960M   4% /home

/dev/nostripevg/x11lv   ext3      170M  112M   50M  69% /usr/X11R6

tmpfs          tmpfs     1.0M  112K  912K  11% /mnt/.init.d

```

Keep your partitioning as a reference during the installation.

2. Go through the instructions until section 6 (Set Up Partitions).  This section needs a little clarifying.

You need 2 partitions (aside from the one(s) for LVM), one for your /boot partition and one for swap.

So, for this example, we're going to create the following partitions: swap, LVM, boot.

Inside fdisk:

Create the partition for /boot to be between 20-50MB as you would any other partition.

(It only holds your initrd, kernel, and grub items)

Change the "type" to 83 (Linux) with the "t" command.

Create your LVM partition partition to be the size of your full system. (Mine is 5.6 Gigabytes)

Change the "type" to 8e (Linux LVM) with the "t" command

Create your swap partition.  (Size is at your discretion.  Standards are >=2*RAM, but I use 136mb)

Change the "type" to 82 (Linux swap) with the "t" command

After You've done that, if you type "p" in fdisk it should resemble my setup (seen below):

```

Disk /dev/hda: 255 heads, 63 sectors, 1247 cylinders

Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System

/dev/hda6  *        523       525     24066   83  Linux

/dev/hda7           526      1230   5662881   8e  Linux LVM

/dev/hda8          1231      1247    136521   82  Linux swap

```

After your sure everything is fine, use the "w" command to write the changes to disk.

3. Time to setup LVM!

 Type: vgscan

 Create your physical volume for the LVM partition we made. Type: pvcreate /dev/hd?? (change ?? to your partition)

 Create your volume group for LVM. The volume group is whats used to allocate your logical volumes in LVM.

    If your not using devfs

    Type: 

```
vgcreate my_volume_group /dev/hda1
```

    (replace hda1 with the partition made for LVM, and my_volume_group with a name for your Logical Volume)

    If you ARE using devfs

    Type: 

```
vgcreate my_volume_group /dev/ide/host0/bus0/target0/lun0/part1
```

    (you have to use the full devfs name for the drive/partition.  Above is equal to /dev/hda1)

 Create your logical volumes. (basically, "partitions" as you originally thought of them, only created in LVM)

    Type: lvcreate -LsizeMB -ntestlv testvg

    Replace sizeMB with how many megabytes you want the partition to be, testlv with the name of your partition,

    and testvg with the name of the volume group you gave in the last step.

    You can name your logical volumes anything easy to remember, as I use rootlv, usrlv, homelv, etc...

    You need to do this for all of the partitions you planned out in the beginning.

 After that, time to create filesystems on the partitions we've created.

     Please note that out of all the filesystems, XFS is *NOT* able to shrink at all.  It can only grow.  Also note that as of this date, resize_reiserfs is not included in the boot cd so be careful when you allocate space for reiserfs.  You can resize ext3 partitions with the tool resize2fs.

 Do the /boot partition.  You have a choice of filesystems, so use the one your most comfortable with.

    Follow section 6 of the installation instructions for examples.

 Do the swap. (mkswap /dev/hda8 for example)

 Now, on to the LVM partitions. Instead of being /dev/hda1, /dev/hda2, and so on, LVM has a different setup

    LVM names it's partitions in the following way: /dev/volumegroup/logicalvolume (e.g. /dev/test_vg/rootlv)

    So, suppose my volume group was "testvg" and I created a logical volume inside of it called "linuxlv".

    It would be called, "/dev/testvg/linuxlv".  You can format it as you do any other device.

```
e.g. mke2fs /dev/testvg/linuxlv
```

4. Mounting LVM Partitions

   It's quite simple, and the same as you would any other drive.

   To mount our linuxlv partition to the root, we do the following:

```
mount /dev/testvg/linuxlv /
```

   Make sure when you follow section 7 of the install instructions to mount ALL of your LVM partitions.

   Also, be sure to include the partition we created for /boot

5. Onto step 14, you will notice that the Gentoo linux-sources has changed a bit from the instructions.

   I personally used sys-kernel/gentoo-sources because I am not using XFS but it does include LVM.

   You can grab any of them except for the vanilla-sources.  Be sure to include built-in support for LVM

   when compiling the kernel.

   Options needed when running make menuconfig:

LVM support

built-in ramdisk support with initrd

DEVfs support

mount dev filesystem at boot

loopback support

   I have noticed issues with grsecurity in the kernel and LVM, but that's my own personal experience.

   When you are finished compiling your kernel, modules, and installing both, perform the command:

```
 lvmcreate_initrd 2.4.19-gentoo-r1
```

 replacing 2.4.19-gentoo-r1 with the version of kernel you installed.

   You will notice module errors, this is normal. (your not running the kernel yet!)

   Notice the size of the loopback file.  It will say: 

```
lvmcreate_initrd -- making loopback file (3238 kB)
```

   except your size will be different.  Please make sure that the size of your ramdisk is larger than this.

6. Onto step 16, perform the steps as the instructions tell you, but be sure to use the full LVM name of the partition.

   (e.g. /dev/testvg/linuxlv as our previous example could be mounted to / )

   Also be sure to include /boot.  This is necessary for your system to operate.

7. When you are creating your /boot/grub/menu.lst, include a line under your "kernel" line saying the following:

```
initrd=/boot/2.4.19-gentoo-r1.gz
```

   Be sure to change the name of the initrd file listed above if that is not the name.  Never hurts to verify!

Follow the installation instructions, and after you reboot you should be able to have everything working if you followed

the instructions.

If you want a more thorough (and non-gentoo specific) howto, please see the great Howto created by the makers of LVM at

Sistina.com Howto at http://www.sistina.com/lvm_howtos/lvm_howto

I am a relatively new user of LVM, but I wanted everyone to at least have something Gentoo specific to read before diving

in like I did.  I hope this helps out!  I'd also like to update this occasionally, so if anyone finds any errors please let

me know on the Gentoo message board (my username is "arkane" or my email address at dan_lund@hotmail.com)

Last edited by arkane on Mon Jan 20, 2003 7:55 pm; edited 1 time in total

----------

## Praxxus

I may very well be overlooking something, but I haven't seen this specifically mentioned yet.

In addition to the built-in support (devfs/mounted at boot, LVM, initrd) you've mentioned, it seems I had to buid loopback device support (block devices) directly into the kernel before I could get LVM working.

----------

## uxbod

Coming from a HP-UX SA background and do not see the point of running LVM at home. I have just build some new servers @ work using RedHat AS and the only partitions that are LVM are /oracle & /data.  All system partitions are ext3. My rationale behind this is that they will be (i hope) the only two partions that shall ever need expanding. LVM is great for that.

----------

## kerframil

Thanks, I hadn't worked out how to get a root partition onto LVM so that's quite useful (although I don't envisage a root partition needing snapshots or resizing).

 *Quote:*   

> Coming from a HP-UX SA background and do not see the point of running LVM at home

 

It's down to choice I suppose. It may not be for Joe Bloggs, but I don't think it's inconceivable that some users would appreciate the features on offer. You may want to run it at home because you want to keep abreast of the technology (that defintely applies to me). The ability to aggregate storage containers (say, upon buying a new hard disk) may be another.

As for a server setup, I generally agree. But I think /home is definitely a candidate, and maybe /var. You can imagine people underestimating future capacity requirements for users. And snapshots provide a proper mechanism for dealing with consistent, point-in-time backups, which apply to other things than just Oracle.

----------

## arkane

 *Praxxus wrote:*   

> I may very well be overlooking something, but I haven't seen this specifically mentioned yet.
> 
> In addition to the built-in support (devfs/mounted at boot, LVM, initrd) you've mentioned, it seems I had to buid loopback device support (block devices) directly into the kernel before I could get LVM working.

 

Thanks for bringing that up, Praxxus.  I just added that into the listing.

I've been neglecting the forums for quite a while now because of school, family, and so forth.  I apologize.

----------

## arkane

 *uxbod wrote:*   

> Coming from a HP-UX SA background and do not see the point of running LVM at home. I have just build some new servers @ work using RedHat AS and the only partitions that are LVM are /oracle & /data.  All system partitions are ext3. My rationale behind this is that they will be (i hope) the only two partions that shall ever need expanding. LVM is great for that.

 

I use it primarily to be able to shrink and grow my partitions as needed.  It gives me the best of both worlds.. having partitions to isolate storage from one another (to keep things from keeping other things from operating due to going haywire with disk usage), and sharing space throughout the entire system.  I've had to grow my /var and /usr/portage directory a couple times for certain things, then I just shrink them back up after I'm done with that.

----------

## jeremy_

well, after spending about 4 hours trying to get a laptop to boot with a fresh instal of gentoo 1.4 and to use lvm, I figured I'd post the fix here.   Hope it's the right place.

I tried pretty much everything, and yet I could never get grub to see my lvm partitions. 

I read a post elsewhere that evms will automatically setup your lvm partitions for you and make them active upon boot.  I compiled evms statically into my kernel (NOT as a module) and booted, and voila, all of my lvm partitions were located at /dev/evms/lvm/volume_group/logical_vol

All that was left was to tell grub that my root was located at  root=/dev/evms/lvm/Volume00/rootfs  and to adjust my fstab to also point to the evms locations. 

Boom!  four hours of work....   5 lines of text editted, and I'm gentoo-lvm-luvin!

----------

## asimon

To make LVM (without EVMS) work with root on a LVM volume you just have to use a adequate initrd (which can be made with lvmcreate_initrd). I think this is mentioned in this thread and described in the LVM howto. initrd is a ram disk which gets mounted as root after the kernel is loaded. Then things like lvm detection/activation can be done and afterwards the kernel mounts the actual rootfs.

EVMS is more comfortable in this regard because with EVMS the kernel itself (which means the EVMS stuff which gets compiled into the kernel) detects and activates LVM volumes at boot time. Then there is no need to have an initrd.

But note that EVMS 2, which was released a couple of days ago, has no longer boot-time volume activation. You have to use the initrd mechanism with EVMS2 too. This is because of architectural changes in the Linux kernel. With the upcoming kernel all detections and activations like LVM, EVMS, etc. will be done in user space, which means that these things are no longer done by the kernel. A initrd-like mechanism is then madatory (AFAIK initrd will be replaced in Linux 2.6 too, but I have no further information on that.)

----------

## jeremy_

I had tried initrd, but to no avail.

Hmmm... guess I'll start figuring it again once I have to upgrade my kernel past 2.4.  :Sad: 

----------

## Simba

I have root fs in lvm, and in the grub.conf I use kernel option root=/dev/localvg/rootlv . I have also initrd in /boot partition. but if I reboot

the pc, linux kernel don't try to find the rootlv at all, but it tried to boot it from

rootnfs, here is the warning:

Root-NFS: No NFS server available, giving up

VFS: Unable to mount root fs via NFS

...

how can I tell the kernel not to use rootnfs, but try to mount the root from 

LVM? but If I use kernel option root=3a01 , where 3a01 is the major/minor number of rootlv device, it works perfectly, but I don't want to boot it in this way.

thanks,

cahya

----------

## asimon

 *Simba wrote:*   

> I have root fs in lvm, and in the grub.conf I use kernel option root=/dev/localvg/rootlv . I have also initrd in /boot partition. but if I reboot
> 
> the pc, linux kernel don't try to find the rootlv at all, but it tried to boot it from
> 
> rootnfs, here is the warning:
> ...

 

I have the following in my grub.conf:

```

title=Gentoo Linux 2.4.20-rck4

        root (hd1,0)

        kernel /bzImage-2.4.20-rck4 root=/dev/main_vg/root_lv hdb=ide-scsi

        initrd /initrd-lvm-2.4.20-rck4.gz

```

whereas initrd-lvm-2.4.20-rck4.gz was created with lvmcreate_initrd. I never had problems with that.

Do you have by any change configured your kernel to have it's "Root file system on NFS" (in Network file systems)? Otherwise it could be some strange devfs problem. But if it's not that kernel options than I dunno what causes your problem.

----------

## atac

this was just what i was looking for, gonna try it out  :Smile: 

----------

## Simba

After I removed the "Root file system on NFS" from the kernel, the boot 

process in my laptop works perfectly. With this experience I want also to setup our compaq server (with hardisk raid)  to have root fs on lvm. I do the same in the kernel: 

# LVM support

# built-in ramdisk support with initrd

# DEVfs support

# mount dev filesystem at boot

# loopback support 

and here is my grub.conf:

```

title=Linux 2.4.20-XFS

root (hd0,0)

kernel /boot/bzImage-2.4.20-xfs-r2 root=/dev/cciss/c0d0p2

 

title=Linux 2.4.20-XFS LVM Root

root (hd0,0)

kernel /boot/bzImage-2.4.20-xfs-r2 root=/dev/localvg/rootlv

initrd /boot/initrd-lvm-2.4.20-xfs-r2.gz

```

the first grub menu is working fine, 

but if I use the second menu with initrd I get this kernel panic at the end:

```

RAMDISK: Compressed image found at block 0

Freeing initrd memory: 4096k freed

XFS: bad magic number

XFS: SB validate failed

Kernel panic: VFS: Unable to mount root fs on 00:00

```

and I try to replace /dev/localvg/rootlv with /dev/cciss/c0d0p2 like the first

grub menu and with

the same initrd, I though it will work because the first grub menu works fine, but it still doesn't work, I got the same Kernel panic: VFS: Unable to mount root fs on 68:01. 

and then I try to change linuxrc in the initrd-lvm, I insert there a line /bin/bash , so I can check something before the initrd is freed again from memory during booting, but I never get in to it, it seems that my initrd is not used at all. can someone help me or give me a hint what I still did wrong here?

thanks again in advance.

cahya.

----------

## Crimson Rider

I can complete allmost all the steps, up to and including booting with GRUB, however, at the end of the line, vgscan and vgchange come up with zilch. nothing nada. It' doesn't find my /dev/lv/ide volume group, could that have something to do with the fact that it is on a promise onboard non-raid ide controller ?

----------

## alexbuell

Can I use both LVM and RAID? Is it even safe?

----------

## Xenophon

I have successfully created the partitions suggested above (root, boot, swap, and lvm) and have created four logical volumes (tmp, usr, var, home).  I have mounted everything accordingly:

```
cdimage root # mount

proc on /proc type proc (rw)

 . . . .

/dev/hda3 on /mnt/gentoo type reiserfs (rw)

/dev/hda1 on /mnt/gentoo/boot type ext2 (rw)

/dev/master/usr on /mnt/gentoo/usr type reiserfs (rw)

/dev/master/home on /mnt/gentoo/home type reiserfs (rw)

/dev/master/tmp on /mnt/gentoo/tmp type reiserfs (rw)

/dev/master/var on /mnt/gentoo/var type reiserfs (rw)

proc on /mnt/gentoo/proc type proc (rw)

```

I then unpacked a stage 1 tarball, edited make.conf to allow portage sandboxing, and ran scripts/bootstrap.sh.

It died:

```
Configuring environment...

Calculating dependencies ...done!

>>> emerge (1 of 1) sys-apps/portage-2.0.48-r5 to /

>>> md5 ;-) portage-2.0.48-r5.tar.bz2

>>> /tmp/sandboxpids.tmp file mode: r+ open: Permission denied

>>> pids file write: Illegal seek

```

How do I need to mount /tmp to allow writes by users?

----------

## eivinn

 *Xenophon wrote:*   

> How do I need to mount /tmp to allow writes by users?

 

I have done it like this:

```
/dev/main/lv_tmp on /tmp type reiserfs (rw,nosuid,nodev,noatime)
```

Make sure you add exec to lvm_volumes other than standard /usr /opt etc if you'd like execution rights. Unreal installer use /tmp as temp dir and execs from there.

----------

## JollyToad

Hello to all you brave LVM users.

   I've just spent several hours of head scratching and chin stroking trying to install

our new server with root on LVM, here's a little story for you:

I decided to use reiserfs for all filesystems, so when it came to kernel compilation

(using gs-sources) I selected ONLY reiserfs (who needs ext2 - I thought).

Anyway, after much tweaking, many reboots, lots of kernel panics, and close

scruntity of lvmcreate_initrd - i discovered it uses ext2 on the initrd!  :Embarassed: 

One kernel recompile and reboot later - and hey presto - a working root on LVM.

The moral of this story is:

Don't forget to compile 'EXT2' filesystem support into the kernel

----------

## eivinn

 *JollyToad wrote:*   

> Hello to all you brave LVM users.
> 
>    I've just spent several hours of head scratching and chin stroking trying to install
> 
> our new server with root on LVM, here's a little story for you:
> ...

 

Why would you do that? You know LVM is out of kernel 2.6 don't you?

In my opinion go with EVMS2, at least LVM2 if you want LVM.

----------

## Birdman

 *Xenophon wrote:*   

> 
> 
> How do I need to mount /tmp to allow writes by users?

 

Do a 

```
chmod 1777 /tmp
```

To ensure that anubody can write to /tmp. You should only need to do this once.

----------

## Neo_0815

hello.

I decided to use lvm and i've done all things described as in here, but got following error:

vgcreate main /dev/ide/host2/bus0/target0/lun0/part4

vgcreate -- no valid physical volumes in command line

lvm-mod is aktivated in my 2.4.22-r7 gentoo-sources kernel, devfs is also up and running.

my partition scheme looks like this:

Name Flags Part. Typ Dateisystemtyp [Bezeichner] Size

------------------------------------------------------------------------------

hde1 Primäre Linux ext3 49,36

hde2 Primäre Linux ext3 246,76

hde3 Primäre Linux swap 1998,75

hde4 Primäre Linux LVM 117761,34

/boot, /, swap and lvm volume in the above order.

I executed vgscan before and got this:

vgscan -- reading all physical volumes (this may take a while...)

vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created

vgscan -- WARNING: This program does not do a VGDA backup of your volume group

Whats the problem, what i am doing wrong.

thx and best regards

Neo

----------

## deepthink

I intalled LVM on my new laptop. This is my current setup:

```
Filesystem            Size  Used Avail Use% Mounted on

/dev/hda5             142M   91M   51M  65% /

/dev/vg/home          5.0G  4.1G  941M  82% /home

/dev/vg/opt           2.0G  505M  1.6G  25% /opt

/dev/vg/var           5.0G  1.3G  3.8G  26% /var

/dev/vg/tmp           2.0G   39M  2.0G   2% /tmp

/dev/vg/usr            10G  7.1G  3.0G  71% /usr

/dev/hda1             9.8G  4.8G  5.0G  50% /mnt/win

none                  252M     0  252M   0% /dev/shm
```

```
     Name            Flags         Part Type     FS Type               [Label]             Size (MB)

 -------------------------------------------------------------------------------------------------------

     hda1            Boot           Primary      W95 FAT32 (LBA)                            10487.24     

     hda2                           Primary      Linux ext2                                    49.36

     hda5                           Logical      Linux ReiserFS                               148.06

     hda6                           Logical      Linux LVM                                  49327.01

```

I created a 512MB swap-partition as a logical volume but that didn't seem to work. Can I somehow make it work? Can I resize the physical LWM partition (/dev/hda6)?

Perhaps I should just shink down windows even more since I never use it.

----------

## Neo_0815

I've took lvm2 and get following more detailed error:

vgcreate main /dev/ide/host2/bus0/target0/lun0/part4 

No physical volume label read from /dev/ide/host2/bus0/target0/lun0/part4

  /dev/ide/host2/bus0/target0/lun0/part4 not identified as an existing physical volume

  Unable to add physical volume '/dev/ide/host2/bus0/target0/lun0/part4' to volume group 'main'.

What i am doing wrong?

best regards

----------

## One

this is quite easy I think. 

before you can use a partition with lvm you have to initialize this partition as a physical lvm partition ... 

this is done by executing pvcreate (partition-name)

I hope this solves your problem  :Smile: 

----------

## Neo_0815

thx very much.

now it works.

best regards

----------

## Moriah

I am installing gentoo to replace redhat, since rh is dropping support for non-"enterprise" versions at the end of April.

I use an automatic backup server to run nightly backups, so I wanted to use lvm to use the snapshot feature to improve the integrity of my backups.  I also wanted to use the 2.6 series kernel and reiser4, but that uses lvm-2, and lvm-2 does not yet support snapshots under gentoo, so I had to fall back and go with the 2.4 kernel and lvm-1 to get my snapshots.  That also means reiserfs version 3 instead of 4.   :Sad: 

Since I use an rsync based backup system, I backup *EVERYTHING* every night -- at least I check everything, including the root filesystem, so I wanted to be able to snapshot the root filesystem also.  This means booting with a root filesystem under lvm.

I used lvmcreate_initrd to make an initial ramdisk image.  I set up the grub.conf and booted.  What I got was exciting -- for a few seconds -- then the kernel paniced.    :Mad: 

```

Freeing initrd memory: 1063k freed

VFS: mounted root (ext2 filesystem) readonly.

Mounted devfs on /dev

Freeing unused kernel memory: 156k freed

can't create lock file /etc/mtab~10: Read-only filesystem (use -n flag to override)

vgscan -- ERROR "creating lvmtab" creating lvmtab

vgscan -- no voolume groups found

vgchange -- ERROR: "/etc/lvmtab" doesn't exist; please run vgscan

warning: can't open /etc/mtab: No such file or directory

umount: /proc: not mounted

kernel panic: Attempted to kill init!

```

I am presently running the gentoo-2.4.25 kernel from gentoo-sources built with genkernel.  Does the genkernel generated kernel have lvm compiled in as part of the resident kernel, or does it use modules to install lvm?  

In other words, do I need to compile a machine specific kernel to get this to work?  If so, that is a pain, as I was planning to get everything working on one box, and then clone it to the other machines.  My machines are heterogenous -- which means they are all different.  If I have to compile a kernel for each machine, I guess I have to, but how can I compile a genkernel-like kernel, only with the necesary prerequisite support as non-modules, so I can clone to different boxes, and so if I change a hardware component in the future, I do not render the machine unusable.

----------

## Moriah

Well, I bit the bullet and compiled a custom kernel, and IT WORKED !!!

I am now running with a small /boot partition that boots into a root-filesystem under lvm, and my swap is also on lvm, and everything is working great.  

Next step is to get it running under reiserfs instead of ext3 for the root filesystem.

----------

## eNTi

is this possible with udev too?

----------

## arkane

 *eNTi wrote:*   

> is this possible with udev too?

 

Haven't the foggiest, never used udev.

----------

## arkane

 *Moriah wrote:*   

> I am installing gentoo to replace redhat, since rh is dropping support for non-"enterprise" versions at the end of April.
> 
> 

 

I'm in the works of setting up a full architecture at work with Gentoo, doing the same thing.  Except it's replacing RH8.

 *Quote:*   

> 
> 
> I use an automatic backup server to run nightly backups, so I wanted to use lvm to use the snapshot feature to improve the integrity of my backups.  I also wanted to use the 2.6 series kernel and reiser4, but that uses lvm-2, and lvm-2 does not yet support snapshots under gentoo, so I had to fall back and go with the 2.4 kernel and lvm-1 to get my snapshots.  That also means reiserfs version 3 instead of 4.  
> 
> 

 

We use Network Appliance to do our critical data.  It does iSCSI and NFS over TCP which is really nice.  I use LVM1 on a couple of servers at work, but only because they have more than one disk and I wanted to make them into a single disk... and I didn't want to go with software RAID0.  I've had 3 occasions of bad experience with reiserfs just corrupting for no apparent reason, along with 2 other occasions at work where it just corrupted for no apparent reason.  I've quickly gotten rid of reiserfs from the server room.  I'll probably experiment with XFS later, but EXT3 has been rock solid.

 *Quote:*   

> 
> 
> I used lvmcreate_initrd to make an initial ramdisk image.  I set up the grub.conf and booted.  What I got was exciting -- for a few seconds -- then the kernel paniced.   
> 
> 

 

>snipped off code<

You know, I had the same issue way back when.

Check out this bug: https://bugs.gentoo.org/show_bug.cgi?id=7592

It might help you out.

 *Quote:*   

> 
> 
> I am presently running the gentoo-2.4.25 kernel from gentoo-sources built with genkernel.  Does the genkernel generated kernel have lvm compiled in as part of the resident kernel, or does it use modules to install lvm?  
> 
> 

 

If you do it with genkernel, you should have first done the --menuconfig flag to set your options.  not sure if it does by default or not, however.  Myself, I'd compile it into the kernel, and not as a module.  It just makes it more work if you do it with a module, and it'll be loaded at all times, anyhow.

 *Quote:*   

> 
> 
> In other words, do I need to compile a machine specific kernel to get this to work?  If so, that is a pain, as I was planning to get everything working on one box, and then clone it to the other machines.  My machines are heterogenous -- which means they are all different.  If I have to compile a kernel for each machine, I guess I have to, but how can I compile a genkernel-like kernel, only with the necesary prerequisite support as non-modules, so I can clone to different boxes, and so if I change a hardware component in the future, I do not render the machine unusable.

 

It's not going to be machine-specific.  If you do i686 (pentium 3 is what I use for the processor selection) for the kernel, you can do everything x86 compat pretty much.  Well, except 586 chips  :Smile: 

I've used the same kernel for going on 6 machines at work so far, with a boilerplate bz2 file containing everything.  Only change 2 files, and those are /etc/hosts and /etc/hostname.  I woudn't wish the compilation of a new kernel for every machine on my worst enemy.  You don't have to do non-modules for everything, either.  You can, however, make a "stage4" that contains the kernel, filesystem, modules, and everything.  I did that, and it only takes up 200mb bz2 compressed.  (1.2G uncompressed)  I have a central filesystem that is an rsync server, and it NFS shares pre-compiled packages.  The machine doing the compiling is a dual-700, while every other machine is in the gigahertz range, and at least 1 or 2 are athlon.  Thinkpad too, now that I think about it... I did my thinkpad today with Gentoo.  Only took 1 1/2 hours.  Pretty sweet.

----------

## Moriah

As I said earlier on another thread somewhere, I compiled a custom kernel and now have LVM on my root filesystem at boot, and swap under lvm as well.  I have read too many "bad rumors" about reiserfs for me to use it in a critical application, but I did put it on a couple of workstations that are on a nightly backup schedule.  We shall see how it fares...

Originally, my primary interest in reiserfs was for my backup server, since it deals with so many small files, but I will keep it under ext3 for now.  If reiser4 proves reliable under the 2.6 kernel along with lvm-2 -- when snapshots work with lvm-2 under gentoo -- then I will switch the backup server over to that configuration.  For now, I am running the 2.4.25 kernel with lvm-1 and reiser3 on the workstations, and ext3 in critical server applications.

----------

## ColeSlaw

 *uxbod wrote:*   

> Coming from a HP-UX SA background and do not see the point of running LVM at home. I have just build some new servers @ work using RedHat AS and the only partitions that are LVM are /oracle & /data.  All system partitions are ext3. My rationale behind this is that they will be (i hope) the only two partions that shall ever need expanding. LVM is great for that.

 

I've got a Myth TV Box at home and LVM is great to record your shows on so that if you need more recording space you can add it easily.  I definately recommend making your Myth TV drive LVM.  (You never know how many MP3s or Videos you will eventually end up with.)

----------

## blake121666

 *eNTi wrote:*   

> is this possible with udev too?

 

Yes.  You need to do a

```
/sbin/vgscan --mknodes --ignorelockingfailure
```

somewhere before /etc/init.d/checkroot gets run.  I put this line in /sbin/rc but I guess you could put it at the top of checkroot or probably best of all is to make an lvm bootscript to go before checkroot.

----------

## gcasillo

Okay tried adding that line to /sbin/rc, but it didn't do anything. So it appears that LVM and udev do not work together at the moment. So, if you're like me, and you've been on a f'ing weekend long sojourn to build a box with Gentoo, you have been warned.

This bug report is a month old and recommends a very similar solution:

https://bugs.gentoo.org/show_bug.cgi?id=51805

----------

## gcasillo

Nevermind. I put the wrong stuff in /etc/fstab. I put /dev/hde6 in instead of /dev/vg/var, for example. LVM2 and udev will work. Excuse me while scoop up some crow.

----------

## blake121666

Actually, I describe almost everything I did as an add-on to the person's howto of RAID-on-root at

https://forums.gentoo.org/viewtopic.php?t=8813&postdays=0&postorder=asc&start=117

I mirrored root w/LVM2 on top of the software RAID.  I'm surprised it has been working so well for me.  I've tested various troubleshooting scenarios that might crop up for me (like a mirror fails, lvm vg gets corrupted, ...etc) and it all appears pretty solid.

Linux has come a long way since I last fiddled with it in '95.  I've setup most of my boxes with it now and am loving life!  No more BSD, AIX, ...etc for me anymore.  And coLinux on my XP machines is pretty cool too.  Definitely ready-for-primetime stuff here.

----------

## tecknojunky

I'm suprised and disappointed that LVM and UDEV do not play well together in Gentoo.  Both have been around for awhile.

In Gentoo's udev guide, they mention *Quote:*   

> LVM2 Names Disappear 
> 
> When you use udev and LVM2 together, you might notice that your created volume groups and logical volumes have disappeared. Well, they haven't, but they are unfortunately named /dev/dm-# with # being 0, 1, ...
> 
> To fix this, edit /etc/udev/rules.d/50-udev.rules and uncomment the following line:
> ...

 On my system, there are no such dm-# files in /dev.  So this is completely useless for me.

Thanks to Google, I found on a mailing list that I only have to issue this command...

```
vgchange -ay
```

... to see all my virtual volumes back again.

Now I need to put this somewhere useful in Gentoo.  If I think hard enough and do a good job, maybe it could be used by the Gentoo bonzs?

I have a better idea  :Idea:  Why don't you tell me where to put the command?  :Wink: 

NEW:

I take it all back.  Uncommenting the line from /etc/udev/rules.d/50-udev.rules do work and I appologies.

I just wish it would have been automatic when I upgraded to udev.  I suppose that if that line is uncommented when you don't use LVM it will do strange thing? (yes.  It is a question)

----------

## Xamindar

can someone be so kind as to tell me where the lvmcreate_initrd can be found?

On another note, I was trying to follow these tips here 

https://forums.gentoo.org/viewtopic.php?t=8813&postdays=0&postorder=asc&start=117

but I get an error when I run this part:

- Make sure the library files are included

Code:

ldd bin/* | awk '{if (/=>/) { print $3 }}' | sort -u \

          | awk 'system("cp "$1" lib")'

----------

## blake121666

 *Xamindar wrote:*   

> can someone be so kind as to tell me where the lvmcreate_initrd can be found?
> 
> On another note, I was trying to follow these tips here 
> 
> https://forums.gentoo.org/viewtopic.php?t=8813&postdays=0&postorder=asc&start=117
> ...

 

What error are you getting?  All the commands are doing is finding the lines from the "ldd" command that list the libraries used in the binary files, uniquely listing them and copying each to the "lib" directory.

----------

## ezaekiel

 *One wrote:*   

> this is quite easy I think. 
> 
> before you can use a partition with lvm you have to initialize this partition as a physical lvm partition ... 
> 
> this is done by executing pvcreate (partition-name)
> ...

 

thanks and I read it here : http://www.gentoo.org/doc/en/lvm2.xml but I don't view pvcreate  :Sad:  lol

----------

## Noe

Hello all,

I have gone all the steps in setting up LVM2 as mentioned in http://gentoo-wiki.com/HOWTO_Install_Gentoo_on_an_LVM2_root_partition#The_Second_Easiest_Way:

  - I have enabled LVM in the kernel together with device-mapper:

```
Device Drivers  --->

 Multi-device support (RAID and LVM)  --->

   [*] Multiple devices driver support (RAID and LVM)

   < >   RAID support

   <*>   Device mapper support
```

  - I have compiled Device-mapper statically in to the kernel:

```
USE="static" emerge device-mapper
```

  - I have enabled ramdisk and initial ramdisk support

  - I have modified the lvm.conf in following way to avoid scanning all devices:

```
filter = [ "a|^/dev/hda[12]|", "a|^/dev/vg01$|", "r/.*/" ]
```

  - I have edited lvm2create_initrd so as to set its size (to 8192kB) and I have created initrd with it:

```
sh ./lvm2create_initrd -c /etc/lvm/lvm.conf 2.6.11-gentoo-r3
```

  - my /etc/fstab:

```
/dev/hda1                  /boot       ext2            noauto,noatime         1 2

/dev/hda2                  none        swap            sw                     0 0

/dev/mapper/vg01-lvol1     /           xfs             noatime                0 1

/dev/mapper/vg01-lvol2     /home       xfs             noatime                0 0

none                       /proc       proc            defaults               0 0

none                       /dev/shm    tmpfs           nodev,nosuid,noexec    0 0
```

  - my /boot/grub/grub.conf: 

```
title Gentoo with LVM

    kernel /boot/kernel-lvm2-2.6.11-gentoo-r3 root=/dev/ram0 lvm2root=/dev/vg01/lvol1 init=/linuxrc ramdisk=8192 video=vesafb:ywrap,mtrr,1024x768-16@85 splash=silent,theme:emergence

    initrd /boot/initrd-lvm2-2.6.11-gentoo-r3.gz
```

Unfortunatelly when booting, the corresponding logical volumes are not found - the system prompts with lvm2rescue but there is no command to rescue lvm2.

Could you please help?

----------

## weedy

When i boot i get ramdisk: incomplete write )-28 ! = 31768) 8388608 and then some can't read fs stuff. used http://gentoo-wiki.com/HOWTO_Install_Gentoo_on_an_LVM2_root_partition , http://gentoo-wiki.com/HOWTO_Gentoo_Install_on_Software_RAID_mirror_and_LVM2_on_top_of_RAID and  https://forums.gentoo.org/viewtopic-t-71860-highlight-raid+mdadm.html

built the initrd with "The Second Easiest Way" (this script http://www.muncc.marmionacademy.org/~pmcdonnell/lvm2create_initrd ) with the command 

./lvm2create_initrd -v -c /etc/lvm/lvm.conf -r md2 -R /etc/mdadm.conf 2.6.16-gentoo 

fs compiled in, raid compiled in, lvm compiled in. I'm official out of ideas :/

----------

