author:headsen chen

date: 2018-04-20  16:48:06

1、查看分区:/home 为67G,太大了,/ 是50g,太小了。
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 1.5G 46G 4% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 477M 36M 416M 8% /boot
/dev/mapper/VolGroup-lv_home
67G 52M 63G 1% /home
2,先卸载/home 分区
[root@localhost ~]# umount /home
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 1.5G 46G 4% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 477M 36M 416M 8% /boot
3,减少lv_home的逻辑卷大小调整为10G
[root@localhost ~]# e2fsck -f /dev/mapper/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/mapper/VolGroup-lv_home: 11/4431872 files (0.0% non-contiguous), 324173/17713152 blocks
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 10G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 2621440 (4k) blocks.
Begin pass 2 (max = 32768)
Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 541)
Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup-lv_home is now 2621440 blocks long.

  4,重新挂载/home分区

[root@localhost ~]# mount /home
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 1.5G 46G 4% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 477M 36M 416M 8% /boot
/dev/mapper/VolGroup-lv_home
9.8G 36M 9.2G 1% /home
[root@localhost ~]# ls /home
lost+found
[root@localhost ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
VolGroup 1 3 0 wz--n- 119.51g 0
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_home VolGroup -wi-ao---- 67.57g
lv_root VolGroup -wi-ao---- 50.00g
lv_swap VolGroup -wi-ao---- 1.94g
5,在逻辑卷里面减少lv的大小
[root@localhost ~]# lvreduce -L -51G /dev/VolGroup/lv_home
  WARNING: Reducing active and open logical volume to 16.57 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Size of logical volume VolGroup/lv_home changed from 67.57 GiB (17298 extents) to 16.57 GiB (4242 extents).
Logical volume lv_home successfully resized
[root@localhost ~]# lvs
  LV      VG       Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
lv_home VolGroup -wi-ao---- 16.57g
lv_root VolGroup -wi-ao---- 50.00g
lv_swap VolGroup -wi-ao---- 1.94g
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup wz--n- .51g .00g

6,增加lv_root的lv
[root@localhost ~]# lvextend -L +50G /dev/VolGroup/lv_root
Size of logical volume VolGroup/lv_root changed from 50.00 GiB ( extents) to 100.00 GiB ( extents).
Logical volume lv_root successfully resized 7,使文件系统重新扫描lv,使修改立即生效。
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 7
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 26214400 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 26214400 blocks long.
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
99G .5G 92G % /
tmpfs 495M 495M % /dev/shm
/dev/sda1 477M 36M 416M % /boot
/dev/mapper/VolGroup-lv_home
.8G 36M .2G % /home
[root@localhost ~]#
05-29 01:17