3.8. 将卷组移动到另一个系统中
您可以使用以下命令将整个 LVM 卷组(VG)移动到另一个系统:
vgexport- 在现有系统上使用此命令使系统无法访问不活跃的 VG。一旦 VG 无法访问,您可以分离其物理卷(PV)。
vgimport- 在其他系统上使用以下命令使在旧系统中不活跃的 VG 在新系统中可访问。
先决条件
- 没有用户正在访问您要移动的卷组中活动卷上的文件。
流程
卸载 LogicalVolumeName 逻辑卷:
# umount /mnt/LogicalVolumeName停用激活卷组中的所有逻辑卷,这可防止卷组上的任何进一步活动:
# vgchange -an VolumeGroupName 0 logical volume(s) in volume group "VolumeGroupName" now active导出卷组,以防止其被您要删除它的系统访问:
# vgexport VolumeGroupName Volume group "VolumeGroupName" successfully exported查看导出的卷组:
# pvscan PV /dev/sda1 is in exported VG VolumeGroupName [17.15 GB / 7.15 GB free] PV /dev/sdc1 is in exported VG VolumeGroupName [17.15 GB / 15.15 GB free] PV /dev/sdd1 is in exported VG VolumeGroupName [17.15 GB / 15.15 GB free] ...- 关闭您的系统,拔出组成卷组的磁盘,并将其连接到新系统。
将磁盘插入新系统,并导入卷组使其可以被新系统访问:
# vgimport VolumeGroupName注意您可以使用
vgimport命令的--force参数导入缺少物理卷的卷组,然后运行vgreduce --removemissing命令。激活卷组:
# vgchange -ay VolumeGroupName挂载文件系统使其可使用:
# mkdir -p /mnt/VolumeGroupName/users # mount /dev/VolumeGroupName/users /mnt/VolumeGroupName/users