[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: lvm2 - question about pvmove

In <4A5D2A14.9000108@cox.net>, Ron Johnson wrote:
>On 2009-07-13 14:24, Boyd Stephen Smith Jr. wrote:
>> In <4A5B841E.7010900@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 

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.           	 ,= ,-_-. =.
bss@iguanasuicide.net            	((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy 	 `-'(. .)`-'
http://iguanasuicide.net/        	     \_/

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

Reply to: