author:headsen chen
date:2019-03-18 14:48:17
1,查看分区状态,发现/ 分区不够用。/home分区太大了。浪费
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 1.8G 49G 2% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 477M 40M 412M 9% /boot
/dev/mapper/VolGroup-lv_home
65G 32M 61.6G 1% /home
2,卸载 /home分区
[[email protected] ~]# umount /home
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 1.8G 45G 4% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 477M 40M 412M 9% /boot
假如要是无法卸载:使用 fuse -km /home 强制杀死站用该/home 分区的进程
查看总的lv的情况
[[email protected] ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_home VolGroup -wi-a----- 65.65g
lv_root VolGroup -wi-ao---- 50.00g
lv_swap VolGroup -wi-ao---- 3.86g
设置文件系统下的 /lv_home分区的大小为5G
[[email protected] ~]# resize2fs -p /dev/VolGroup/lv_home 5G resize2fs 1.41.12 (17-May-2010) Please run 'e2fsck -f /dev/VolGroup/lv_home' first. [[email protected] ~]# e2fsck -f /dev/VolGroup/lv_home e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/VolGroup/lv_home: 11/4308992 files (0.0% non-contiguous), 316463/17209344 blocks [[email protected] ~]# resize2fs -p /dev/VolGroup/lv_home 5G resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/VolGroup/lv_home to 1310720 (4k) blocks. Begin pass 2 (max = 32768) Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 3 (max = 526) Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The filesystem on /dev/VolGroup/lv_home is now 1310720 blocks long.
挂载 /home 分区
[[email protected] ~]# mount /dev/VolGroup/lv_home
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 1.8G 45G 4% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 477M 40M 412M 9% /boot
/dev/mapper/VolGroup-lv_home
4.8G 32M 4.6G 1% /home
但此时的lv配置并没有改变:
[[email protected] ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_home VolGroup -wi-ao---- 65.65g
lv_root VolGroup -wi-ao---- 50.00g
lv_swap VolGroup -wi-ao---- 3.86g
修改lv的配置大小为5G
[[email protected] ~]# lvreduce -L 5G /dev/VolGroup/lv_home # 设置lv_home 大小为5g WARNING: Reducing active and open logical volume to 5.00 GiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce VolGroup/lv_home? [y/n]: y Size of logical volume VolGroup/lv_home changed from 60.00 GiB (15360 extents) to 5.00 GiB (1280 extents). Logical volume lv_home successfully resized. [[email protected] ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert lv_home VolGroup -wi-ao---- 5.00g lv_root VolGroup -wi-ao---- 50.00g lv_swap VolGroup -wi-ao---- 3.86g [[email protected] ~]# vgs VG #PV #LV #SN Attr VSize VFree VolGroup 1 3 0 wz--n- 119.51g 60.65g
增加/lv_root 的大小:60g
[[email protected] ~]# lvextend -L +60G /dev/VolGroup/lv_root Size of logical volume VolGroup/lv_root changed from 50.00 GiB (12800 extents) to 80.00 GiB (20480 extents). Logical volume lv_root successfully resized. [[email protected] ~]# resize2fs -p /dev/VolGroup/lv_root resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required old desc_blocks = 4, new_desc_blocks = 5 Performing an on-line resize of /dev/VolGroup/lv_root to 20971520 (4k) blocks. The filesystem on /dev/VolGroup/lv_root is now 20971520 blocks long.
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
109G 1.8G 103G 3% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 477M 40M 412M 9% /boot
/dev/mapper/VolGroup-lv_home
4.8G 32M 4.6G 1% /home
[[email protected] ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 3 0 wz--n- 119.51g 664.00m
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/2169.html