From: "Bryn M. Reeves" <bmr@redhat.com>
To: "Stuart D. Gathman" <stuart@bmsi.com>
Cc: maillists@conactive.com,
LVM general discussion and development <linux-lvm@redhat.com>
Subject: Re: [linux-lvm] shift PV from disk to raid device?
Date: Tue, 09 Dec 2008 17:36:06 +0000 [thread overview]
Message-ID: <493EAC86.6010104@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0812091146560.16428@bmsred.bmsi.com>
Stuart D. Gathman wrote:
> His problem is that sda is one of the mirror of md2. And he
> accidentally make sda the PV instead of md2. So pvmove is only part of
> solution.
I'd misread that. In that case, there should be no need to copy any
data. Just re-create the PV on the correct device and restore the VG
metadata, but this set up sounds a little strange to me - I'm not sure
how you would get into that situation in the first place since you
cannot (at least with up-to-date tools) run pvcreate on an MD member:
# mdadm -C /dev/md0 -l1 -n2 /dev/loop{0,1}
mdadm: array /dev/md0 started.
# pvcreate /dev/loop0
Can't open /dev/loop0 exclusively. Mounted filesystem?
Afaik, that check has been in there for quite some time. You also can't
just stop the array and run it on a member or it'll trash the MD superblock:
# pvcreate /dev/loop0
Wiping software RAID md superblock on /dev/loop0
Physical volume "/dev/loop0" successfully created
Which will break the array. The only way I could make this happen was by
creating an array, breaking one member of it (i.e. destroying the
array), creating a PV on it and then re-creating the array, forcing it
for the fact that one member already had a valid MD superblock:
# mdadm --run /dev/md0
mdadm: failed to run array /dev/md0: Invalid argument
# mdadm -C /dev/md0 -l1 -n2 /dev/loop{0,1}
mdadm: /dev/loop1 appears to be part of a raid array:
level=1 devices=2 ctime=Tue Dec 9 11:03:16 2008
Continue creating array? y
mdadm: array /dev/md0 started.
That's quite a lot of forcing/overriding and the system no longer
recognises the MD member (/dev/loop0 in this case) as an LVM2 PV:
# pvs /dev/loop0
Failed to read physical volume "/dev/loop0"
I can only get the LVM2 tools to recognise this as a PV at this point by
manually disabling MD component detection
(devices/md_component_detection = 0), which has been turned on by
default since 2.00.13.
At this point, when the array is running I can "see" 3 PVs, but the LVM
tools chose the MD array and do not complain about duplicates:
# pvs -o+uuid
PV VG Fmt Attr PSize PFree PV UUID
/dev/md0 lvm2 -- 128.00M 128.00M
kAa32l-uWS3-8y5b-jXQB-e2tI-xaGy-8akTyc
With the array not running, I do get duplicate warnings for the 2nd side
of the mirror:
# pvs -o+uuid
Found duplicate PV kAa32luWS38y5bjXQBe2tIxaGy8akTyc: using /dev/loop1
not /dev/loop0
PV VG Fmt Attr PSize PFree PV UUID
/dev/loop1 lvm2 -- 128.00M 128.00M
kAa32l-uWS3-8y5b-jXQB-e2tI-xaGy-8akTyc
The OP didn't mention the versions of the tools in use, so I'm not sure
what to conclude here. It seems a little odd that he's been able to get
into such a position.
> Here are the steps that I see:
>
> 1) remove sda from md2 array
> 2) use dd or pvremove to clear PV info in md2. This should not
> affect sda since sda is removed from md2
But the LVM tools still think that md2 is part of the VG and the same PV
UUID is going to be visible on both members of the array and the MD device..
> 3) pvcreate md2 as a new PV and add to volume group
In my testing, md2 would already be a PV at this point - if it really
does contain the same data as sda3/sdb3 then it should show up as a PV
already.
> 4) pvmove sda -> md2. The data should physically go on sdb, or whatever the
> other mirror of md2 is.
It seems a bit pointless moving data around if it's already there.
> 5) check that all LVs are gone from sda, and remove from volume group
> 6) pvremove sda
> 7) add sda to md2 array, and synchronize.
> Did I miss anything?
I'd have thought that you could just take a metadata backup
(vgcfgbackup), wipe the labels from all devices and then run:
pvcreate --uuid=$the_uuid --restorefile=/path/to/backup /dev/md2
vgcfgrestore -f /path/to/backup $vgname
And avoid the need to shovel lots of data around.
This works for me, but I'm not completely convinced that I've re-created
the same situation the original poster was seeing - I had to play a lot
of tricks with the tools just to get into that state in the first place.
Regards,
Bryn.
next prev parent reply other threads:[~2008-12-09 17:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-08 23:41 [linux-lvm] shift PV from disk to raid device? Kai Schaetzl
2008-12-09 10:30 ` Bryn M. Reeves
2008-12-09 13:09 ` Kai Schaetzl
2008-12-09 14:24 ` Bryn M. Reeves
2008-12-09 17:22 ` Kai Schaetzl
2008-12-09 16:54 ` Stuart D. Gathman
2008-12-09 16:56 ` Stuart D. Gathman
2008-12-09 17:36 ` Bryn M. Reeves [this message]
2008-12-09 18:16 ` Kai Schaetzl
2008-12-09 18:32 ` Kai Schaetzl
2008-12-09 18:03 ` Kai Schaetzl
2008-12-09 18:06 ` Bryn M. Reeves
2008-12-09 18:20 ` Kai Schaetzl
2008-12-09 18:38 ` Stuart D. Gathman
2008-12-09 19:42 ` Kai Schaetzl
2008-12-09 19:56 ` Doug Ledford
2008-12-09 20:15 ` Kai Schaetzl
2008-12-09 20:22 ` Doug Ledford
2008-12-09 21:03 ` Stuart D. Gathman
2008-12-09 21:22 ` Doug Ledford
2008-12-09 20:38 ` Kai Schaetzl
2008-12-09 20:51 ` Doug Ledford
2008-12-09 21:04 ` Stuart D. Gathman
2008-12-09 20:49 ` Kai Schaetzl
2008-12-09 20:56 ` Doug Ledford
2008-12-10 0:31 ` Kai Schaetzl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=493EAC86.6010104@redhat.com \
--to=bmr@redhat.com \
--cc=linux-lvm@redhat.com \
--cc=maillists@conactive.com \
--cc=stuart@bmsi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.