1 在vmware安装系统的时候使用了系统的自动分区,系统装好后发现/home分区太大了30G,使得/root下不够用。需将/home的空间划一点出来,分到根分区下去。
1.查看分区信息#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 7.7G 39G 17% /
tmpfs 932M 292K 932M 1% /dev/shm
/dev/sda1 477M 42M 410M 10% /boot
/dev/mapper/VolGroup-lv_home
33G 348M 31G 2% /home
.host:/ 98G 64G 35G 66% /mnt/hgfs
/dev/sr0 3.7G 3.7G 0 100% /media/RHEL-6.8 Server.x86_64
2.卸载/home
#umount /home
3.调整/home大小为20G
# resize2fs -p /dev/mapper/VolGroup-lv_home 20G
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/mapper/VolGroup-lv_home' first.
注:如果出现上面提示,请执行#e2fsce2fsck 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: 4372/2203648 files (0.2% non-contiguous), 260035/8808448 blocks
k -f /dev/mapper/VolGroup-lv_home
继续执行#resize2fs -p /dev/mapper/VolGroup-lv_home 20G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 5242880 (4k) blocks.
Begin pass 2 (max = 53699)
Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 269)
Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 985)
Updating inode references XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup-lv_home is now 5242880 blocks long.
4.挂载/home后并df查看大小
#mount /home
#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 7.7G 39G 17% /
tmpfs 932M 292K 932M 1% /dev/shm
/dev/sda1 477M 42M 410M 10% /boot
.host:/ 98G 64G 35G 66% /mnt/hgfs
/dev/sr0 3.7G 3.7G 0 100% /media/RHEL-6.8 Server.x86_64
/dev/mapper/VolGroup-lv_home
20G 344M 19G 2% /home
5.收缩/home大小为20G,释放其余空间。需按y确认
#lvreduce -L 20G /dev/mapper/VolGroup-lv_home
WARNING: Reducing active and open logical volume to 20.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 33.60 GiB (8602 extents) to 20.00 GiB (5120 extents).
Logical volume lv_home successfully resized.
6.查剩余空间大小
#vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 87.51 GiB
PE Size 4.00 MiB
Total PE 22402
Alloc PE / Size 18920 / 73.91 GiB
Free PE / Size 3482 / 13.60 GiB
VG UUID k74r18-xXPi-2sVI-JUYn-QZuF-8JcC-OcZ28W
7.将剩余空间划分到/目录下,即/dev/mapper/VolGroup-lv_root
#lvextend -L +13G /dev/mapper/VolGroup-lv_root
Size of logical volume VolGroup/lv_root changed from 50.00 GiB (12800 extents) to 63.00 GiB (16128 extents).
Logical volume lv_root successfully resized.
8.重新设置/分区大小,使扩展的空间生效
[root@localhost hyl]# 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 = 4
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 16515072 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 16515072 blocks long.
9.查看确认分区大小
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
62G 7.8G 52G 14% /
tmpfs 932M 292K 932M 1% /dev/shm
/dev/sda1 477M 42M 410M 10% /boot
.host:/ 98G 64G 35G 66% /mnt/hgfs
/dev/sr0 3.7G 3.7G 0 100% /media/RHEL-6.8 Server.x86_64
/dev/mapper/VolGroup-lv_home
20G 344M 19G 2% /home
至此,完成了将/home的空间分到/root下的操作。