Skip to contentSkip to conversation

Adding PVs to a group

linux-lvm Charles Marcus 5 participants 12 messages Apr 18, 2008 – Apr 21, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

I'm still fairly new to using LVM, and I need to do something on a live server, so just need to be sure of what I'm doing...

Hardware:

3ware 9500S-8 Raid card with 8 Seagate 160GB hard drives

Ports 0 & 1 are mirrored, and contain:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         100      803218+  83  Linux
/dev/sda2             101         163      506047+  82  Linux swap
/dev/sda3             164        2654    20008957+  83  Linux
/dev/sda4            2655       19450   134913870   83  Linux

The other 6 are set up in a Raid 10, and contain:

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       24900   200009218+  8e  Linux LVM
/dev/sdb2           24901       58352   268703190   8e  Linux LVM

pvscan shows:

myhost # pvscan
/dev/cdrom: open failed: Read-only file system Attempt to close device '/dev/cdrom' which is not open.
PV /dev/sdb1 VG vg2 lvm2 [190.74 GB / 0 free]
Total: 1 [190.74 GB] / in use: 1 [190.74 GB] / in no VG: 0 [0 ]
myhost #

lvscan shows:

myhost # lvscan

  ACTIVE            '/dev/vg2/home' [50.00 GB] inherit
  ACTIVE            '/dev/vg2/usr' [20.00 GB] inherit
  ACTIVE            '/dev/vg2/var' [120.74 GB] inherit

myhost #

So, /dev/sdb2 was being used for backups, but I was finally able to convince the boss to let me get a QNAP NAS, so am using that for backups now.

What I want to do is make the space from /dev/sdb2 available to my vg2 volume group, so I can extend my /var partition (it is filling up fast - damn email packrats)....

Am I correct in that all I need to do is:

vgextend vg2 /dev/sdb2

then I can extend any of the logical volumes?

What I want to do is add all of /dev/sdb2 to the /var partition, so am I correct taht to do this I would do:

lvextend -l %FREE /dev/vg2/var

(I think the %FREE is how I tell it to use all of it, right?)

then resize the filesystem (it is reiserfs):

umount /dev/vg2/var
resize_reiserfs /dev/vg2/var
mount -t reiserfs /dev/vg2/var /var

Thanks for any help and/or suggestions...

Signature · 3 lines
Best regards,

Charles
#1 lore raw
Quoted 8 lines · Charles Marcus

Ports 0 & 1 are mirrored, and contain:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         100      803218+  83  Linux
/dev/sda2             101         163      506047+  82  Linux swap
/dev/sda3             164        2654    20008957+  83  Linux
/dev/sda4            2655       19450   134913870   83  Linux

Should have been more specific...

/dev/sda1 = /boot
/dev/sda2 = swap
/dev/sda3 = /
/dev/sda4 = /backups

Quoted 5 lines

The other 6 are set up in a Raid 10, and contain:

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       24900   200009218+  8e  Linux LVM
/dev/sdb2           24901       58352   268703190   8e  Linux LVM 

These are:

/dev/sdb1 = /home, /usr, and /var
/dev/sdb2 = nothing (was being used for backups)

Signature · 3 lines
Best regards,

Charles
#2 lore raw

sounds fine to me.

I had never heard of the %FREE thing though. To fill out a vg I would just check how many extents are available and use that on the command line with -l, remember there are no spaces between -l and the number of extents given.

#3 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · [email protected] wrote:

sounds fine to me.

I had never heard of the %FREE thing though. To fill out a vg I would just check how many extents are available and use that on the command line with -l, remember there are no spaces between -l and the number of extents given.

The %VG, %LV & %FREE suffices were introduced a while back:

Version 2.02.11 - 12th October 2006
===================================
[...]
Add %VG, %LV and %FREE suffices to lvcreate/lvresize --extents arg.

Regards,
Bryn.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFIDGl+6YSQoMYUY94RAmYvAKCSdjcxMRVbvZY0RCKEJZYClEyzdwCgrJ2m kJj33ju8X2nYhJcG0yhBA1g=
=cdou
-----END PGP SIGNATURE-----

#4 lore raw
Quoted 9 lines · Bryn M. Reeves
Quoted 1 line

I had never heard of the %FREE thing though. To fill out a vg I

would just check how many extents are available and use that on the command line with -l, remember there are no spaces between -l and the number of extents given.

The %VG, %LV & %FREE suffices were introduced a while back:

Version 2.02.11 - 12th October 2006
===================================
[...]
Add %VG, %LV and %FREE suffices to lvcreate/lvresize --extents arg.

Cool... so to confirm, the correct syntax would be:

lvextend -l%FREE /dev/vg2/var

(no space between the 'l' and '%FREE')

?

Thanks again guys...

Signature · 3 lines
Best regards,

Charles
#5 lore raw
In reply to Charles Marcus

Actually, now I'm confusing myself...

Currently, /dev/sdb is partitioned into two partitions...

Since I'm no longer using the second partition at all, wouldn't it be simpler/cleaner to just delete the second partition entirely (using fdisk) and then just resize /dev/sdb1 to include the new free space using vgextend?

Or will that not work?

Signature · 3 lines
Best regards,

Charles
#6 lore raw
Quoted 7 lines · Charles Marcus

Actually, now I'm confusing myself...

Currently, /dev/sdb is partitioned into two partitions...

Since I'm no longer using the second partition at all, wouldn't it be simpler/cleaner to just delete the second partition entirely (using fdisk) and then just resize /dev/sdb1 to include the new free space using vgextend?

Or will that not work?

That will work. You'll need to run pvresize after resizing the partition, and you wouldn't need to use vgextend.

--Dave

#7 lore raw
Quoted 5 lines · David Robinson
Quoted 3 lines

Since I'm no longer using the second partition at all, wouldn't it be simpler/cleaner to just delete the second partition entirely (using fdisk) and then just resize /dev/sdb1 to include the new free space using vgextend?

Or will that not work?

That will work. You'll need to run pvresize after resizing the partition, and you wouldn't need to use vgextend.

Thanks for taking the time to hold my hand a little through this David...

OT: this list seems a little on the dead side... is there a more active LVM oriented list that you are aware of?

Anyway...

Ok, so I guess the only question I have is - does it matter?

Is my following evaluation correct? :

It is much simpler - because I can do this without rebooting - to just do:

vgextend vg2 /dev/sdb2, then

lvextend -L+100G /dev/vg2/var, then

resize_reiserfs -f /dev/vg2/var

than it is to:

delete /dev/sdb2, reboot, then

resize /dev/sdb1, reboot, then

run pvresize, *then*

run lvextend...

So, again - does it really matter? Is having my vg2 in one big LVM partition 'better' than having it consist of two different partitions?

I'm thinking it does *not* matter, so will most likely go with the first/easiest option, unless you (or someone else) provides a good reason to take option 2...

Thanks again,

Signature · 3 lines
Best regards,

Charles
#8 lore raw
Quoted 1 line

OT: this list seems a little on the dead side... is there a more active LVM oriented list that you are aware of?

The list is active, but its quiet on weekends ;)

Quoted 1 line

Ok, so I guess the only question I have is - does it matter?

It doesn't really matter. Either method will work fine. I'd prefer to remove the partition, but that's only to keep things tidy - I don't like having unnecessary partitions.

Quoted 6 lines

Is my following evaluation correct? :

It is much simpler - because I can do this without rebooting - to just do:

vgextend vg2 /dev/sdb2, then

Quoted 7 lines

lvextend -L+100G /dev/vg2/var, then

resize_reiserfs -f /dev/vg2/var

than it is to:

delete /dev/sdb2, reboot, then

You could modify the partition table in one step rather than two. Use fdisk to delete both partitions then create a new partition that spans the entire device (just make sure that you create the partition with the same start block). The end result should look something like:

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       58352   468712408+  8e  Linux LVM
Quoted 1 line

resize /dev/sdb1, reboot, then

You may not need to reboot at all... you could use "partprobe" or "blockdev --rereadpt", but check /proc/partitions to make sure that the kernel knows of the new partition table. I've seen instances where partprobe doesn't actually cause the partition table to be refreshed.

Quoted 5 lines

run pvresize, *then*

run lvextend...

So, again - does it really matter? Is having my vg2 in one big LVM partition 'better' than having it consist of two different partitions?

There's no difference, LVM doesn't care.

--Dave

#9 lore raw
Quoted 3 lines · David Robinson
Quoted 1 line

OT: this list seems a little on the dead side... is there a more active LVM oriented list that you are aware of?

The list is active, but its quiet on weekends ;)

Oh, right, I forget that some people actually have lives outside work, unlike me... ;)

Quoted 4 lines

You could modify the partition table in one step rather than two. Use fdisk to delete both partitions then create a new partition that spans the entire device (just make sure that you create the partition with the same start block). The end result should look something like:

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       58352   468712408+  8e  Linux LVM

I have read about doing this, but somehow it just gives me the shudders...

I'll have to play with it sometime in a VM...

Quoted 3 lines
Quoted 1 line

resize /dev/sdb1, reboot, then

You may not need to reboot at all... you could use "partprobe" or "blockdev --rereadpt", but check /proc/partitions to make sure that the kernel knows of the new partition table. I've seen instances where partprobe doesn't actually cause the partition table to be refreshed.

Thanks - have to read up on partprobe too...

Still feel like a newbie sometimes, even though I've been using Linux for almost two years now (came over from the windows world)...

Quoted 3 lines
Quoted 1 line

So, again - does it really matter? Is having my vg2 in one big LVM partition 'better' than having it consist of two different partitions?

There's no difference, LVM doesn't care.

Ok, thanks... thats what I'll do for now... I'm actually planning on replacing this server with a different one and rebuilding everything from scratch in a few months anyway, so I'll redo the partitions then...

For now, simple and safe is best... my main goal is to keep /var from filling up...

Signature · 3 lines
Best regards,

Charles
#10 lore raw
In reply to Charles Marcus
Quoted 6 lines · Charles Marcus

vgextend vg2 /dev/sdb2, then

lvextend -L+100G /dev/vg2/var, then

resize_reiserfs -f /dev/vg2/var

In your first example you umount'd before resizing. In this example you don't. reiser doesn't require taking the volume offline before resizing, so I don't think you need umount in any case.
Ross

#11 lore raw
Quoted 7 lines · Ross Boylan
Quoted 5 lines

vgextend vg2 /dev/sdb2, then

lvextend -L+100G /dev/vg2/var, then

resize_reiserfs -f /dev/vg2/var

In your first example you umount'd before resizing. In this example you don't. reiser doesn't require taking the volume offline before resizing, so I don't think you need umount in any case.

Right... although, if I'm not mistaken, you do have to umount if you are *shrinking*...

And I'm assuming thats what the -f is for when doing it on a live filesystem?

But I prefer to umount anyway... just feels safer to me...

Signature · 3 lines
Best regards,

Charles