Re: lvm2 - question about pvmove

2009-07-15 Thread Boyd Stephen Smith Jr.
In <4a5d2a14.9000...@cox.net>, Ron Johnson wrote:
>On 2009-07-13 14:24, Boyd Stephen Smith Jr. wrote:
>> In <4a5b841e.7010...@cox.net>, Ron Johnson wrote:
 In your case, you'll have to add at least 3 of the new PVs to the VG
 before pvmove will let you begin.  Are you going to move swap onto
 LVM? If not, make sure your partition table for the new drive still
 has space for swap.
>>
>> If you have a VG that is on /dev/sda2 and /dev/sdb and you want to move
>> it (and, of course, all the LVs it contains) to /dev/sdc1, /dev/sdc2,
>> /dev/sdc3, and /dev/sdc4, you do:
>
>Here's the difference: your example assumes inserting the new hard
>drive and then moving the old data to it.

Based on my quoting of you, I'd say that is the case you are in as well.

>I don't yet have the new hard drive, and want to get all the data
>off of the old drive first.

Do you have enough free PEs in your VG to do that?  It might not be 
possible.

Here's a script that will tell you:
pvs -o name,pe_count,pe_alloc_count --noheadings |
awk '
BEGIN { device="/dev/sda5"; free=0; need=0; }
$1 = device { need += $3; }
$1 != device { free += ($2 - $3); }
END {
printf "need = %d\n", need;
printf "free = %d\n", free;
printf "Can%s reallocate extents on %s.\n",
   (need <= free ? "" : "not"), device;
}
'

You'll need to change the device on line 3 and run the whole thing as root.

Assuming you have enough space, it should be as simple as:
vgreduce $vg $failing_device
# Remove device
# Add new device
vgextend $vg $new_device
# If you want, pvmove LVs around.
-- 
Boyd Stephen Smith Jr.   ,= ,-_-. =.
b...@iguanasuicide.net  ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/\_/



signature.asc
Description: This is a digitally signed message part.


Re: lvm2 - question about pvmove

2009-07-14 Thread Ron Johnson

On 2009-07-13 14:24, Boyd Stephen Smith Jr. wrote:

In <4a5b841e.7010...@cox.net>, Ron Johnson wrote:

In your case, you'll have to add at least 3 of the new PVs to the VG
before pvmove will let you begin.  Are you going to move swap onto LVM? 
If not, make sure your partition table for the new drive still has space

for swap.

So pvmove will spread the blocks across any empty devices?


1. Read the manpage.
2. You can specify a destination or destinations if you like.  You can also 
limit the source to a single LV.

3. Yes.


Like others, I think having multiple PVs on a single physical disk is a
bit silly, but I don't foresee it causing any issues.

Is there an lvmove or vgmove?


There is no lvmove or vgmove, nor is there a need for them.  Moving a VG to 
different physical media is handled via pvmove.  Moving a LV to different 
physical media is handled via pvmove.  Moving a PV to different phyical 
media doesn't make sense (usually) and is NOT handled via pvmove.


If you have a VG that is on /dev/sda2 and /dev/sdb and you want to move it 
(and, of course, all the LVs it contains) to /dev/sdc1, /dev/sdc2, 
/dev/sdc3, and /dev/sdc4, you do:

pvcreate /dev/sdc1
pvcreate /dev/sdc2
pvcreate /dev/sdc3
pvcreate /dev/sdc4
vgextend $vg /dev/sdc1
vgextend $vg /dev/sdc2
vgextend $vg /dev/sdc3
vgextend $vg /dev/sdc4


Here's the difference: your example assumes inserting the new hard 
drive and then moving the old data to it.


I don't yet have the new hard drive, and want to get all the data 
off of the old drive first.


So, I simply tried "pvmove $FAILING_PARTITION" but it instantly 
threw me an error.


Sadly, I didn't save it.


pvmove /dev/sda2
pvmove /dev/sdb
vgreduce $vg /dev/sda2
vgreduce $vg /dev/sdb
pvremove /dev/sda2
pvremove /dev/sdb

If your VG contains /dev/md1, a RAID-0 device, and /dev/sdb, a hardware 
RAID-6 device, and part of LV "home" was allocated to /dev/md1 accidentally 
or temporarily you can move that data to /dev/sdb with:

pvmove /dev/md1 -n home /dev/sdb



--
Scooty Puff, Sr
The Doom-Bringer


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org




Re: lvm2 - question about pvmove

2009-07-13 Thread Boyd Stephen Smith Jr.
In <537f90650907131240t37ff3fa9k2e72f498eec26...@mail.gmail.com>, Mike 
Castle wrote:
>On Mon, Jul 13, 2009 at 12:24 PM, Boyd Stephen Smith
>
>Jr. wrote:
>> pvcreate /dev/sdc1
>> pvcreate /dev/sdc2
>> pvcreate /dev/sdc3
>> pvcreate /dev/sdc4
>> vgextend $vg /dev/sdc1
>> vgextend $vg /dev/sdc2
>> vgextend $vg /dev/sdc3
>> vgextend $vg /dev/sdc4
>> pvmove /dev/sda2
>> pvmove /dev/sdb
>> vgreduce $vg /dev/sda2
>> vgreduce $vg /dev/sdb
>> pvremove /dev/sda2
>> pvremove /dev/sdb
>
>Wouldn't you want to move the first pvremove up after the first
>pvmove?  Otherwise the second pvmove might choose to move onto the
>device you just cleared out.

Sort of.  I was a bit sloppy there.

The last 6 lines should be rearranged:
pvmove /dev/sda2
vgreduce $vg /dev/sda2
pvmove /dev/sdb
vgreduce $vg /dev/sdb
pvremove /dev/sda2
pvremove /dev/sdb

You could also move the first pvremove up a bit.  Anytime after the first 
vgreduce is fine.

Also, the pvmove commands might be optional.  ISTR that vgreduce is smart 
enough to perform a pvmove if the PV being removed still has PEs allocated.

Finally, the pvremove command are good practice but optional.  LVM will not 
complain if those devices suddenly disappear because they are not associated 
with a known VG.
-- 
Boyd Stephen Smith Jr.   ,= ,-_-. =.
b...@iguanasuicide.net  ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/\_/




signature.asc
Description: This is a digitally signed message part.


Re: lvm2 - question about pvmove

2009-07-13 Thread Mike Castle
On Mon, Jul 13, 2009 at 12:24 PM, Boyd Stephen Smith
Jr. wrote:
> pvcreate /dev/sdc1
> pvcreate /dev/sdc2
> pvcreate /dev/sdc3
> pvcreate /dev/sdc4
> vgextend $vg /dev/sdc1
> vgextend $vg /dev/sdc2
> vgextend $vg /dev/sdc3
> vgextend $vg /dev/sdc4
> pvmove /dev/sda2
> pvmove /dev/sdb
> vgreduce $vg /dev/sda2
> vgreduce $vg /dev/sdb
> pvremove /dev/sda2
> pvremove /dev/sdb


Wouldn't you want to move the first pvremove up after the first
pvmove?  Otherwise the second pvmove might choose to move onto the
device you just cleared out.

mrc


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: lvm2 - question about pvmove

2009-07-13 Thread Boyd Stephen Smith Jr.
In <4a5b841e.7010...@cox.net>, Ron Johnson wrote:
>> In your case, you'll have to add at least 3 of the new PVs to the VG
>> before pvmove will let you begin.  Are you going to move swap onto LVM? 
>> If not, make sure your partition table for the new drive still has space
>> for swap.
>
>So pvmove will spread the blocks across any empty devices?

1. Read the manpage.
2. You can specify a destination or destinations if you like.  You can also 
limit the source to a single LV.
3. Yes.

>> Like others, I think having multiple PVs on a single physical disk is a
>> bit silly, but I don't foresee it causing any issues.
>
>Is there an lvmove or vgmove?

There is no lvmove or vgmove, nor is there a need for them.  Moving a VG to 
different physical media is handled via pvmove.  Moving a LV to different 
physical media is handled via pvmove.  Moving a PV to different phyical 
media doesn't make sense (usually) and is NOT handled via pvmove.

If you have a VG that is on /dev/sda2 and /dev/sdb and you want to move it 
(and, of course, all the LVs it contains) to /dev/sdc1, /dev/sdc2, 
/dev/sdc3, and /dev/sdc4, you do:
pvcreate /dev/sdc1
pvcreate /dev/sdc2
pvcreate /dev/sdc3
pvcreate /dev/sdc4
vgextend $vg /dev/sdc1
vgextend $vg /dev/sdc2
vgextend $vg /dev/sdc3
vgextend $vg /dev/sdc4
pvmove /dev/sda2
pvmove /dev/sdb
vgreduce $vg /dev/sda2
vgreduce $vg /dev/sdb
pvremove /dev/sda2
pvremove /dev/sdb

If your VG contains /dev/md1, a RAID-0 device, and /dev/sdb, a hardware 
RAID-6 device, and part of LV "home" was allocated to /dev/md1 accidentally 
or temporarily you can move that data to /dev/sdb with:
pvmove /dev/md1 -n home /dev/sdb
-- 
Boyd Stephen Smith Jr.   ,= ,-_-. =.
b...@iguanasuicide.net  ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/\_/



signature.asc
Description: This is a digitally signed message part.


Re: lvm2 - question about pvmove

2009-07-13 Thread Boyd Stephen Smith Jr.
In <4a5b8105.2020...@cox.net>, Ron Johnson wrote:
>On 2009-07-13 12:55, Mike Castle wrote:
>> On Mon, Jul 13, 2009 at 10:41 AM, Ron Johnson 
wrote:
>>> What if I want 4 "small" partitions instead of one monster 1TB
>>> partition? I've read that you need a target at least as large as the
>>> source.
>>
>> It makes no sense to have multiple LVM partitions on the same disk,
>> just to put them back together again as one big volume group.  I mean,
>> what's the purpose of using LVM in the first place then?
>
>And if that huge drive starts to die, how do you move the data over
>to another device?  AFAICT, there's no "lvmove".

pvmove handles moving data between devices, by remapping LEs to different 
PEs.  It *is* the tool that moves an LV to a different physical device.

I think you are somehow confused.

Use case for LVM, particularly pvmove:
1. Create small PV, pv1; pvcreate
2. Create VG, vg1; vgcreate 
3. Create LVs, lv1 and lv2; lvcreate
4. Decide to replace the physical media that is pv1.
5. Add new physical media.
6. Create new PV, pv2; pvcreate
7. Extend vg1; vgextend
8. Move data off of pv1; pvmove
9. Reduce vg1; vgreduce
10. Erase LVM header from physical media; pvremove
11. Remove small physical media.

Your LVs are now on different physical media and you never had to even mount 
them read-only.
-- 
Boyd Stephen Smith Jr.   ,= ,-_-. =.
b...@iguanasuicide.net  ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/\_/



signature.asc
Description: This is a digitally signed message part.


Re: lvm2 - question about pvmove

2009-07-13 Thread Ron Johnson

On 2009-07-13 13:32, Boyd Stephen Smith Jr. wrote:

In <4a5b26b9.50...@cox.net>, Ron Johnson wrote:

I have a 640GB drive that's starting to throw errors, so I'm going
to replace it with a 1TB drive.

The 640GB (596GiB) drive is partitioned into:
sdb1 - 2GiB swap
sdb2 - 594GiB lvm2 member

When I get the new device, I want to create 4x 250GB PVs, and then
move the contents of sdb2 into them.

Any tips?


Not really.  pvmove is relatively foolproof.  It makes sure there are enough 
free PEs before it begins the process and it checkpoints regularly.  It can 
be aborted at any time.  Even if it is completed and you find you don't like 
the results, you can always restore your old VG metadata because LVM makes a 
backup immediately before the pvmove and immediately after.


In your case, you'll have to add at least 3 of the new PVs to the VG before 
pvmove will let you begin.  Are you going to move swap onto LVM?  If not, 
make sure your partition table for the new drive still has space for swap.


So pvmove will spread the blocks across any empty devices?

Like others, I think having multiple PVs on a single physical disk is a bit 
silly, but I don't foresee it causing any issues.


Is there an lvmove or vgmove?

--
Scooty Puff, Sr
The Doom-Bringer


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org




Re: lvm2 - question about pvmove

2009-07-13 Thread Ron Johnson

On 2009-07-13 12:55, Mike Castle wrote:

On Mon, Jul 13, 2009 at 10:41 AM, Ron Johnson wrote:

What if I want 4 "small" partitions instead of one monster 1TB partition?
 I've read that you need a target at least as large as the source.

(I've got this aching feeling that 1TB partitions are just not a good idea,
and that granularity is always a good idea...)


It makes no sense to have multiple LVM partitions on the same disk,
just to put them back together again as one big volume group.  I mean,
what's the purpose of using LVM in the first place then?



And if that huge drive starts to die, how do you move the data over 
to another device?  AFAICT, there's no "lvmove".


--
Scooty Puff, Sr
The Doom-Bringer


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org




Re: lvm2 - question about pvmove

2009-07-13 Thread Boyd Stephen Smith Jr.
In <4a5b26b9.50...@cox.net>, Ron Johnson wrote:
>I have a 640GB drive that's starting to throw errors, so I'm going
>to replace it with a 1TB drive.
>
>The 640GB (596GiB) drive is partitioned into:
>sdb1 - 2GiB swap
>sdb2 - 594GiB lvm2 member
>
>When I get the new device, I want to create 4x 250GB PVs, and then
>move the contents of sdb2 into them.
>
>Any tips?

Not really.  pvmove is relatively foolproof.  It makes sure there are enough 
free PEs before it begins the process and it checkpoints regularly.  It can 
be aborted at any time.  Even if it is completed and you find you don't like 
the results, you can always restore your old VG metadata because LVM makes a 
backup immediately before the pvmove and immediately after.

In your case, you'll have to add at least 3 of the new PVs to the VG before 
pvmove will let you begin.  Are you going to move swap onto LVM?  If not, 
make sure your partition table for the new drive still has space for swap.

Like others, I think having multiple PVs on a single physical disk is a bit 
silly, but I don't foresee it causing any issues.
-- 
Boyd Stephen Smith Jr.   ,= ,-_-. =.
b...@iguanasuicide.net  ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/\_/



signature.asc
Description: This is a digitally signed message part.


Re: lvm2 - question about pvmove

2009-07-13 Thread Mike Castle
On Mon, Jul 13, 2009 at 10:41 AM, Ron Johnson wrote:
>>
>
> What if I want 4 "small" partitions instead of one monster 1TB partition?
>  I've read that you need a target at least as large as the source.
>
> (I've got this aching feeling that 1TB partitions are just not a good idea,
> and that granularity is always a good idea...)

It makes no sense to have multiple LVM partitions on the same disk,
just to put them back together again as one big volume group.  I mean,
what's the purpose of using LVM in the first place then?

No.  Partition the disk into one swap + one LVM.

Then use the LVM stuff to parcel out the space to various file systems.

The only case that I could see for partitioning the drive into
multiple LVM chunks would be if you want to experiment with using the
LVM commands like pvmove and you only have one disk.

For example, I have one machine with four disks, two 500GB and two
1TB.  The partition schemes on those are:
/dev/sda1   1  17  136521   82  Linux swap / Solaris
/dev/sda2  18  121601   976623480   8e  Linux LVM
/dev/sdb1   1  17  136521   82  Linux swap / Solaris
/dev/sdb2  18  121601   976623480   8e  Linux LVM
/dev/sdc1   1  17  136521   82  Linux swap / Solaris
/dev/sdc2  18   60801   488247480   8e  Linux LVM
/dev/sdd1   1  17  136521   82  Linux swap / Solaris
/dev/sdd2  18   60801   488247480   8e  Linux LVM

That gives me a VG of 2.73TB, which I have partitioned out into into a
number of LVs of all sorts of different sizes:
thune:~# lvdisplay | grep LV.Size
  LV Size300.00 GB
  LV Size128.00 GB
  LV Size70.00 GB
  LV Size5.00 GB
  LV Size512.00 MB
  LV Size16.00 GB
  LV Size1.00 GB
  LV Size14.00 GB
  LV Size1.94 TB
  LV Size20.00 GB
  LV Size25.00 GB

Hmmm.. . I wonder what that 1GB one is

One my other machine, it's similar, only with less swap across spindles:
/dev/sda1   1  182401  1465136001   8e  Linux LVM
/dev/sdb1   1  17  136521   82  Linux swap / Solaris
/dev/sdb2  18  121601   976623480   8e  Linux LVM

For another 2.27TB with:
  LV Size8.00 GB
  LV Size15.00 GB
  LV Size800.00 GB
  LV Size200.00 GB
  LV Size200.00 GB
  LV Size200.00 GB
  LV Size900.00 GB


Nothing wrong with big disk partitions (fdisk); just break it up into
smaller LVs

mrc


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: lvm2 - question about pvmove

2009-07-13 Thread Ron Johnson

On 2009-07-13 11:54, Mike Castle wrote:

Don't try to do two things at once.  If something goes wrong, you
won't know which is the cause.

Just put in the new drive and partition it into swap + lvm

swapoff /dev/sda1
vi /etc/fstab   # remove swap
pvcreate
vgextend
pvmove -v /dev/sdb2


What if I want 4 "small" partitions instead of one monster 1TB 
partition?  I've read that you need a target at least as large as 
the source.


(I've got this aching feeling that 1TB partitions are just not a 
good idea, and that granularity is always a good idea...)



vgreduce /dev/sdb2


Interesting, and helpful that I don't have to know how large that 
/dev/sdb2 is.




shutdown and remove the bad drive

At that point, everything should be good and you can continue on.
Moreover, you'll still have nearly 400G on the new drive that you can
play with.

Now you can lvcreate a new volume and move stuff over and set up mount
points at your leisure.  You can then reduce the existing partition
and eventually get to the form you're looking for.



--
Scooty Puff, Sr
The Doom-Bringer


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org




Re: lvm2 - question about pvmove

2009-07-13 Thread Mike Castle
Don't try to do two things at once.  If something goes wrong, you
won't know which is the cause.

Just put in the new drive and partition it into swap + lvm

swapoff /dev/sda1
vi /etc/fstab   # remove swap
pvcreate
vgextend
pvmove -v /dev/sdb2
vgreduce /dev/sdb2

shutdown and remove the bad drive

At that point, everything should be good and you can continue on.
Moreover, you'll still have nearly 400G on the new drive that you can
play with.

Now you can lvcreate a new volume and move stuff over and set up mount
points at your leisure.  You can then reduce the existing partition
and eventually get to the form you're looking for.

mrc


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: lvm2 - question about pvmove

2009-07-13 Thread Ron Johnson

On 2009-07-13 09:42, Johannes Wiedersich wrote:

Ron Johnson wrote:

When I get the new device, I want to create 4x 250GB PVs, and then move

  
Why? Any reason why not just less PVs?


Granularity.

--
Scooty Puff, Sr
The Doom-Bringer


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org




Re: lvm2 - question about pvmove

2009-07-13 Thread Johannes Wiedersich
Ron Johnson wrote:
> When I get the new device, I want to create 4x 250GB PVs, and then move
  
Why? Any reason why not just less PVs?

Cheers,

Johannes


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org