首页 > 代码库 > redhat 6.6 重新调整分区大小

redhat 6.6 重新调整分区大小

安装系统的时候贪图省事使用了系统的自动分区,系统装好后发现/home分区太大了,500G的硬盘,400多G的空间分给了/home。需将/home的空间划一点出来,分到根分区下去

df 查看分区

[root@localhost ~]# df
Filesystem           1K-blocks     Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      51475068 10149092  38704536  21% /
tmpfs                 16442092      224  16441868   1% /dev/shm
/dev/sda1               487652    33803    428249   8% /boot
/dev/mapper/VolGroup-lv_home
                     447558496    71768 424745328   1% /home

 

1、卸载/home

umount /home

2、调整/home大小为50G

[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 50G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 13107200 (4k) blocks.
Begin pass 2 (max = 32768)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 3471)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup-lv_home is now 13107200 blocks long.

3、挂载/home后df查看大小

root@localhost ~]#mount /home

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G  9.7G   37G  21% /
tmpfs                  16G  224K   16G   1% /dev/shm
/dev/sda1             477M   34M  419M   8% /boot
/dev/mapper/VolGroup-lv_home
                       50G   52M   47G   1% /home

4、收缩/home大小为50G,释放其余空间。需按y确认

[root@localhost ~]# lvreduce -L 50G /dev/mapper/VolGroup-lv_home
  WARNING: Reducing active and open logical volume to 50.00 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 433.76 GiB (111042 extents) to 50.00 GiB (12800 extents).
  Logical volume lv_home successfully resized

5、查剩余空间大小

[root@localhost ~]# 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               499.51 GiB
  PE Size               4.00 MiB
  Total PE              127874
  Alloc PE / Size       29632 / 115.75 GiB
  Free  PE / Size       98242 / 383.76 GiB
  VG UUID               4cl81Y-e6zg-EnAr-xkKb-XkYQ-QGBv-2SJMe3

6、将剩余空间划分到/目录下,即/dev/mapper/VolGroup-lv_root

[root@localhost ~]# lvextend -L +380G /dev/mapper/VolGroup-lv_root
  Size of logical volume VolGroup/lv_root changed from 50.00 GiB (12800 extents) to 430.00 GiB (110080 extents).
  Logical volume lv_root successfully resized

7、重新设置/分区大小,使扩展的空间生效

[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 = 27
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 112721920 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 112721920 blocks long.

8、查看分区大小确认

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      424G  9.7G  392G   3% /
tmpfs                  16G  224K   16G   1% /dev/shm
/dev/sda1             477M   34M  419M   8% /boot
/dev/mapper/VolGroup-lv_home
                       50G   52M   47G   1% /home

redhat 6.6 重新调整分区大小