3.8. 将卷组移动到另一个系统中
您可以使用以下命令将整个 LVM 卷组(VG)移到另一个系统中:
vgexport
- 在现有系统上使用此命令使系统无法访问不活跃的 VG。一旦 VG 无法访问,您可以分离其物理卷(PV)。
vgimport
- 在其他系统上使用以下命令使在旧系统中不活跃的 VG 在新系统中可访问。
先决条件
- 没有用户正在访问您要移动的卷组中活动卷上的文件。
流程
卸载 LogicalVolumeName 逻辑卷:
# umount /dev/mnt/LogicalVolumeName
停用激活卷组中的所有逻辑卷,这可防止卷组上的任何进一步活动:
# vgchange -an VolumeGroupName vgchange -- volume group "VolumeGroupName" successfully deactivated
导出卷组以防止您要将其从中删除的系统访问:
# vgexport VolumeGroupName vgexport -- 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
其他资源
-
vgimport (8)
,vgexport (8)
, 和vgchange (8)
man page