在使用CentOS6.3版本Linux系统的时候,发现根目录(/)的空间不是很充足,而其他目录空间有很大的空闲,所以本文主要是针对现在已有的空间进行调整。首先,先来查看一下系统的空间分配情况:
[root@CentOS-78 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_centos-lv_root
50G 14G 34G 30% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/vg_centos-lv_home
404G 670M 382G 1% /home
下面的详细步骤部分将从vg_centos-lv_home分区下取出100G的空间添加到/vg_centos-lv_root分区上去。
二、详细步骤
1、卸载vg_centos-lv_home分区
[root@CentOS-78 /]# umount /home
此时在用df命令查看将会发现/home目录已经看不见了,如下所示:
[root@CentOS-78 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_centos-lv_root
50G 14G 34G 30% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
2、从新设定vg_home-lv_home的大小
[root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_home 282G
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/mapper/vg_centos-lv_home' first.
这一步设定vg_home-lv_home大小没有成功,系统提示我们先运行下面的命令,操作如下:
[root@CentOS-78 /]# e2fsck -f /dev/mapper/vg_centos-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/vg_centos-lv_home: 1386/26836992 files (0.9% non-contiguous), 1855856/107344896 blocks
重新设定vg_home-lv_home的大小:
[root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_home 282G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_centos-lv_home to 73924608 (4k) blocks.
Begin pass 2 (max = 43)
Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 3276)
Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 266)
Updating inode references XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/vg_centos-lv_home is now 73924608 blocks long.
检查是否成功:
[root@CentOS-78 /]# mount /home
[root@CentOS-78 /]#
[root@CentOS-78 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_centos-lv_root
50G 14G 34G 30% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/vg_centos-lv_home
278G 663M 263G 1% /home
[root@CentOS-78 /]#