在centos裡試圖掛載另外一塊硬盤,其中的一個分區是LVM2格式的,不能直接mount,方法記錄如下,以備不時之需。
1.首先使用vgscan 掃描 lvm 結果如下
[root@localhost ~]# 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
[root@localhost ~]# 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的名字重命名
[root@localhost ~]# 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的信息了
[root@localhost ~]# 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
[root@localhost ~]# 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
[root@localhost ~]# vgchange -ay /dev/vg01
2 logical volume(s) in volume group “vg01″ now active
查看狀態
[root@localhost ~]# 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
[root@localhost ~]# 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文件系統
[root@localhost mnt]# mount /dev/vg01 /mnt/新建目錄
就可以訪問了
注:報錯時,mount: /dev/vg01 is not a block device,說明 有時vg01可能還有多級目錄:如“LogVol01,LogVol00”;需要進入vg01的子目錄再掛載。[root@localhost mnt]# mount /dev/vg01/LogVol01 /mnt/新建目錄
linux下lvm分區掛載方法
fdisk -l //下面會看到所有硬盤的情況,hda是虛擬機自己的硬盤,hdb則是掛載上去的硬盤
看到最下面Volume group “VolGroup00” successfully renamed to “vg01”則說明改名成功
使用完以後要卸載
修改過卷組名的這個硬盤是不能再啟動了,應為默認啟動引導是引導到VolGroup00卷組的,所以修改過卷組名的硬盤要想仍能重新啟動的話,必須把卷組名修改會默認的VolGroup00
但是在已經有VolGroup00卷組的虛擬機上是不能修改的!這裡我們單獨建立一個分區格式不是linux lvm格式的虛擬機來掛載硬盤,其格式為ext3的(顯示為linux)
在ext3格式分區的虛擬機上直接掛載linux lvm分區的硬盤的方法如下:
http://xxxxxx/Linuxjc/1134169.html TechArticle