学派吧-教你怎么在linux/centos中调整分区大小-linux教程

本篇文章主要介绍了linux如何无损调整分区大小,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

情况:

  1. home:500G

  2. root:50G

  3. root分区不够用

思路:把home分区的空间划一部分到root分区

# 设置home分区大小为200G,释放300G空间
$ lvreduce -L 200G /dev/centos/home

# 将空闲空间扩展到root分区
$ lvextend -l +100%FREE /dev/centos/root

# 使用XFS文件系统自带的命令集增加分区空间
$ xfs_growfs /dev/mapper/centos-root

实例

situation

挂载在根目录的分区 /dev/mapper/centos-root 爆满,占用100%

$ df -h
Filesystem        Size Used Avail Use% Mounted on
/dev/mapper/centos-root  50G  50G  19M 100% /
devtmpfs         32G   0  32G  0% /dev
tmpfs           32G   0  32G  0% /dev/shm
tmpfs           32G 2.5G  29G  8% /run
tmpfs           32G   0  32G  0% /sys/fs/cgroup
/dev/mapper/centos-home 476G  33M 476G  1% /home
/dev/sda1        497M 238M 259M 48% /boot
tmpfs          6.3G   0 6.3G  0% /run/user/0

analyze

挂载在根目录的分区空间太小,只有50G,而服务器 home 目录为非常用目录,挂在了近500G的空间。

思路:从 centos-home 分区划出300G空间到 centos-root 分区。

operation

1.查看各分区信息

$ lvdisplay
--- Logical volume ---
LV Path        /dev/centos/home
LV Name        home
VG Name        centos
LV UUID        1fAt1E-bQsa-1HXR-MCE2-5VZ1-xzBz-iI1SLv
LV Write Access    read/write
LV Creation host, time localhost, 2016-10-26 17:23:47 +0800
LV Status       available
# open         0
LV Size        475.70 GiB
Current LE       121778
Segments        1
Allocation       inherit
Read ahead sectors   auto
- currently set to   256
Block device      253:2

--- Logical volume ---
LV Path        /dev/centos/root
LV Name        root
VG Name        centos
LV UUID        lD64zY-yc3Z-SZaB-dAjK-03YM-2gM8-pfj4oo
LV Write Access    read/write
LV Creation host, time localhost, 2016-10-26 17:23:48 +0800
LV Status       available
# open         1
LV Size        50.00 GiB
Current LE       12800
Segments        1
Allocation       inherit
Read ahead sectors   auto
- currently set to   256
Block device      253:0

2.减少/home分区空间

# 释放 /dev/centos/home 分区 300G 的空间
# 命令设置 /dev/centos/home 分区 200G空间
$ lvreduce -L 200G /dev/centos/home
WARNING: Reducing active logical volume to 200.00 GiB.
 THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce centos/home? [y/n]: y
 Size of logical volume centos/home changed from 475.70 GiB (121778 extents) to 200.00 GiB (51200 extents).
 Logical volume centos/home successfully resized.

3.增加/root分区空间

$ lvextend -l +100%FREE /dev/centos/root
Size of logical volume centos/root changed from 50.06 GiB (12816 extents) to 325.76 GiB (83394 extents).
Logical volume centos/root successfully resized.

4.扩展XFS文件空间大小

$ xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256  agcount=4, agsize=3276800 blks
     =            sectsz=512  attr=2, projid32bit=1
     =            crc=0    finobt=0 spinodes=0
data   =            bsize=4096  blocks=13107200, imaxpct=25
     =            sunit=0   swidth=0 blks
naming  =version 2       bsize=4096  ascii-ci=0 ftype=0
log   =internal        bsize=4096  blocks=6400, version=2
     =            sectsz=512  sunit=0 blks, lazy-count=1
realtime =none          extsz=4096  blocks=0, rtextents=0
data blocks changed from 13107200 to 85395456

完成

【相关推荐】

1. Mysql免费视频教程

2. 详解innodb_index_stats导入数据时

提示表主键冲突的错误

3. 实例详解

mysql中innodb_autoinc_lock_mode

4. MySQL中添加新用户权限的实例详解

5. Linux如何检测服务器网络状况

以上就是教你怎么在linux中调整分区大小的详细内容,更多请关注学派吧其它相关文章!

主题测试文章,只做测试使用。发布者:云大使,转转请注明出处:https://www.xp8.net/server/2505.html

(0)
打赏 微信扫一扫 微信扫一扫
云大使的头像云大使
上一篇 2018年12月12日 下午10:13
下一篇 2018年12月12日 下午10:13

相关推荐

  • 解决PHP5.6版本“No input file specified”的问题

    问题描述:使用TP框架做项目时,在启用REWRITE的伪静态功能的时候,首页可以访问,但是访问其它页面的时候,就提示:“No input file specified.”原因在于使用的PHP5.6是fast_cgi模式,而在某些情况下,不能正确识别path_info所造成的错误默认的.htaccess里面的规则: IfModule mod_rewrite.c…

    服务器运维 2018年7月17日
    3.8K00
  • 学派吧-在linux下安装python3的过程教程-linux教程

    本篇文章主要介绍了在centos7下安装python3的步骤,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧 环境搭建 准备工具: centos7:mirror.bit.edu.cn/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1611.iso virtuslvox:www.virtualbo…

    服务器运维 2018年12月14日
    1.9K00
  • 宝塔安装其他SSL证书

    有些新朋友不会安装证书、我在这里做个演示、我们先申请证书、我是在国内申请的免费的、这个看需求、如果是公司可以用收费的、加密不同 我用的景安提供的免费版、http://www.zzidc.com/index.action?agentpand=36148先注册会员,然后点产品、云安全、免费SSL、申请 购买购买后点开通下面填写下基本信息进行验证、我选择的DNS验…

    2018年8月4日
    12.6K00
  • 学派吧-shell一个空格引起的异常-linux教程

    学派吧-最近使用shell编写一个备份和替换f服务器程序的脚本replace.sh,初衷是为了节约人力的重复机械的劳动。在脚本编写过程中,由于疏忽多打了一个空格,出现了一个不符合预期的情况。 1.先看一下出问题的replace.sh  清单1:replace.sh 1 #!/bin/sh 2 file="mv.sh" #日志清理脚本 3 …

    2018年12月19日
    2.3K00
  • 总结关于文件说明注意点-linux教程

    如果您有服务器咨询问题、购买问题、可以联系我们客服 7271895 690624商祺云-阿里代理、景安代理、西部代理 一、/etc/hosts>man hosts1、作用: 主机名查询静态表;主要用于IP地址与计算机主机名之间的转换。/etc/hosts文件格式,每行表示一个IP地址;每行由三部分构成:IP_address canonical_host…

    服务器运维 2019年1月14日
    2.9K00

发表回复

登录后才能评论
联系我们

联系我们

18838889666

在线咨询: QQ交谈

邮件:xinyun@88.com

工作时间:周一至周五,9:30-18:30,节假日休息

添加微信
添加微信
分享本页
返回顶部
---------官方优惠叠加渠道折扣:通过我们购买腾讯云/阿里云,价格更低,服务更优。更有专业配置指导与服务。微信同步:18838889666----