更多: zhilu jiaocheng
使用 vgmerge 合并 VG
我们可以将 VGs vg01 和 vg02 合并为一个 VG vg01.
因此,换句话说,我们希望摆脱 VG vg02 而不会丢失其中的任何数据。
请按照以下步骤操作:
- 卸载两个 VG 下的挂载点。
# umount /data01 # umount /u02
- 停用我们要移除的卷组并与另一个 VG 合并。
在我们的例子中是 vg02.
# vgchange -an vg02 0 logical volume(s) in volume group "vg02" now active
- 合并卷组
# vgmerge vg01 vg02 Volume group "vg02" successfully merged into "vg01"
- 激活从 vg02 合并的逻辑卷。
在我们的例子中,我们只有一个来自 vg02 的卷,例如:lv02:
# lvchange -ay vg01/lv02
如何将 2 个卷组与现有的 LV 合并,并且不应该有数据丢失。
在本文中,我们有 2 个 VGs vg01 和 vg02.
两者都其中创建了一个 LV,如下所示:
# vgs VG #PV #LV #SN Attr VSize VFree cl 1 2 0 wz--n- 19.00g 0 vg01 1 1 0 wz--n- 20.00g 10.00g vg02 1 1 0 wz--n- 20.00g 10.00g
# lvs LV VG Attr LSize Pool Oroirn Data% Meta% Move Log Cpy%Sync Convert root cl -wi-ao---- 17.00g swap cl -wi-ao---- 2.00g lv01 vg01 -wi-a----- 10.00g lv02 vg02 -wi-a----- 10.00g
# ls -lrt /dev/mapper/* crw-------. 1 root root 10, 236 Oct 6 18:25 /dev/mapper/control lrwxrwxrwx. 1 root root 7 Oct 6 18:25 /dev/mapper/cl-swap -> ../dm-1 lrwxrwxrwx. 1 root root 7 Oct 6 18:25 /dev/mapper/cl-root -> ../dm-0 lrwxrwxrwx. 1 root root 7 Oct 6 18:28 /dev/mapper/vg01-lv01 -> ../dm-2 lrwxrwxrwx. 1 root root 7 Oct 6 18:28 /dev/mapper/vg02-lv02 -> ../dm-3
合并 VG 的准备工作
在将两个 VG 合并为一个之前,请确保满足以下准备工作。
VG 中的逻辑卷必须是唯一的。
如果需要,可以在移动(合并)之前重命名它们。两个卷组的 PV 盘区大小必须相同
检查确认
验证 VG 和 LV 是否合并。
我们现在应该在同一个 VG 下看到两个 LV。
# vgs VG #PV #LV #SN Attr VSize VFree cl 1 2 0 wz--n- 19.00g 0 vg01 2 2 0 wz--n- 39.99g 19.99g
# lvs LV VG Attr LSize Pool Oroirn Data% Meta% Move Log Cpy%Sync Convert root cl -wi-ao---- 17.00g swap cl -wi-ao---- 2.00g lv01 vg01 -wi-a----- 10.00g lv02 vg01 -wi-a----- 10.00g
# ls -lrt /dev/mapper/* crw-------. 1 root root 10, 236 Oct 6 18:25 /dev/mapper/control lrwxrwxrwx. 1 root root 7 Oct 6 18:25 /dev/mapper/cl-swap -> ../dm-1 lrwxrwxrwx. 1 root root 7 Oct 6 18:25 /dev/mapper/cl-root -> ../dm-0 lrwxrwxrwx. 1 root root 7 Oct 6 18:28 /dev/mapper/vg01-lv01 -> ../dm-2 lrwxrwxrwx. 1 root root 7 Oct 6 18:37 /dev/mapper/vg01-lv02 -> ../dm-3
日期:2020-09-17 00:13:43 来源:oir作者:oir