cp文件时,查看磁盘,发现根目录满了,下面对根目录开始扩容
[root@b2g9855 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup-root 20G 20G 0 100% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 386M 3.5G 10% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 283M 138M 126M 53% /boot
/dev/mapper/VolGroup-home 9.8G 2.4G 6.9G 26% /home
tmpfs 783M 4.0K 783M 1% /run/user/42
tmpfs 783M 48K 783M 1% /run/user/0
/dev/mapper/VolGroup-data 246G 139G 96G 60% /data01
10.12.71.210:/backup 100G 72G 23G 77% /mnt
扩容前需先确认,逻辑卷是否还有空闲的空间(没有就不能扩容)
方法一:
(看 VFree)
[root@b2g9855 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 4 0 wz--n- <349.70g <61.70g
方法二:
(看 Free PE / Size)
[root@b2g9855 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 2
Act PV 2
VG Size <349.70 GiB
PE Size 4.00 MiB
Total PE 89523
Alloc PE / Size 73728 / 288.00 GiB
Free PE / Size 15795 / <61.70 GiB
VG UUID cDHieE-hcgA-scgA-gXd9-DCvY-m8Bx-wo7WI9
lvextend是扩展逻辑卷,lvreduce是缩小逻辑卷,lvresize是扩展或缩小逻辑
使用 lvextend 命令扩容失败(分区爆满了,写不进去了,也可以尝试删除一些不要的文件,再扩容命令)
[root@b2g9855 ~]# lvextend -L +20G /dev/mapper/VolGroup-root
/etc/lvm/archive/.lvm_b2g9855_30812_709373585: write error failed: 设备上没有空间
[root@b2g9855 ~]# lvextend -L +2G /dev/mapper/VolGroup-root
/etc/lvm/archive/.lvm_b2g9855_30989_517224891: write error failed: 设备上没有空间
[root@b2g9855 ~]#
[root@b2g9855 ~]# cd /tm-bash: 无法为立即文档创建临时文件: 设备上没有空间
-bash: cd: /tm: 不是目录
使用 lvresize 扩容成功
[root@b2g9855 backup]# lvresize -A n -L +42G /dev/mapper/VolGroup-root
Size of logical volume VolGroup/root changed from 20.00 GiB (5120 extents) to 62.00 GiB (15872 extents).
WARNING: This metadata update is NOT backed up.
Logical volume VolGroup/root successfully resized.
使扩容生效
[root@b2g9855 backup]#
[root@b2g9855 backup]# resize2fs -p /dev/mapper/VolGroup-root
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/VolGroup-root is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 8
The filesystem on /dev/mapper/VolGroup-root is now 16252928 blocks long.
再次查看更目录,容量增加了
[root@b2g9855 backup]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup-root 61G 20G 39G 34% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 386M 3.5G 10% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 283M 138M 126M 53% /boot
/dev/mapper/VolGroup-home 9.8G 2.4G 6.9G 26% /home
tmpfs 783M 4.0K 783M 1% /run/user/42
tmpfs 783M 48K 783M 1% /run/user/0
/dev/mapper/VolGroup-data 246G 139G 96G 60% /data01
10.12.71.210:/backup 100G 72G 23G 77% /mnt
[root@b2g9855 backup]# lvresize -A n -L -22G /dev/mapper/VolGroup-root
再次查看逻辑盘,未分配的空间减少了
[root@b2g9855 backup]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 4 0 wz--n- <349.70g <19.70g
网友评论