Splitting a Volume Group--Jaylin Zhou
Create PVs:
# pvcreate /dev/sdb[567] Physical volume "/dev/sdb5" successfully created Physical volume "/dev/sdb6" successfully created Physical volume "/dev/sdb7" successfully created
|
Create VG:
# vgcreate myvg /dev/sdb[567] Volume group "myvg" successfully created
|
Create LV:
# lvcreate -l 50 /dev/myvg -n mylv Logical volume "mylv" created
|
Create filesystem on LV:
# mkfs.ext3 /dev/myvg/mylv
|
Mount LV and Write data on LV
Determining Free Space:
Use "pvscan" command to determine how much free space is currently available in the VG
# pvscan PV /dev/sdb5 VG myvg lvm2 [100.00 MB / 0 free] PV /dev/sdb6 VG myvg lvm2 [100.00 MB / 0 free] PV /dev/sdb7 VG myvg lvm2 [100.00 MB / 100.00 MB free] Total: 3 [300.00 MB] / in use: 3 [300.00 MB] / in no VG: 0 [0 ]
|
Moving the Data:
Move all the used PE in /dev/sdb5 to /dev/sdb7 with the "pvmove" command
The "pvmove" command can take a long time to execute
# pvmove /dev/sdb5 /dev/sdb7 /dev/sdb5: Moved: 100.0%
|
After moving the data, all of the space on /dev/sdb5 is free
# pvscan PV /dev/sdb5 VG myvg lvm2 [100.00 MB / 100.00 MB free] PV /dev/sdb6 VG myvg lvm2 [100.00 MB / 0 free] PV /dev/sdb7 VG myvg lvm2 [100.00 MB / 0 free] Total: 3 [300.00 MB] / in use: 3 [300.00 MB] / in no VG: 0 [0 ]
|
Splitting the VG:
Before splitting the VG, the LV must be inactive.
If the file system is mounted, it must be unmounted before deactivating the LV.
Deactivate the LV with the "lvchange" command or "pvchange" command
# lvchange -an /dev/myvg/mylv
|
Split the VG "yourvg" from the VG "myvg" with moving PV "/dev/sdb5" into the new VG "yourvg"
# vgsplit myvg yourvg /dev/sdb5 New volume group "yourvg" successfully split from "myvg"
|
Use the "vgs" command to see the attributes of the two VGs
# vgs VG #PV #LV #SN Attr VSize VFree myvg 2 1 0 wz--n- 200.00M 0 yourvg 1 0 0 wz--n- 100.00M 100.00M
|
Creating the New LV:
Create the new LV "yourlv"
# lvcreate -l 100%FREE /dev/yourvg -n yourlv Logical volume "yourlv" created
|
Making a File System and Mounting the New LV:
# mkfs.ext3 /dev/yourvg/yourlv # mount /dev/yourvg/yourlv /mnt/
|
Activating and Mounting the Original LV:
Check the state of the original LV
# lvscan inactive '/dev/myvg/mylv' [200.00 MB] inherit ACTIVE '/dev/yourvg/yourlv' [100.00 MB] inherit
|
Activate the original LV
# lvchange -ay /dev/myvg/mylv
|
Check the new state of the original LV
# lvscan ACTIVE '/dev/myvg/mylv' [200.00 MB] inherit ACTIVE '/dev/yourvg/yourlv' [100.00 MB] inherit # mount /dev/myvg/mylv /mnt/
|
阅读(1368) | 评论(0) | 转发(0) |