标签:logic swap release host 安装 sector div ted 格式化
系统环境:CentOS Linux release 7.3.1611 (Core) 3.10.0-514.el7.x86_64
CentOS6与7配置方法大同小异。通常是在系统安装的时候创建lvm,然后在后期进行动态扩展分区容量。
安装lvm2
# yum install lvm2
创建初始化物理卷,物理卷可以是一个分区,也可以是一整块硬盘
# pvcreate /dev/sda2
查看物理卷
[root@centos7 etc]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 cl lvm2 a-- 29.00g 4.00m [root@centos7 etc]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name cl PV Size 29.00 GiB / not usable 3.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 7423 Free PE 1 Allocated PE 7422 PV UUID TN6Hvw-4C4D-pceR-Beqx-CTUm-7L7b-8oFozr
创建卷组,可指定多个硬盘
# vgcreate VGNAME /dev/sda2
查看卷组
[root@centos7 etc]# vgs VG #PV #LV #SN Attr VSize VFree cl 1 2 0 wz--n- 29.00g 4.00m [root@centos7 etc]# vgdisplay --- Volume group --- VG Name cl System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 29.00 GiB PE Size 4.00 MiB Total PE 7423 Alloc PE / Size 7422 / 28.99 GiB Free PE / Size 1 / 4.00 MiB VG UUID 3Wspeg-DuBe-V4yu-QuIk-90eS-D0TC-FLwOaU
创建逻辑卷
# lvcreate -n LVNAME -L 20G VGNAME
查看逻辑卷
[root@centos7 etc]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root cl -wi-ao---- 26.99g swap cl -wi-ao---- 2.00g [root@centos7 etc]# lvdisplay --- Logical volume --- LV Path /dev/cl/swap LV Name swap VG Name cl LV UUID 2TMxpT-Ed6t-OJNr-rKbJ-Fep6-3kQO-A30ntK LV Write Access read/write LV Creation host, time localhost.localdomain, 2017-09-04 15:30:26 +0800 LV Status available # open 2 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/cl/root LV Name root VG Name cl LV UUID UfjHjv-bWzI-FMKs-ze0A-7GoI-Z3ho-oguZ61 LV Write Access read/write LV Creation host, time localhost.localdomain, 2017-09-04 15:30:26 +0800 LV Status available # open 1 LV Size 26.99 GiB Current LE 6910 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
格式化逻辑卷并挂载使用
# mkfs.ext4 /dev/VGNAME/LVNAME # mount /dev/VGNAME/LVNAME /mnt
删除lvm,先后顺序lv->vg->pv
# lvremove /dev/VGNAME/LVNAME
# vgremove VGNAME
# pvremove /dev/sdb
新增物理卷
# pvcreate /dev/sdd
新增物理卷到卷组
# vgextend VGNAME /dev/sdd
增加逻辑卷容量,增加逻辑卷容量的操作是热操作,无需停用任何设备或分区
# lvextend -L +10G /dev/VGNAME/LVNAME #增加10G到LVNAME卷中 # lvextend -l +100%FREE /dev/VGNAME/LVNAME #增加剩余所有容量到卷中
更新文件系统之后,新增容量才能生效
# resize2fs /dev/VGNAME/LVNAME #适用于ext2、3、4文件系统 # xfs_growfs /dev/VGNAME/LVNAME #适用于xfs文件系统
卸载逻辑卷。要执行逻辑卷缩小操作,必须先取消挂载,且操作顺序必须是umount>resize2fs>lvreduce
# umount /dev/VGNAME/LVNAME
重新指定逻辑卷大小
# resize2fs /dev/VGNAME/LVNAME 10G
把逻辑卷减少9G容量,为防数据丢失,减少的容量尽量少于实际计算的减少容量
# lvreduce -L -9G /dev/VGNAME/LVNAME
把逻辑卷减少到9G,缩小后的容量必须大于已经使用的空间
# lvreduce -L 9G /dev/VGNAME/LVNAME
重新挂载逻辑卷
# mount /dev/VGNAME/LVNAME /mnt
缩小卷组容量,退出物理卷(物理硬盘)。缩小前确认vg空闲空间大于/dev/sdd,否则可能造成数据丢失
# vgreduce VGNAME /dev/sdd
# pvremove /dev/sdd
标签:logic swap release host 安装 sector div ted 格式化
原文地址:http://www.cnblogs.com/st-jun/p/7737507.html