周末朋友的服務器硬盤出問題了,讓IDC的人掛了個IDE硬盤把系統安裝好,然後再掛上以前的SATA硬盤,想把數據倒騰出來,結果哥們發現他搞不定,給我打電話求助。我遠程上去看了下,發現2塊盤系統做的都是LVM分區格式8e,不是ext3的83,難怪他不會掛載,而且還有個問題就是卷組都是默認安裝的同一個名字VolGroup00。
[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
hda2是新系統盤74G多,sda2是老數據盤232G多。卷組名稱一樣,因為2個系統安裝的時候都是默認安裝的。
[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
我們先用vgrename改卷組名:
[root@locallhost ~]# vgrename VolGroup00 aaalvm
Found more than one VG called VolGroup00. Please supply VG uuid.
直接報有同名,需要用uuid。查uuid可以用vgdisplay或vgs -v:
[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
--- 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
[root@locallhost ~]# vgs -v
Finding all volume groups
Finding volume group "VolGroup00"
Archiving volume group "VolGroup00" metadata (seqno 3).
Archiving volume group "VolGroup00" metadata (seqno 3).
Creating volume group backup "/etc/lvm/backup/VolGroup00" (seqno 3).
Finding volume group "VolGroup00"
Archiving volume group "VolGroup00" metadata (seqno 3).
Archiving volume group "VolGroup00" metadata (seqno 3).
Creating volume group backup "/etc/lvm/backup/VolGroup00" (seqno 3).
VG Attr Ext #PV #LV #SN VSize VFree VG UUID
VolGroup00 wz--n- 32.00M 1 2 0 232.78G 0 bAydq6-rv9e-wCa0-iK2f-zFWn-UBUr-4AR3Ct
VolGroup00 wz--n- 32.00M 1 2 0 74.41G 0 YHLmkq-b1xS-UzAS-Y3nv-6vaX-2Xou-GScvk0
查到數據盤的uuid是bAydq6-rv9e-wCa0-iK2f-zFWn-UBUr-4AR3Ct,改卷組名的時候用uuid,如下:
[root@locallhost ~]# vgrename bAydq6-rv9e-wCa0-iK2f-zFWn-UBUr-4AR3Ct aaalvm
Volume group "VolGroup00" successfully renamed to "aaalvm"
ok了,改完再vgs看下:
[root@locallhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 1 2 0 wz--n- 74.41G 0
aaalvm 1 2 0 wz--n- 232.78G 0
沒問題了,再lvscan下:
[root@locallhost ~]# lvscan
inactive '/dev/aaalvm/LogVol00' [228.84 GB] inherit
inactive '/dev/aaalvm/LogVol01' [3.94 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [70.47 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [3.94 GB] inherit
已經看到新改名的卷組是inactive了,2個分區LogVol00和LogVol01,用vgchange加載我們該名過的aaalvm卷組:
[root@locallhost ~]# vgchange -ay /dev/aaalvm
2 logical volume(s) in volume group "aaalvm" now active
提示active狀態成功,最後mount文件系統:
[root@locallhost ~]# ls /dev/aaalvm/
LogVol00 LogVol01
[root@locallhost ~]# mount /dev/aaalvm/LogVol00 /aaaa/
[root@locallhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
69G 2.7G 63G 5% /
/dev/hda1 99M 12M 82M 13% /boot
tmpfs 1010M 0 1010M 0% /dev/shm
/dev/mapper/aaalvm-LogVol00
222G 111G 100G 53% /aaaa
[root@locallhost ~]# mount /dev/aaalvm/LogVol01 /bbb/
/dev/aaalvm/LogVol01 looks like swapspace - not mounted
mount: you must specify the filesystem type
LogVol01是swap分區,不用掛載。把/bin/mount /dev/aaalvm/LogVol00 /aaaa/寫入rc.local裡面,讓每次開機自動掛載,也可以寫到fstab裡面,但是如果寫錯出問題可能導致進不了系統,所以建議寫rc.local。