电玩城打鱼捕鱼-专业24小时上下分

centos里挂载另外一块硬盘,Linux下挂载LVM遇到卷组同名的解决方法

七月 12th, 2019  |  电玩城捕鱼系统简介

本人电脑有Windows
XP和CentOS两个系统,因学习需要装了Ubuntu
10.04,不料发现不能加载lvm,故查阅资料,借鉴别人,整理如下:

centos里挂载另外一块硬盘

在centos里试图挂载另外一块硬盘,其中的一个分区是LVM2格式的,不能直接mount,方法记录如下,以备不时之需。

1.首先使用vgscan 扫描 lvm 结果如下

[[email protected]
~]# vgscan
Reading all physical volumes. This may take a while…
WARNING: Duplicate VG name VolGroup00: Existing
bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence
over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
WARNING: Duplicate VG name VolGroup00: Existing
bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence
over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
WARNING: Duplicate VG name VolGroup00: Existing
1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM (created here) takes precedence
over bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh
Found volume group “VolGroup00″ using metadata type lvm2
WARNING: Duplicate VG name VolGroup00: Existing
bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence
over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
Found volume group “VolGroup00″ using metadata type lvm2

2.通过 vgdisplay VolGroup00 查看 lvm 的 VG UUID

[[email protected]
~]# vgdisplay VolGroup00
WARNING: Duplicate VG name VolGroup00: Existing
bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence
over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 129.31 GB
PE Size 32.00 MB
Total PE 4138
Alloc PE / Size 4137 / 129.28 GB
Free PE / Size 1 / 32.00 MB
VG UUID bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh

可以看出当前操作系统使用的VolGroup00的 VG UUID 是
bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh
说明 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM 这个VG UUID
是要另一块硬盘的lvm 分区

3.将第二块硬盘的VG的名字重命名

[[email protected]
~]# vgrename 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM /dev/vg01
WARNING: Duplicate VG name VolGroup00: Existing
bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence
over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
WARNING: Duplicate VG name VolGroup00: Existing
bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence
over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
WARNING: Duplicate VG name VolGroup00: Existing
1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM (created here) takes precedence
over bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh
Volume group “VolGroup00″ successfully renamed to “vg01″

这个时候通过 vgdisplay 就可以看到 VG的信息了

[[email protected]
~]# vgdisplay
— Volume group —
VG Name vg01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 34.50 GB
PE Size 32.00 MB
Total PE 1104
Alloc PE / Size 1103 / 34.47 GB
Free PE / Size 1 / 32.00 MB
VG UUID 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM

— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 129.31 GB
PE Size 32.00 MB
Total PE 4138
Alloc PE / Size 4137 / 129.28 GB
Free PE / Size 1 / 32.00 MB
VG UUID bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh

4.激活VG

VG重命名后,默认是非ACTIVE状态,我们要通过以下方式激活VG

[[email protected]
~]# lvscan
inactive ‘/dev/vg01/LogVol00′ [31.50 GB] inherit
inactive ‘/dev/vg01/LogVol01′ [2.97 GB] inherit
ACTIVE ‘/dev/VolGroup00/LogVol00′ [125.41 GB] inherit
ACTIVE ‘/dev/VolGroup00/LogVol01′ [3.88 GB] inherit

激活 VG
[[email protected]
~]# vgchange -ay /dev/vg01
2 logical volume(s) in volume group “vg01″ now active

查看状态
[[email protected]
~]# lvscan
ACTIVE ‘/dev/vg01/LogVol00′ [31.50 GB] inherit
ACTIVE ‘/dev/vg01/LogVol01′ [2.97 GB] inherit
ACTIVE ‘/dev/VolGroup00/LogVol00′ [125.41 GB] inherit
ACTIVE ‘/dev/VolGroup00/LogVol01′ [3.88 GB] inherit
[[email protected]
~]# vgscan
Reading all physical volumes. This may take a while…
Found volume group “vg01″ using metadata type lvm2
Found volume group “VolGroup00″ using metadata type lvm2

到此为止,可以挂载系统了!

5.挂载lvm文件系统

[[email protected]
mnt]# mount /dev/vg01 /mnt/新建目录

就可以访问了

注:报错时,mount: /dev/vg01 is not a block device,说明
有时vg01可能还有多级目录:如“LogVol01,LogVol00”;需要进入vg01的子目录再挂载。[[email protected]
mnt]# mount /dev/vg01/LogVol01 /mnt/新建目录

linux下lvm分区挂载方法
fdisk -l
//下面会看到所有硬盘的情况,hda是虚拟机自己的硬盘,hdb则是挂载上去的硬盘

周末朋友的服务器硬盘出问题了,让IDC的人挂了个IDE硬盘把系统安装好,然后再挂上以前的SATA硬盘,想把数据倒腾出来,结果哥们发现他搞不定,给我打电话求助。我远程上去看了下,发现2块盘系统做的都是LVM分区格式8e,不是ext3的83,难怪他不会挂载,而且还有个问题就是卷组都是默认安装的同一个名字VolGroup00。

1.首先使用vgscan 扫描 lvm 结果如下

vgscan //扫描所有卷组

[root@locallhost ~]# pvs
  PV         VG         Fmt  Attr PSize   PFree
  /dev/hda2  VolGroup00 lvm2 a-    74.41G    0
  /dev/sda2  VolGroup00 lvm2 a-   232.78G    0

zhq@zhq:/$ sudo vgscan
  Reading all physical volumes.  This may take a while…
  Found volume group “VolGroup00” using metadata type lvm2

vgdisplay //显示出多有卷组信息

hda2是新系统盘74G多,sda2是老数据盘232G多。卷组名称一样,因为2个系统安装的时候都是默认安装的。

2.通过 vgdisplay VolGroup00 查看 lvm 的 VG UUID

vgrename G8ysH1-61Mc-hVQI-YvNk-0301-KgJV-54x9CP vg01 //重新命名挂载盘的卷组名,因为和虚拟机本身的卷组名是一样的所以lvm分区无法挂载,必须改名(要修改挂载盘的卷组名,这里要分编号哪个是挂载上去的),这里的类似于序列号的就是VG UUID,卷组名是一样的,只能靠VG UUID来修改卷组名

看到最下面Volume group “VolGroup00” successfully renamed to
“vg01”则说明改名成功

[root@locallhost ~]# vgs
  VG         #PV #LV #SN Attr   VSize   VFree
  VolGroup00   1   2   0 wz–n- 232.78G    0
  VolGroup00   1   2   0 wz–n-  74.41G    0

zhq@zhq:/$ sudo vgdisplay VolGroup00
  — Volume group —
  VG Name               VolGroup00
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               19.62 GiB
  PE Size               32.00 MiB
  Total PE              628
  Alloc PE / Size       628 / 19.62 GiB
  Free  PE / Size       0 / 0  
  VG UUID               xPw6Yb-1SYW-ayBT-TqOP-hF4i-w02x-vY0165

vgdisplay //可以看到已经有一个改名为vg01

我们先用vgrename改卷组名:

3.重命名(本人认为此步可省,可能是源于简洁吧,呵呵,没试,你可以试试,呵呵)

lvscan //看到上面两个是挂在上去的磁盘,没有激活

[root@locallhost ~]# vgrename VolGroup00
aaalvm
  Found more than one VG called VolGroup00. Please supply VG uuid.

zhq@zhq:/$ sudo vgrename VolGroup00 /dev/vg0
  Volume group “VolGroup00” successfully renamed to “vg0”

vgchange -ay /dev/vg01 //激此卷组

直接报有同名,需要用uuid。查uuid可以用vgdisplay或vgs -v:

这个时候通过 vgdisplay 就可以看到 VG的信息了

lvscan //看下vg01的卷组是否被激活

[root@locallhost ~]# vgdisplay
  — Volume group —
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               232.78 GB
  PE Size               32.00 MB
  Total PE              7449
  Alloc PE / Size       7449 / 232.78 GB
  Free  PE / Size       0 / 0
  VG UUID               bAydq6-rv9e-wCa0-iK2f-zFWn-UBUr-4AR3Ct

zhq@zhq:/$ sudo vgdisplay
  — Volume group —
  VG Name               vg0
  System ID           
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               19.62 GiB
  PE Size               32.00 MiB
  Total PE              628
  Alloc PE / Size       628 / 19.62 GiB
  Free  PE / Size       0 / 0 
  VG UUID               xPw6Yb-1SYW-ayBT-TqOP-hF4i-w02x-vY0165

mkdir /mnt/hdb //新建一个文件夹用来作为挂载点

  — Volume group —
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               74.41 GB
  PE Size               32.00 MB
  Total PE              2381
  Alloc PE / Size       2381 / 74.41 GB
  Free  PE / Size       0 / 0
  VG UUID               YHLmkq-b1xS-UzAS-Y3nv-6vaX-2Xou-GScvk0

标签:

Your Comments

近期评论

    功能


    网站地图xml地图