[TriLUG] Problem with LVM

Brian McCullough bdmc at bdmcc-us.com
Sat Jun 3 22:36:13 EDT 2006


On Sat, Jun 03, 2006 at 09:47:10PM -0400, T. Bryan wrote:
> On Saturday 03 June 2006 09:14 pm, Brian McCullough wrote:
> 
> > Here, Rick is combining two different technologies, that may confuse
> > you.  
> 
> Yes and no.  I am also trying to use LVM on top of a RAID 1 device.  Of 
> course, since this is the first time I've created a software RAID under 
> Linux, and it's also the first time I've used LVM....yeah, a bit of 
> confusion.  :)
> 
> > The first, which is RAID ( type 1 -- Mirroring ) is what he used 
> > sdb5 for.  Then he used LVM on top of that RAID device to create, first,
> > a Physical Volume, and then a Volume Group ( VG ).  Yes it was
> > unformatted, or if it wasn't he is in trouble!
> 
> I think that he's fine.  I don't think that I was.  My notes say that the 
> first time I tried this, I did the following. 
> 
> Created /dev/hde1 and /dev/hdg1 as Linux partitions
> Formatted both partitions as ext3
> Created the RAID device /dev/md0 using /dev/hde1 and /dev/hdg1 
> Created a physical volume on /dev/md0
> Created a volume group on /dev/md0
> 
> Then the rest of the stuff that matched what Rick had done last time: 
> creating volume groups, formatting the logical devices, mounting the 
> logical devices.
> So....when I try this again, I'll set the partition type to LVM, and 
> I'll skip the part where I formatted the partition.  Perhaps that's 
> how I got myself into trouble.  :)

Tom,

In a sense, you did things a bit upside down.  You have to think of both
RAID and LVM as producing block devices, while your ultimate goal is a
filesystem, formatted in the format you like. ( ext2, ext3, etc. )

As you understand, you need to layer things to get the effect that you
want.  This is something that I tend to do for any client machine where
things are worth saving -- RAID saves you from some hardware errors --
it won't save you from typing "rm" but....  The RAID device is like one
or more actual disk drives.  Then LVM allows you to assemble one or more
"physical" disk devices into a seamless whole, which you then subdivide
as necessary for your own partitioning scheme.  You also understand that
this partitioning scheme is completely flexible, and that you can change
the size of any "partition" as you like, when you like.  Up to this
point, you are, in effect, dealing with the devices -- now you actually
allocate, format and mount the various parts of your filesystem.


Your procedure should be -- actually, you have two alternatives,
although I will only give you the preferred one.

Use fdisk to create partitions for your RAID device or devices.  Each of
those partitions will be coded as "fa" if I remember correctly -- it is
the "automatic RAID partition type" -- check fdisk.  Then use mdadm to
assemble each RAID device from the various partitions that comprise it.
Once you have those RAID devices, use pvcreate to mark them as being
initialized for LVM use.  This makes a mark in the first block of the
RAID device ( or partition ) which LVM uses to identify devices that it
is using.  Then use vgcreate to assemble the PVs into volume groups.
This also makes marks in the partitions, showing them as belonging to
that VG.  A record is also kept in /etc/lvm of all of this work, which
should be backed up periodically. ( read up on vgcfgbackup /
vgcfgrestore )  Finally, use lvcreate / mke2fs to create the actual 
components of your filesystem.  Note, however, that in your lvm.conf
file, you need to check your filters, to make sure that ONLY the "mdX"
device is scanned, NOT the sdaX, sdbX devices.


> ---Tom


Brian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2229 bytes
Desc: not available
URL: <http://www.trilug.org/pipermail/trilug/attachments/20060603/9c18a5ea/attachment.bin>


More information about the TriLUG mailing list