LVM 教學
參考 : http://linux.vbird.org/linux_basic/0420quota.php#lvmhttp://linux.vbird.org/linux_basic/0230filesystem.php#gdisk
[彈性放大LV容量]
1) lvextend -l 178813 /dev/11HD_vg/11HD_lv
178813是欲加大的size,如2.7T=178813 PE, 1 PE=16MB
2)lvresize -l 1966943 /dev/11HD_vg/11HD_lv
1966943是加大後的總size,如30T=1966943 PE , 可以用 vgdisplay 11HD_vg 查目前的 vg 詳細資料,包含total size and free size ,單位都是 PE
3)resize2fs /dev/11HD_vg/11HD_lv
P.S假如找不到gdisk指令,使用 yum install gdisk 安裝
使用 gdisk 分割磁區時,
Hex code or GUID (L to show codes, Enter = 8300):輸入8e00===> LVM (logical volumn manager)
[移除pv]
pvscan or pvdisplay 毀損的硬碟會顯示:
Couldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3
PV Name unknown device
由於硬碟毀損,紀錄還留在VG內,因此需移除 PV:
vgreduce --removemissing --force 11HD_vg#但也會把所有 LV刪除,故須重建 LV
pvscan or pvdisplay 就不會顯示 "unknown device"
[如何mount 已存在於一顆硬碟內之LVM的partition]
#pvscan
PV /dev/sdc2 VG vg_centos6 lvm2 <===== 吾人想要mount 的LVM (已存在於別顆硬碟)
PV /dev/sdb2 VG vg_test lvm2
Total: 2 / in use: 2 / in no VG: 0
#vgscan
Reading all physical volumes.This may take a while...
Found volume group "vg_centos6" using metadata type lvm2
Found volume group "vg_test" using metadata type lvm2
#lvscan
inactive '/dev/vg_centos6/lv_root' inherit <====未啟用
inactive '/dev/vg_centos6/lv_swap' inherit <====未啟用
ACTIVE '/dev/vg_test/lv_root' inherit
ACTIVE '/dev/vg_test/lv_swap' inherit
#lvdisplay /dev/vg_centos6/lv_root
--- Logical volume ---
LV Path /dev/vg_centos6/lv_root
LV Name lv_root
VG Name vg_centos6
LV UUID 0nFiiu-yDQG-1JUB-JI2r-uoTe-Hupi-WGisCe
LV Write Access read/write
LV Creation host, time ,
LV Status unavailable <==== 不可用
# open 1
LV Size 21.84 GiB
Current LE 5591
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
重點在這裡:
vgchange -ay vg_centos6 <====== 啟動 VG (假如 關閉VG ==> vgchange -an vg_centos6)
再查一次 LV:
#lvscan
ACTIVE '/dev/vg_centos6/lv_root' inherit<====已啟動了
ACTIVE '/dev/vg_centos6/lv_swap' inherit<====已啟動了
ACTIVE '/dev/vg_test/lv_root' inherit
ACTIVE '/dev/vg_test/lv_swap' inherit
mount LVM:
mkdir /mnt/lvmdisk
mount /dev/vg_centos6/lv_root/mnt/lvmdisk
大功告成!
頁:
[1]