博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
将home多余的空间分配到"/"分区下
阅读量:5791 次
发布时间:2019-06-18

本文共 4037 字,大约阅读时间需要 13 分钟。

.操作过程

 1.df -h 查看分区大小情况;

[root@localhost /]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                       50G  1.9G   45G   5% /

tmpfs                 7.5G     0  7.5G   0% /dev/shm

/dev/sda1             477M   90M  362M  20% /boot

/dev/mapper/VolGroup-lv_home

                      860G  101M  816G   1% /home

tmpfs                 4.0G     0  4.0G   0% /var/spool/MailScanner/incoming

 2.卸载home分区

[root@localhost /]# umount /home

 3.查看卸载情况

[root@localhost /]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                       50G  1.9G   45G   5% /

tmpfs                 7.5G     0  7.5G   0% /dev/shm

/dev/sda1             477M   90M  362M  20% /boot

tmpfs                 4.0G     0  4.0G   0% /var/spool/MailScanner/incoming

 4.重新整合home分区

[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: 50/57212928 files (10.0% non-contiguous), 3649291/228843520 blocks

 5.从新设定home分区的大小:

[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 = 32849)

Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Begin pass 3 (max = 6984)

Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Begin pass 4 (max = 17)

Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

 6.重新挂载home分区

[root@localhost /]# mount /home 

 7.查看挂载情况

[root@localhost /]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                       50G  1.9G   45G   5% /

tmpfs                 7.5G     0  7.5G   0% /dev/shm

/dev/sda1             477M   90M  362M  20% /boot

tmpfs                 4.0G     0  4.0G   0% /var/spool/MailScanner/incoming

/dev/mapper/VolGroup-lv_home

                       50G   81M   47G   1% /home

 7.lv_home逻辑分区减小到指定大小

[root@localhost /]# lvreduce -L 50 /dev/mapper/VolGroup-lv_home

  Rounding size to boundary between physical extents: 52.00 MiB.

  WARNING: Reducing active and open logical volume to 52.00 MiB.

  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 872.97 GiB (223480 extents) to 52.00 MiB (13 extents).

  Logical volume lv_home successfully resized.

 8.查询卷组的信息:

[root@localhost /]# vgdisplay 

  --- Volume group ---

  VG Name               VolGroup

  System ID            

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  6

  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               930.51 GiB

  PE Size               4.00 MiB

  Total PE              238210

  Alloc PE / Size       14743 / 57.59 GiB

  Free  PE / Size       223467 / 872.92 GiB           #Free PE / Size指定的应该是现在可在分配的空间

  VG UUID               Acapyj-Dw5o-Hi3c-RLVe-AmHl-AD83-Nek4Qv

 9.增加root分区的大小

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

  Size of logical volume VolGroup/lv_root changed from 50.00 GiB (12800 extents) to 922.00 GiB (236032 extents).

  Logical volume lv_root successfully resized.

 10.从新设定root分区的大小:

[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 = 58

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

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

 11.重新查看分区大小

[root@localhost /]# df -h 

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                      908G  1.9G  860G   1% /

tmpfs                 7.5G     0  7.5G   0% /dev/shm

/dev/sda1             477M   90M  362M  20% /boot

tmpfs                 4.0G     0  4.0G   0% /var/spool/MailScanner/incoming

/dev/mapper/VolGroup-lv_home

                       50G   81M   47G   1% /home

.遇到问题解决办法

1、在卸载/home目录的时候失败

可先执行如下fuser命令,然后再umount即可:

 [plain] view plaincopyprint?

[root@CentOS-78 /]# fuser -m /home 

[root@CentOS-78 /]# 

2、设定完lv_home的大小,再次mount该分区时,发现用df命令无法看到给分区,此时只要在mount一次即可

3、在设定lv_root的大小时,不要把Free PE / Size的空间全部都用上,这很可能会出现Free PE空间不足的现象,建议保留一点Free PE的空间。

转载于:https://www.cnblogs.com/tchroot/p/6561813.html

你可能感兴趣的文章
func install in ubuntu-server
查看>>
PostgreSQL数据库pg_dump命令行不输入密码的方法
查看>>
asp教程八:访问数据库
查看>>
Linux 文件系统权限记序
查看>>
Exchange2010高可靠性和可用性解决方案
查看>>
java读取Excel文件
查看>>
病毒在网络上传播的基本途径分析
查看>>
Mac系统中在Finder中显示(隐藏)隐藏文件
查看>>
perl学习笔记(9)
查看>>
使用Intel Thread Profiler查看Parallel.For性能
查看>>
《Hadoop进阶》利用Hadoop构建豆瓣图书推荐系统
查看>>
Linux运行环境大杂配
查看>>
部件举例之磁头上岗记(硬盘构造再揭秘之二)
查看>>
我们如何从VC++开始“编程”?
查看>>
Swing中为组件捕获光标焦点及为按钮设置快捷键
查看>>
MySQL--基本语句操作
查看>>
vue--实例与组件
查看>>
日常练习
查看>>
LVS 负载均衡群集详解、地址转换模式(LVS-NAT)案例详解
查看>>
自动化运维-Ansible (第二部:模块)
查看>>