lvm添加同名硬盘及硬盘修复挂载

  • A+
所属分类:Linux

在Linux下使用新硬盘安装系统,安装好以后再挂载原来的硬盘,分区格式全为系统默认分区,系统默认使用的
是lvm格式,并且默认的卷都是 VolGroup00

使用 pvs 查看显示如下:
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 136.62G 0
/dev/sdb2 VolGroup00 lvm2 a- 136.62G 0
发现可以正确认别到两个VG,但是同名,如何挂载呢?
解决办法是,将原来的VG更名,解决冲突即可挂载

重命名格式为:vgrename VolGroup00 VolGroup01 
此时会提示:
[root@localhost ~]# vgrename VolGroup00 VolGroup01
Found more than one VG called VolGroup00. Please supply VG uuid.
原因是存在两个 VolGroup00,修改的方法他已经提示了要指定 VG uuid即可

查看VG uuid的命令为:
[root@localhost ~]# vgs -v
Finding all volume groups
Finding volume group "VolGroup00"
Finding volume group "VolGroup00"
VG Attr Ext #PV #LV #SN VSize VFree VG UUID
VolGroup00 wz--n- 32.00M 1 2 0 136.62G 0 dcHa6G-abU2-Xfq8-EPBm-jBLj-sf18-O5uH0U
VolGroup00 wz--n- 32.00M 1 2 0 136.62G 0 OF8g7h-PQJB-9D9z-yPxn-1kfY-Advq-YbNHJ9

查到VG uuid以后,再次执行改名:
[root@localhost ~]# vgrename OF8g7h-PQJB-9D9z-yPxn-1kfY-Advq-YbNHJ9 VolGroup01
Volume group "VolGroup00" still has active LVs

修改成功以后,再执行:lvscan
[root@localhost ~]# lvscan
inactive '/dev/VolGroup01/LogVol00' [130.84 GB] inherit
inactive '/dev/VolGroup01/LogVol01' [5.78 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [130.84 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [5.78 GB] inherit
可以看到新修改的VolGroup01是inactive状态。
再使用vgchange 加载 VolGroup01
[root@localhost ~]# vgchange -ay /dev/VolGroup01 
2 logical volume(s) in volume group "VolGroup01" now active

然后mount  报如下错误
[root@localhost ~]# mount /dev/VolGroup01/root /mnt/old

mount /dev/VolGroup01/root on /mnt/old failed: Structure needs cleaning

此时修复磁盘

ext4文件系统,使用命令 fsck.ext4 /dev/VolGroup01/root 修复,
如果是xfs文件系统,使用命令 xfs_repair -L /dev/VolGroup01/root 修复,

修复完成在挂载就可以了

[root@localhost ~]# mount /dev/VolGroup01/root /mnt/old

 

 

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: