LVM在线扩容:
[root@centos7 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 9.3G 1.1G 8.3G 12% /
devtmpfs 982M 0 982M 0% /dev
tmpfs 993M 0 993M 0% /dev/shm
tmpfs 993M 8.6M 984M 1% /run
tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda1 197M 103M 95M 53% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/mapper/vg1_demo-lv1 27M 779K 24M 4% /app
[root@centos7 ~]# dd if=/dev/zero of=/app/aa.txt bs=1M count=23
23+0 records in
23+0 records out
24117248 bytes (24 MB) copied, 0.0563617 s, 428 MB/s
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 9.3G 1.1G 8.3G 12% /
devtmpfs 982M 0 982M 0% /dev
tmpfs 993M 0 993M 0% /dev/shm
tmpfs 993M 8.6M 984M 1% /run
tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda1 197M 103M 95M 53% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/mapper/vg1_demo-lv1 27M 24M 1007K 97% /app
[root@centos7 ~]#
扩容前先看下是否有剩余的空间:
[root@centos7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 9.80g 0
vg1_demo 2 1 0 wz--n- 544.00m 460.00m
[root@centos7 ~]#
lv扩容40M
[root@centos7 ~]# lvextend -L +40M /dev/mapper/vg1_demo-lv1
lv扩容到40M
[root@centos7 ~]# lvextend -L 40M /dev/mapper/vg1_demo-lv1
[root@centos7 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 9.30g
swap centos -wi-ao---- 512.00m
lv1 vg1_demo -wi-ao---- 72.00m
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]# lvextend -L +10M /dev/mapper/vg1_demo-lv1
Rounding size to boundary between physical extents: 12.00 MiB.
Size of logical volume vg1_demo/lv1 changed from 72.00 MiB (18 extents) to 84.00 MiB (21 extents).
Logical volume vg1_demo/lv1 successfully resized.
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 9.30g
swap centos -wi-ao---- 512.00m
lv1 vg1_demo -wi-ao---- 84.00m
[root@centos7 ~]#
扩容后需要对扩容的部分LV,在线格式化
[root@centos7 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 9.3G 1.1G 8.3G 12% /
devtmpfs 982M 0 982M 0% /dev
tmpfs 993M 0 993M 0% /dev/shm
tmpfs 993M 8.6M 984M 1% /run
tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda1 197M 103M 95M 53% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/mapper/vg1_demo-lv1 27M 24M 1007K 97% /app
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]# resize2fs /dev/mapper/vg1_demo-lv1 注:如果是xfs 文件系统就用:xfs_growfs /dev/mapper/vg1_demo-lv1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/vg1_demo-lv1 is mounted on /app; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mapper/vg1_demo-lv1 is now 86016 blocks long.
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 9.3G 1.1G 8.3G 12% /
devtmpfs 982M 0 982M 0% /dev
tmpfs 993M 0 993M 0% /dev/shm
tmpfs 993M 8.6M 984M 1% /run
tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda1 197M 103M 95M 53% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/mapper/vg1_demo-lv1 78M 25M 49M 34% /app
[root@centos7 ~]#