LVM How-To by Lennart

Tim Writer tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org
Wed Jan 17 04:50:31 UTC 2007


Merv Curley <mervc-MwcKTmeKVNQ at public.gmane.org> writes:

> On Monday 15 January 2007 16:18, Lennart Sorensen wrote:
> > On Fri, Jan 12, 2007 at 08:09:15PM -0500, Merv Curley wrote:
> > > Thanks for the instructions Lennart. From what stuck in the grey cells
> > > from the HOW-TO,  it seemed to make sense.  I assume that somewhere in
> > > the second stage I format the 'newdisk' with ext3 to match the present
> > > part of the logical volume?
> >
> > No.  You are extending an existing filesystem I imagine.  If you don't 
> > want to expand an existing logical volume, you can create a new logical
> > volume with lvcreate and format that afterwards.
> >
> hda on the Myth system, has a primary partition for /boot, a VolumeGroup 
> [rootvg]  for the  Myth install  / and the swap;  and a VolumeGroup for 
> Myth Data [videovg].  I have a 320 GB drive [hdb] that I thought could 
> extend the videovg group.

You can. Once you have extended it you have a choice. You can extend
existing logical volumes (using lvextend) or you can create new logical
volumes. New logical volumes would required to create file system on them
before mounting. Existing logical volumes likely already have a file system
which you can simply resize (e.g. using resize2fs) once you have extended
the volume using lvextend.

You complained about the LVM HOWTO but it's actually comprehensive. I think
it would be a good idea for you to spend some more time with it, perhaps on
an experimental system, to be sure you understand the concepts.

> > The vgdisplay should show how many free extents are unused (not used by
> > any logical volume).  That is how many extents you can potentially add
> > to any existing logical volume.
> >
> Well it seems that vgdisplay didn't return what it should have because I 
> didn't use the  VolumeGroup name.  I just tried again and
> 
>  vgdisplay videovg     [now sez among other things]
> 
> Max PV   0  0     Cur PV  1   1      Act PV  1  1
> VG size 225.88   PE Size 32 MB
> Total PE 7228
> Alloc PE/Size  7227 / 225.88
> Free PE/Size  1 / 32 MB

This is before running vgextend, correct? You only have one PV (physical
disk partition) and 1 free extent (block of 32MB available for use by LVM).
You need to use pvcreate to prepare your new disk for use with LVM and add
that PV to your existing volume group using vgextend. At that point, you
should have free extents.

> Is that better?

No. See above.

> How many free extents are there, just 1?

Yes.

> Is this second drive going to be videolv02 for mounting purposes in fstab
> and a part of the 'videovg group?

Absolutely not. When using LVM, you don't mount (physical) drives or
partitions, you mount logical volumes. The purpose of LVM is to provide a
layer between the file system and physical disks. It allows you to resize
your logical disks (logical volumes) by adding and removing physical disk
resources. You can then grow and shrink file systems without needing to
backup and restore them.

Let me give you a concrete example. My laptop has a single physical
disk. It has four physical partitions: 8GB for XP (yuck!), 512MB for the
laptop diagnostics, 256MB for /boot, and the remaining 25GB as a single PV
for LVM.

The PV comprises (is allocated to) a single volume group, vg0. Within vg0,
I have the following logival volumes:

    /dev/vg0/ub606_root
    /dev/vg0/ub606_usr
    /dev/vg0/ub606_var
    /dev/vg0/home
    /dev/vg0/ub610_root
    /dev/vg0/ub610_usr
    /dev/vg0/ub610_var

When running Ubuntu 6.10, I have the following mounts:

    /dev/vg0/ub610_root on /
    /dev/vg0/ub610_usr on /usr
    /dev/vg0/ub610_var on /var
    /dev/hda3 on /boot type
    /dev/vg0/home on /home type

I have free space in vg0, as you will have after you extend it with
pvcreate and vgextend. I can add some of that free space to /home as
follows:

    umount /home
    lvextend -L +4G /dev/vg0/home
    resize2fs /dev/vg0/home
    mount /home

At this point, I'll have an additional 4GB of usable space in /home. Note
that I didn't need to backup and restore /home, and I didn't need to make a
new file system.

[snip]

Hope this helps,

-- 
tim writer <tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org>                                  starnix inc.
647.722.5301                                      toronto, ontario, canada
http://www.starnix.com              professional linux services & products
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list