1 |
On Wednesday 30 March 2011 07:28:40 Florian Philipp wrote: |
2 |
> Am 30.03.2011 05:02, schrieb Einux: |
3 |
> > Hi, |
4 |
> > |
5 |
> > I bought a new 1T harddrive which is exactly the same as my previous |
6 |
> > harddrive. So I'm planning to make a Raid-1 layout(for security |
7 |
> > reasons). But here's the problem: I've already setup LVM2 on the |
8 |
> > existing harddrive and I don't want to destroy the existing LVM volume |
9 |
> > groups. I tried to google it, but I'm not sure which is the right |
10 |
> > keyword. Could you guys help me out? |
11 |
> > |
12 |
> > Thanks in advance:) |
13 |
> |
14 |
> 1. Create a degenerated RAID1 with your new disk |
15 |
> mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb |
16 |
> |
17 |
> 2. Partition the raid device |
18 |
> |
19 |
> 3. Add one of the partitions to your LVM volume group. |
20 |
> pvcreate /dev/sdb2 |
21 |
> vgextend volume_group /dev/sdb2 |
22 |
> |
23 |
> 4. Move everything from the old physical volumes to the new pv. |
24 |
> pvmove /dev/sda3 /dev/sdb2 |
25 |
> |
26 |
> 5. Remove the old and now empty physical volume |
27 |
> vgreduce volume_group /dev/sda3 |
28 |
> |
29 |
> 6. Move everything else which is not on LVM to your new raid. Guess you |
30 |
> need to go to single user mode to do this safely. |
31 |
> |
32 |
> 7. Grow your raid to also contain the old disk. |
33 |
> mdadm /dev/md0 -a /dev/sda |
34 |
> |
35 |
> No, I have not tested this and you should double-check everything. No |
36 |
> guarantees, etc. |
37 |
> |
38 |
> One warning, though: pvmove is known to create problems from time to |
39 |
> time. Leaking memory, bogging systems with infinite system load and so |
40 |
> on. If it gives you trouble, you can abort it with `pvmove --abort` and |
41 |
> try it again later by calling `pvmove volume_group` (without physical |
42 |
> device specified) to resume it. It SHOULD survive system crashes. |
43 |
> Trying another kernel version sometimes helps when pvmove gives you trouble. |
44 |
|
45 |
To avoid that, with "large" moves, do the following: |
46 |
# pvmove -i 600 /dev/sda3 |
47 |
|
48 |
The "-i 600" means, only report every 10 minutes. It's the "reporting" that |
49 |
causes the memory leak. |
50 |
|
51 |
Also, when just wanting to "empty" one physical volume, it is not necessary to |
52 |
specify the "target". |
53 |
It's a good idea to mark the PVs on the existing drive "non-allocatable". Then |
54 |
LVM won't try to move anything to that PV: |
55 |
# pvchange -xn /dev/sda3 |
56 |
|
57 |
The rest of the steps read correct. It's how I did a similar operation, but |
58 |
still double-check all the parameters and when in doubt, read the manual |
59 |
and/or ask on the list. |
60 |
|
61 |
-- |
62 |
Joost Roeleveld |