zoukankan      html  css  js  c++  java
  • CentOS7调整home盘空间到根目录

    1:解除挂载

      umount /home

      如报错:

    [root@zabbix-hk-01 home]# umount /home
    umount: /home:目标忙。
            (有些情况下通过 lsof(8) 或 fuser(1) 可以
             找到有关使用该设备的进程的有用信息)
    

       查找占用进程

    [root@zabbix-hk-01 home]# fuser -mv /home
                         用户     进程号 权限   命令
    /home:               root     kernel mount /home
                         root      104289 ..c.. bash
    [root@zabbix-hk-01 home]# kill -9 104289
    

       再次运行:

        umount /home

     2:删除逻辑卷home

    lvremove /dev/centos/home

    [root@zabbix-hk-01 /]# lvremove /dev/centos/home
    Do you really want to remove active logical volume centos/home? [y/n]: y
      Logical volume "home" successfully removed
    

     3:查看卷组可用空间 vgdisplay

    [root@zabbix-hk-01 /]# vgdisplay
      --- Volume group ---
      VG Name               centos
      System ID             
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  5
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                2
      Open LV               2
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               <299.00 GiB
      PE Size               4.00 MiB
      Total PE              76543
      Alloc PE / Size       13792 / <53.88 GiB
      Free  PE / Size       62751 / 245.12 GiB
      VG UUID               tAIuiq-fX7C-BiHa-yb0j-QzVp-T6A0-lpUNsn
    

    4:新建卷 lvcreate -L 50G -n home centos

    [root@zabbix-hk-01 /]# lvcreate -L 50G -n home centos
    WARNING: xfs signature detected on /dev/centos/home at offset 0. Wipe it? [y/n]: y
      Wiping xfs signature on /dev/centos/home.
      Logical volume "home" created.
    

     5:查看逻辑卷空间 lvdisplay

    [root@zabbix-hk-01 /]# lvdisplay
      --- Logical volume ---
      LV Path                /dev/centos/swap
      LV Name                swap
      VG Name                centos
      LV UUID                eowOwC-QBD1-F30j-P4qx-YGdP-eKWb-KRtWuP
      LV Write Access        read/write
      LV Creation host, time localhost, 2019-01-10 17:25:37 +0800
      LV Status              available
      # open                 2
      LV Size                <3.88 GiB
      Current LE             992
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     8192
      Block device           253:1
       
      --- Logical volume ---
      LV Path                /dev/centos/root
      LV Name                root
      VG Name                centos
      LV UUID                QOG2IY-DbGU-ces4-7I91-1gQ7-fszz-BocFkV
      LV Write Access        read/write
      LV Creation host, time localhost, 2019-01-10 17:25:37 +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     8192
      Block device           253:0
       
      --- Logical volume ---
      LV Path                /dev/centos/home
      LV Name                home
      VG Name                centos
      LV UUID                4hlXcF-Jrk3-wSPL-A7Dt-87EI-XarC-05Hve1
      LV Write Access        read/write
      LV Creation host, time zabbix-hk-01, 2019-01-30 08:40:20 +0800
      LV Status              available
      # open                 0
      LV Size                50.00 GiB
      Current LE             12800
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     8192
      Block device           253:2
    

     6:查看卷空间  vgdisplay

    [root@zabbix-hk-01 /]# vgdisplay
      --- Volume group ---
      VG Name               centos
      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               2
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               <299.00 GiB
      PE Size               4.00 MiB
      Total PE              76543
      Alloc PE / Size       26592 / <103.88 GiB
      Free  PE / Size       49951 / 195.12 GiB
      VG UUID               tAIuiq-fX7C-BiHa-yb0j-QzVp-T6A0-lpUNsn
    

    7:激活卷组(可选)

    [root@zabbix-hk-01 /]# vgchange -ay centos
      3 logical volume(s) in volume group "centos" now active

     8:在新逻辑卷/home上建立xfs文件系统

    [root@zabbix-hk-01 /]# mkfs -t xfs /dev/centos/home
    meta-data=/dev/centos/home       isize=512    agcount=4, agsize=3276800 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        finobt=0, sparse=0
    data     =                       bsize=4096   blocks=13107200, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
    log      =internal log           bsize=4096   blocks=6400, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    

     9:把新建的逻辑卷挂载到/home,并查验df -h

    [root@zabbix-hk-01 /]# mount /dev/centos/home /home/
    [root@zabbix-hk-01 /]# df -h
    文件系统                 容量  已用  可用 已用% 挂载点
    /dev/mapper/centos-root   50G  4.1G   46G    9% /
    devtmpfs                 3.8G     0  3.8G    0% /dev
    tmpfs                    3.9G     0  3.9G    0% /dev/shm
    tmpfs                    3.9G  362M  3.5G   10% /run
    tmpfs                    3.9G     0  3.9G    0% /sys/fs/cgroup
    /dev/xvda1              1014M  185M  830M   19% /boot
    tmpfs                    780M     0  780M    0% /run/user/0
    /dev/mapper/centos-home   50G   33M   50G    1% /home
    

    10:查看空闲空间

     

    [root@zabbix-hk-01 /]# vgdisplay
      --- Volume group ---
      VG Name               centos
      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               <299.00 GiB
      PE Size               4.00 MiB
      Total PE              76543
      Alloc PE / Size       26592 / <103.88 GiB
      Free  PE / Size       49951 / 195.12 GiB
      VG UUID               tAIuiq-fX7C-BiHa-yb0j-QzVp-T6A0-lpUNsn
    

    11:分配空间

    [root@zabbix-hk-01 /]# lvextend -L +195.12G /dev/centos/root
      Rounding size to boundary between physical extents: 195.12 GiB.
      Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 245.12 GiB (62751 extents).
      Logical volume centos/root successfully resized.

     12:查看卷组情况 root 空间已扩展

    [root@zabbix-hk-01 /]# lvdisplay
      --- Logical volume ---
      LV Path                /dev/centos/swap
      LV Name                swap
      VG Name                centos
      LV UUID                eowOwC-QBD1-F30j-P4qx-YGdP-eKWb-KRtWuP
      LV Write Access        read/write
      LV Creation host, time localhost, 2019-01-10 17:25:37 +0800
      LV Status              available
      # open                 2
      LV Size                <3.88 GiB
      Current LE             992
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     8192
      Block device           253:1
       
      --- Logical volume ---
      LV Path                /dev/centos/root
      LV Name                root
      VG Name                centos
      LV UUID                QOG2IY-DbGU-ces4-7I91-1gQ7-fszz-BocFkV
      LV Write Access        read/write
      LV Creation host, time localhost, 2019-01-10 17:25:37 +0800
      LV Status              available
      # open                 1
      LV Size                245.12 GiB
      Current LE             62751
      Segments               2
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     8192
      Block device           253:0
       
      --- Logical volume ---
      LV Path                /dev/centos/home
      LV Name                home
      VG Name                centos
      LV UUID                4hlXcF-Jrk3-wSPL-A7Dt-87EI-XarC-05Hve1
      LV Write Access        read/write
      LV Creation host, time zabbix-hk-01, 2019-01-30 08:40:20 +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     8192
      Block device           253:2
    

    13:查看磁盘分配情况 (不使用xfs_growfs扩展文件系统,磁盘不会识别分配空间

    [root@zabbix-hk-01 conf]# df -h
    文件系统                 容量  已用  可用 已用% 挂载点
    /dev/mapper/centos-root   50G  4.1G   46G    9% /
    devtmpfs                 3.8G     0  3.8G    0% /dev
    tmpfs                    3.9G     0  3.9G    0% /dev/shm
    tmpfs                    3.9G  362M  3.5G   10% /run
    tmpfs                    3.9G     0  3.9G    0% /sys/fs/cgroup
    /dev/xvda1              1014M  185M  830M   19% /boot
    tmpfs                    780M     0  780M    0% /run/user/0
    /dev/mapper/centos-home   50G   33M   50G    1% /home
    

    14:xfs_growfs /dev/centos/root

    [root@zabbix-hk-01 /]# xfs_growfs /dev/centos/root
    meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3276800 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        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=1
    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 64257024
    

     15:df -h

    [root@zabbix-hk-01 /]# df -h
    文件系统                 容量  已用  可用 已用% 挂载点
    /dev/mapper/centos-root  246G  4.1G  242G    2% /
    devtmpfs                 3.8G     0  3.8G    0% /dev
    tmpfs                    3.9G     0  3.9G    0% /dev/shm
    tmpfs                    3.9G  362M  3.5G   10% /run
    tmpfs                    3.9G     0  3.9G    0% /sys/fs/cgroup
    /dev/xvda1              1014M  185M  830M   19% /boot
    tmpfs                    780M     0  780M    0% /run/user/0
    /dev/mapper/centos-home   50G   33M   50G    1% /home
    

    感谢:

    https://blog.csdn.net/evandeng2009/article/details/49814097/

  • 相关阅读:
    Asp.net 连接池使用
    关于ASP.NET页面打印技术的总结
    Asp.net页面传值总结
    C#委托
    ASP.NET状态存储管理九大兵器
    JavaScript取ASP.NET中服务器端数据的方法
    DSOFramer.ocx 控件使用
    C#2.0 泛型学习(入门)
    黑马程序员——Java基础String与StringBuilder
    黑马程序员——Java基础语法关键字、常量、变量、运算符
  • 原文地址:https://www.cnblogs.com/jackyzm/p/10335119.html
Copyright © 2011-2022 走看看