码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 磁盘空间调整

时间:2019-03-12 10:43:31      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:系统   情况   现象   PFS   指定   code   process   end   vol   

环境:OS: Red Hat Enterprise Linux Server release 6.5 (Santiago)

准备阶段

1.记录当前卷名称、大小

[[email protected] ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol01   50G   41G  6.3G  87% /
tmpfs                           16G     0   16G   0% /dev/shm
/dev/xvda1                     194M   30M  155M  16% /boot
/dev/mapper/VolGroup-LogVol02  2.0T   32G  1.9T   2% /home
cm_processes                    16G     0   16G   0% /var/run/cloudera-scm-agent/process

2.设定目标目标:从 /dev/mapper/VolGroup-LogVol02 调整 1T 到 /dev/mapper/VolGroup-LogVol01

3.记录当前磁盘挂载情况

[[email protected] ~]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup
  ...
  Free  PE / Size       5577 / 21.79 GiB

当前可分配磁盘为 21.79GB

步骤预览

1.卸载分区

[[email protected] ~]# umount /home
umount: /home: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

[[email protected] ~]# fuser -m /home
/home:                 336ce  1942ce 16741cm 21443ce 23193ce 25565ce

[[email protected] ~]# ps -ef | grep 336
[[email protected] ~]# kill -9 336 
...
[[email protected] ~]# umount /home

有用户进程正在运行是无法卸载的。可通过fuser找到进程信息,逐个结束进程再卸载。

2.设定被调整卷大小

[[email protected] ~]# resize2fs -p /dev/mapper/VolGroup-LogVol02 1024G
Please run 'e2fsck -f /dev/mapper/VolGroup-LogVol02' first.

[[email protected] ~]# e2fsck -f /dev/mapper/VolGroup-LogVol02
Pass 1: Checking inodes, blocks, and sizes
...

[[email protected] ~]# resize2fs -p /dev/mapper/VolGroup-LogVol02 1024G
...
The filesystem on /dev/mapper/VolGroup-LogVol02 is now 268435456 blocks long.

3.装载分区

[[email protected] ~]# mount /home
[[email protected] ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol01   50G   41G  6.3G  87% /
...
/dev/mapper/VolGroup-LogVol02 1008G   32G  926G   4% /home

如果df命令无法看到分区,可再在mount一次。

4.将逻辑分区减小到指定大小

 [[email protected] ~]# lvreduce -L 1024G /dev/mapper/VolGroup-LogVol02

摘:"我认为这个命令是将已经减少的100G空间拿到系统公共的区域,可以被其他分区加载和利用。"

5.查看可分配卷信息

[[email protected] ~]# vgdisplay
 Free  PE / Size       267721 / 1.02 TiB

6.增加目标分区大小

lvextend -L +1024G /dev/mapper/VolGroup-LogVol01 

# 注意在设定目标分区大小时,建议不要把Free PE / Size的空间全部都用上,这很可能会出现Free PE空间不足的现象,建议保留一点Free PE的空间。

7.调整目标卷大小

[[email protected] ~]# resize2fs -p /dev/mapper/VolGroup-LogVol01

[[email protected] ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol01  1.1T   41G  963G   5% /
...
/dev/mapper/VolGroup-LogVol02 1008G   32G  926G   4% /home

参考文档

Linux 磁盘空间调整

标签:系统   情况   现象   PFS   指定   code   process   end   vol   

原文地址:https://www.cnblogs.com/futeng/p/10515021.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有 京ICP备13008772号-2
迷上了代码!