一、需求
- 使用4个partition,每个partition的容量均在1GB左右,且systemID需要为8e;
- 全部的partition整合成为一个VG,VG名称设定为vbirdvg;且PE的大小为16GB;
- 建立一个名为vbirdlv的LV,容量大约为2G;
- 最终这个LV格式化为xfs的文件系统,且挂载在/srv/lvm中
二、gdisk分区
[root@study ~]# gdisk /dev/sda #使用gdisk进行分区
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): n
Partition number (4-128, default 4): #默认值
First sector (34-83886046, default = 65026048) or {+-}size{KMGTP}: +1gb #1gb大小
Last sector (67123200-83886046, default = 83886046) or {+-}size{KMGTP}: +1gb
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00 #8e00:Linux LVM
Changed type of partition to 'Linux LVM'
#重复4次,w写入并退出
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
三、建立PV(Physical Volume)
- pvcreate 将实体partition建立成为PV
- pvscan 搜寻目前系统里面任何具有PV的磁盘
- pvdisplay 显示出目前系统上面的PV状态
- pvremove 将PV属性移除,让该partition不具有PV属性
#1.将/dev/sda{4-7}建立成PV格式
[root@study ~]# pvcreate /dev/sda{4,5,6,7}
Physical volume "/dev/sda4" successfully created.
Physical volume "/dev/sda5" successfully created.
Physical volume "/dev/sda6" successfully created.
Physical volume "/dev/sda7" successfully created.
#2.查看一下里面具有PV状态的磁盘
[root@study ~]# pvscan
PV /dev/sda3 VG centos lvm2 [30.00 GiB / 14.00 GiB free]
PV /dev/sda6 lvm2 [1.00 GiB]
PV /dev/sda7 lvm2 [1.00 GiB]
PV /dev/sda5 lvm2 [1.00 GiB]
PV /dev/sda4 lvm2 [1.00 GiB]
Total: 5 [34.00 GiB] / in use: 1 [30.00 GiB] / in no VG: 4 [4.00 GiB]
#3.更详细列出系统上每个PV的信息
[root@study ~]# pvdisplay /dev/sda4
"/dev/sda4" is a new physical volume of "1.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sda4
VG Name
PV Size 1.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 1hANDP-PL30-wed0-3Z61-8VG0-jfwf-NEqfBb
四、建立VG(Volume Groups)
- vgcreate 建立vg的指令
- vgscan