> CentOS > CentOS入门 >

CentOS下把home空间的分出来给root

Centos 系统扩展VolGroup-lv_root分区

下面的操作是通过实际操作完成的。

下面的例子尝试吧home空间的20G中的5G分出来给root空间

[root@localhost ~]# df -h

文件系统              容量  已用  可用 已用%% 挂载点

/dev/mapper/VolGroup-lv_root

                       75G   50G  22G  70% /

tmpfs                 3.9G   88K 3.9G   1% /dev/shm

/dev/sda1             485M   30M 430M   7% /boot

/dev/mapper/VolGroup-lv_home

                       20G  174M  19G   1% /home

[root@localhost ~]# umount /home

[root@localhost ~]# e2fsck -f/dev/mapper/VolGroup-lv_home

e2fsck 1.41.12 (17-May-2010)

第一步: 检查inode,块,和大小

第二步: 检查目录结构

第3步: 检查目录连接性

Pass 4: Checking reference counts

第5步: 检查簇概要信息

/dev/mapper/VolGroup-lv_home: 158/1310720files (0.0% non-contiguous), 126581/5242880 blocks

[root@localhost ~]# resize2fs -p/dev/mapper/VolGroup-lv_home 15G

resize2fs 1.41.12 (17-May-2010)

Resizing the filesystem on/dev/mapper/VolGroup-lv_home to 3932160 (4k) blocks.

Begin pass 3 (max = 160)

正在扫描inode表         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The filesystem on/dev/mapper/VolGroup-lv_home is now 3932160 blocks long.

 

[root@localhost ~]# mount /home

[root@localhost ~]# df -h

文件系统              容量  已用  可用 已用%% 挂载点

/dev/mapper/VolGroup-lv_root

                       75G   50G  22G  70% /

tmpfs                 3.9G   88K 3.9G   1% /dev/shm

/dev/sda1             485M   30M 430M   7% /boot

/dev/mapper/VolGroup-lv_home

                       15G  170M  14G   2% /home

[root@localhost ~]#  lvreduce -L 15G /dev/mapper/VolGroup-lv_home

 WARNING: Reducing active and open logical volume to 15.00 GiB

 THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce lv_home?[y/n]: y

 Reducing logical volume lv_home to 15.00 GiB

 Logical volume lv_home successfully resized

[root@localhost ~]# vgdisplay

  ---Volume group ---

  VGName               VolGroup

 System ID            

 Format                lvm2

 Metadata Areas        1

 Metadata Sequence No  7

  VGAccess             read/write

  VGStatus             resizable

  MAXLV                0

  CurLV                3

 Open LV               3

  MaxPV                0

  CurPV                1

  ActPV                1

  VGSize               99.51 GiB

  PESize               4.00 MiB

 Total PE              25474

 Alloc PE / Size       24194 /94.51 GiB

 Free  PE / Size       1280 / 5.00 GiB

  VGUUID              cxzV5u-cG1f-HvPd-pE8c-eKrR-dBjN-H07k3I

  

[root@localhost ~]# lvextend -L +5.00G/dev/mapper/VolGroup-lv_root

 Extending logical volume lv_root to 80.57 GiB

 Logical volume lv_root successfully resized

[root@localhost ~]# resize2fs -p/dev/mapper/VolGroup-lv_root

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/VolGroup-lv_rootis mounted on /; on-line resizing required

old desc_blocks = 5, new_desc_blocks = 6

Performing an on-line resize of/dev/mapper/VolGroup-lv_root to 21121024 (4k) blocks.

The filesystem on/dev/mapper/VolGroup-lv_root is now 21121024 blocks long.

 

[root@localhost ~]# df -h

文件系统              容量  已用  可用 已用%% 挂载点

/dev/mapper/VolGroup-lv_root

                       80G   50G  27G  66% /

tmpfs                 3.9G   88K 3.9G   1% /dev/shm

/dev/sda1             485M   30M 430M   7% /boot

/dev/mapper/VolGroup-lv_home

                       15G  170M  14G   2% /home

(责任编辑:IT)