相关构架
PE:物理块 默认4M大小
PV:物理卷
VG:卷组
LV:逻辑卷
LE:可被寻址的基本单位,在同一个卷组中,LE的大小和PE是相同的,并且一一对应
LVM相关管理命令
1.pv命令
pvcreate:创建PV
pvcreate device
pvdisplay:查看命令
pvs:查看
pvscan:扫描物理卷
pvremove 移除物理卷
pvmove:将pv中的数据挪移到其他pv中
2.vg命令
vgcreate
vgcreate vgname /dev/sd....(divce)
-s: 用来指定PE大小
vgextend:扩容
vgreduce:删除
vgremove:删除卷组
vgs:查看
vgdisplay:查看命令
vgrename
3.lv命令:
lvcreate:
-n:指定逻辑卷名称
-L:指定逻辑卷大小 #绝对容量 +# 增量
-l:指定逻辑卷大小 指定使用PE个数
-s:创建快照
-p:设置属性 r
lvextend
lvreduce
lvrename
lvs
lvdisplay
lvremove
lvconvert:拍照
lv缩减:
1、卸载逻辑卷
2、强制检测磁盘剩余空间
3、使用resize2fs缩减文件系统
4、再使用lvreduce命令缩减逻辑卷
5、再挂载使用
文件系统大小需要和逻辑卷大小一致
删除逻辑卷
1、卸载逻辑卷
2、lvremove删除逻辑卷,删除之前一定要删除掉/etc/fstab中记录的挂载信息
3、vgremove删除卷组
4、pvremove删除物理卷
lvm创建
新建分区(在这里我建了四个分区:sdb1,sdb2,sdb3,sdb4 100M)
[root@localhost ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@localhost ~]# 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 0xb05ef01e.
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 e