前言:LVM基本術語
物理存儲介質(The physical media)
這裡指系統的存儲設備:硬盤,如:/dev/hda、/dev/sda等等,是存儲系統最低層的存儲單元。
物理卷(physical volume)
物理卷就是指硬盤分區或從邏輯上與磁盤分區具有同樣功能的設備(如RAID),是LVM的基本存儲邏輯塊,但和基本的物理存儲介質(如分區、磁盤等)比較,卻包含有與LVM相關的管理參數。
卷組(Volume Group)
LVM卷組類似於非LVM系統中的物理硬盤,其由物理卷組成。可以在卷組上創建一個或多個“LVM分區”(邏輯卷),LVM卷組由一個或多個物理卷組成。
邏輯卷(logical volume)
LVM的邏輯卷類似於非LVM系統中的硬盤分區,在邏輯卷之上可以建立文件系統(比如/home或者/usr等)。
PE(physical extent)
每一個物理卷被劃分為稱為PE(Physical Extents)的基本單元,具有唯一編號的PE是可以被LVM尋址的最小單元。PE的大小是可配置的,默認為4MB。
LE(logical extent)
邏輯卷也被劃分為被稱為LE(Logical Extents) 的可被尋址的基本單位。在同一個卷組中,LE的大小和PE是相同的,並且一一對應。
一、創建邏輯卷的步驟
1)通過pvcreate命令將linux分區處理成物理卷(PV);
2)通過vgcreate命令將創建好的物理卷處理成卷組(Vg);
3)通過lvcreate命令將卷組分成若干個邏輯卷(Lv);
之後我們可以對邏輯卷進行格式化,掛載,刪除等操作,我們可以動態的調整邏輯卷的大小,並且該操作不會影響我們在邏輯卷(Lv)上的數據。
二、物理卷創建管理操作
1、物理分區信息
[root@node1 ~]# fdisk /dev/sdd
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sdd: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 200 1606468+ 83 Linux
/dev/sdd2 201 400 1606500 83 Linux
/dev/sdd3 401 600 1606500 83 Linux
/dev/sdd4 601 2610 16145325 5 Extended
/dev/sdd5 601 800 1606468+ 83 Linux
/dev/sdd6 801 1000 1606468+ 83 Linux
/dev/sdd7 1001 1200 1606468+ 83 Linux
/dev/sdd8 1201 1400 1606468+ 83 Linux
/dev/sdd9 1600 1800 1614532+ 83 Linux
/dev/sdd10 1401 1599 1598404+ 83 Linux
/dev/sdd11 1801 2000 1606468+ 83 Linux
/dev/sdd12 2001 2200 1606468+ 83 Linux
/dev/sdd13 2201 2400 1606468+ 83 Linux
/dev/sdd14 2401 2610 1686793+ 83 Linux
Partition table entries are not in disk order
2、創建物理卷
[root@node1 ~]# pvcreate /dev/sdd*
Device /dev/sdd not found (or ignored by filtering).
Physical volume “/dev/sdd1″ successfully created
Physical volume “/dev/sdd10″ successfully created
Physical volume “/dev/sdd11″ successfully created
Physical volume “/dev/sdd12″ successfully created
Physical volume “/dev/sdd13″ successfully created
Physical volume “/dev/sdd14″ successfully created
Physical volume “/dev/sdd2″ successfully created
Physical volume “/dev/sdd3″ successfully created
Device /dev/sdd4 not found (or ignored by filtering).
Physical volume “/dev/sdd5″ successfully created
Physical volume “/dev/sdd6″ successfully created
Physical volume “/dev/sdd7″ successfully created
Physical volume “/dev/sdd8″ successfully created
Physical volume “/dev/sdd9″ successfully created
3、刪除物理卷
[root@node1 ~]# pvremove /dev/sdd1
Labels on physical volume “/dev/sdd1″ successfully wiped
4、添加物理卷
[root@node1 ~]# pvcreate /dev/sdd1
Physical volume “/dev/sdd1″ successfully created
5、查看物理卷信息
[root@node1 ~]# pvscan
PV /dev/sdd1 lvm2 [1.53 GB]
PV /dev/sdd2 lvm2 [1.53 GB]
PV /dev/sdd3 lvm2 [1.53 GB]
PV /dev/sdd5 lvm2 [1.53 GB]
PV /dev/sdd6 lvm2 [1.53 GB]
PV /dev/sdd7 lvm2 [1.53 GB]
PV /dev/sdd8 lvm2 [1.53 GB]
PV /dev/sdd9 lvm2 [1.54 GB]
PV /dev/sdd10 lvm2 [1.52 GB]
PV /dev/sdd11 lvm2 [1.53 GB]
PV /dev/sdd12 lvm2 [1.53 GB]
PV /dev/sdd13 lvm2 [1.53 GB]
PV /dev/sdd14 lvm2 [1.61 GB]
Total: 13 [19.99 GB] / in use: 0 [0 ] / in no VG: 13 [19.99 GB]
6、查看物理卷詳細參數
root@node1 ~]# pvdisplay /dev/sdd5
“/dev/sdd5″ is a new physical volume of “1.53 GB”
— NEW Physical volume —
PV Name /dev/sdd5
VG Name
PV Size 1.53 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 7Ms1jT-wxUI-2d7l-h24c-t17F-J9vL-fz2zHM