目录
一、查看卷组信息
查看服务器卷组(VG)、物理卷(PV)、逻辑卷(LV)相关信息。
vgscan:查找系统中存在的LVM卷组。显示卷组名和LVM元数据类型。
vgdisplay:查看卷组详细信息。
pvscan:查看系统中所有连接硬盘,显示出物理卷。
lvscan:查看所有LVM的逻辑卷(LV)。
新增硬盘后,用 fdisk -l 命令,查看新增硬盘。
二、新建一个分区partition
新建一个主分区(primary partition)或逻辑分区(logical partition)
[root@getlnx20 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xaa12f277.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-10443, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-10443, default 10443):
Using default value 10443
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
三、创建物理卷pv
[root@getlnx20 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@getlnx20 ~]# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [39.51 GiB / 0 free]
PV /dev/sdb1 lvm2 [80.00 GiB]
Total: 2 [119.51 GiB] / in use: 1 [39.51 GiB] / in no VG: 1 [80.00 GiB]
四、创建卷组vg
[root@getlnx20 ~]# vgcreate -s 32M VolGroup01 /dev/sdb1
Volume group "VolGroup01" successfully created
[root@getlnx20 ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup01" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2
五、查看vg可用空间
[root@getlnx20 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1