Linux硬盘UUID相同处理⽅法
OVF模板部署的linux虚拟机磁盘id是相同的,当同⼀个模板⽣成的虚拟机挂载虚拟机磁盘时就会遇到两个磁盘UUID相同的情况,导致系统启动后只能识别⼀个磁盘。这⾥介绍⼀下LVM分区的磁盘UUID相同的处理⽅法
(对于⾮lvm就更简单,直接参考《三、处理分区信息》修改uuid即可。)
⼀、查看磁盘信息
1.1 查看所有分区及uuid信息
(vg的名称为centos,有两个lv,分别是root和swap)
[root@centos7 ~]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 xfs 85082005-65c6-476a-a996-0063d6c395fd
└─sda2 LVM2_member qtCH1O-JNWW-svVN-CF61-OOn7-LxvA-SyOlfs
├─centos-root xfs faf28794-0fba-4753-becf-d47f003630d1 /
└─centos-swap swap e5ca3ca9-0404-4887-b0bd-5a6ab4a6cf64 [SWAP]
sdb
├─sdb1 xfs 85082005-65c6-476a-a996-0063d6c395fd /boot
└─sdb2 LVM2_member qtCH1O-JNWW-svVN-CF61-OOn7-LxvA-SyOlfs
sr0
1.2 查看pv、vg、lv均提⽰“duplicate PVs were found”
[root@centos7 ~]# pvs
WARNING: Not using lvmetad because duplicate PVs were found.
WARNING: Use multipath or vgimportclone to resolve duplicate PVs?
WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.
WARNING: Not using device /dev/sdb2 for PV qtCH1O-JNWW-svVN-CF61-OOn7-LxvA-SyOlfs.
WARNING: PV qtCH1O-JNWW-svVN-CF61-OOn7-LxvA-SyOlfs prefers device /dev/sda2 because device is used by LV.
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <39.00g 4.00m
⼆、激活vg
2.1 因为这两块磁盘(⾮多路径磁盘),所以使⽤vgimportclone处理
[root@centos7 ~]# vgimportclone -n newcentos /dev/sdb2
WARNING: Not using device /dev/sdb2 for PV qtCH1O-JNWW-svVN-CF61-OOn7-LxvA-SyOlfs.
WARNING: PV qtCH1O-JNWW-svVN-CF61-OOn7-LxvA-SyOlfs prefers device /dev/sda2 because device is used by LV.
2.2 启⽤pv
[root@centos7 ~]# pvscan --cache
[root@centos7 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <39.00g 4.00m
/dev/sdb2 newcentos lvm2 a-- <39.00g 4.00m
[root@centos7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <39.00g 4.00m
newcentos 1 2 0 wz--n- <39.00g 4.00m
# 此时“newcentos”的两个lv状态为⾮active
[root@centos7 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <35.00g
swap centos -wi-ao---- <4.00g
root newcentos -wi------- <35.00g
swap newcentos -wi------- <4.00g
[root@centos7 ~]#
2.3 启⽤vg
# active newcentos(a:active 、y:yes、n:no)
[root@centos7 ~]# vgchange newcentos -ay
linux磁盘管理2 logical volume(s) in volume group "newcentos" now active
# 此时lv已经active
[root@centos7 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <35.00g
swap centos -wi-ao---- <4.00g
root newcentos -wi-a----- <35.00g
swap newcentos -wi-a----- <4.00g
三、处理分区信息
3.1 虽然vg显⽰已经正常了,但是挂载lv时依旧失败,⽇志提⽰的内容是uuid相同
[root@centos7 ~]# mount /dev/mapper/newcentos-root /mnt/
mount: wrong fs type, bad option, bad superblock on /dev/mapper/newcentos-root,
missing codepage or helper program, or other error
[root@centos7 ~]# dmesg |tail
[ 854.482564] XFS (dm-3): Filesystem has duplicate UUID faf28794-0fba-4753-becf-d47f003630d1 - can't mount 3.2 通过blkid或者lvdisplay查看uuid会发现“/dev/mapper/centos-root”和“newcentos-root”是⼀样的
[root@centos7 ~]# blkid
/dev/sda1: UUID="85082005-65c6-476a-a996-0063d6c395fd" TYPE="xfs"
/dev/sda2: UUID="qtCH1O-JNWW-svVN-CF61-OOn7-LxvA-SyOlfs" TYPE="LVM2_member"
/dev/sdb1: UUID="85082005-65c6-476a-a996-0063d6c395fd" TYPE="xfs"
/dev/sdb2: UUID="y09RBQ-B06M-8cOP-PR2I-X7k0-4OOw-gbl24f" TYPE="LVM2_member"
/dev/mapper/centos-root: UUID="faf28794-0fba-4753-becf-d47f003630d1" TYPE="xfs"
/dev/mapper/centos-swap: UUID="e5ca3ca9-0404-4887-b0bd-5a6ab4a6cf64" TYPE="swap"
/dev/mapper/newcentos-swap: UUID="e5ca3ca9-0404-4887-b0bd-5a6ab4a6cf64" TYPE="swap"
/dev/mapper/newcentos-root: UUID="faf28794-0fba-4753-becf-d47f003630d1" TYPE="xfs"
3.3 有两种⽅式处理
3.3.1 mount禁⽤uuid
mount -o nouuid /dev/mapper/newcentos-root /mnt
3.3.2 修改uuid
(xfs⽂件系统)
xfs_admin -U generate /dev/mapper/newcentos-root
Clearing log and setting UUID
writing all SBs
(ext2、3、4⽂件系统)
tune2fs /dev/sdc1 -U time
tune2fs 1.42.9 (28-Dec-2013)
clear clear the filesystem UUID
random generate a new randomly-generated UUID
time generate a new time-based UUID
# 再次挂载分区
[root@centos7 ~]# mount /dev/mapper/newcentos-root /mnt
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论