zoukankan      html  css  js  c++  java
  • LVM扩容根分区

    LVM的工作方式      

    LVM管理工具集

    [root@wendang ~]# lsblk

    NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

    sda               8:0    0   50G  0 disk

    ├─sda1            8:1    0    1G  0 part /boot

    ├─sda2            8:2    0   15G  0 part

    │ ├─centos-root 253:0    0 13.4G  0 lvm  /

    │ └─centos-swap 253:1    0  1.6G  0 lvm  [SWAP]

    └─sda3            8:3    0   10G  0 part

    sr0              11:0    1 1024M  0 rom 

    [root@wendang ~]#  pvcreate /dev/sda3

      Physical volume "/dev/sda3" successfully created.

    [root@wendang ~]# vgs

      VG     #PV #LV #SN Attr   VSize   VFree

      centos   1   2   0 wz--n- <15.00g    0

    [root@wendang ~]# vgextend centos /dev/sda3

      Volume group "centos" successfully extended

    [root@wendang ~]#  vgs

      VG     #PV #LV #SN Attr   VSize  VFree 

      centos   2   2   0 wz--n- 24.99g <10.00g

    [root@wendang ~]# lvs

      LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

      root centos -wi-ao---- 13.39g                                                   

      swap centos -wi-ao----  1.60g                                                   

    [root@wendang ~]# df -h

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

    /dev/mapper/centos-root   14G  1.1G   13G    8% /

    devtmpfs                 908M     0  908M    0% /dev

    tmpfs                    920M     0  920M    0% /dev/shm

    tmpfs                    920M  8.8M  911M    1% /run

    tmpfs                    920M     0  920M    0% /sys/fs/cgroup

    /dev/sda1               1014M  145M  870M   15% /boot

    tmpfs                    184M     0  184M    0% /run/user/0

    ".

    [root@wendang ~]# df -h

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

    /dev/mapper/centos-root   14G  1.1G   13G    8% /

    devtmpfs                 908M     0  908M    0% /dev

    tmpfs                    920M     0  920M    0% /dev/shm

    tmpfs                    920M  8.8M  911M    1% /run

    tmpfs                    920M     0  920M    0% /sys/fs/cgroup

    /dev/sda1               1014M  145M  870M   15% /boot

    tmpfs                    184M     0  184M    0% /run/user/0

    [root@wendang ~]#

    [root@wendang ~]# lsblk

    NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

    sda               8:0    0   50G  0 disk

    ├─sda1            8:1    0    1G  0 part /boot

    ├─sda2            8:2    0   15G  0 part

    │ ├─centos-root 253:0    0 13.4G  0 lvm  /

    │ └─centos-swap 253:1    0  1.6G  0 lvm  [SWAP]

    └─sda3            8:3    0   10G  0 part

    sr0              11:0    1 1024M  0 rom 

    [root@wendang ~]# pvdisplay

      --- Physical volume ---

      PV Name               /dev/sda2

      VG Name               centos

      PV Size               <15.00 GiB / not usable 3.00 MiB

      Allocatable           yes (but full)

      PE Size               4.00 MiB

      Total PE              3839

      Free PE               0

      Allocated PE          3839

      PV UUID               mh1zwp-wM9K-iSCl-5fgJ-evDG-d3zZ-AozMWl

      

      --- Physical volume ---

      PV Name               /dev/sda3

      VG Name               centos

      PV Size               10.00 GiB / not usable 4.00 MiB

      Allocatable           yes

      PE Size               4.00 MiB

      Total PE              2559

      Free PE               2559

      Allocated PE          0

      PV UUID               IZJrH3-UswX-QXNe-Twih-oAR5-6cL3-l0LKGI

      

    [root@wendang ~]# vgdisplay

      --- Volume group ---

      VG Name               centos

      System ID            

      Format                lvm2

      Metadata Areas        2

      Metadata Sequence No  4

      VG Access             read/write

      VG Status             resizable

      MAX LV                0

      Cur LV                2

      Open LV               2

      Max PV                0

      Cur PV                2

      Act PV                2

      VG Size               24.99 GiB

      PE Size               4.00 MiB

      Total PE              6398

      Alloc PE / Size       3839 / <15.00 GiB

      Free  PE / Size       2559 / <10.00 GiB

      VG UUID               ZJCdml-lltw-AUau-NBJL-1QH1-2SAn-S5gbUB

      

    [root@wendang ~]# lvdisplay

      --- Logical volume ---

      LV Path                /dev/centos/swap

      LV Name                swap

      VG Name                centos

      LV UUID                hp3gdC-nima-jxLh-Be3r-c0dW-6n5S-Whnjfh

      LV Write Access        read/write

      LV Creation host, time wendang, 2019-09-17 00:12:50 +0800

      LV Status              available

      # open                 2

      LV Size                1.60 GiB

      Current LE             410

      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                ZbNoyJ-6c9y-APnh-oxYl-clan-KbQN-qAwqo2

      LV Write Access        read/write

      LV Creation host, time wendang, 2019-09-17 00:12:50 +0800

      LV Status              available

      # open                 1

      LV Size                13.39 GiB

      Current LE             3429

      Segments               1

      Allocation             inherit

      Read ahead sectors     auto

      - currently set to     8192

      Block device           253:0

      

     [root@wendang ~]# lvextend -L +9G /dev/mapper/centos-root

      Size of logical volume centos/root changed from 13.39 GiB (3429 extents) to 22.39 GiB (5733 extents).

      Logical volume centos/root successfully resized.

    [root@wendang ~]# xfs_growfs /dev/mapper/centos-root

    meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=877824 blks

             =                       sectsz=512   attr=2, projid32bit=1

             =                       crc=1        finobt=0 spinodes=0

    data     =                       bsize=4096   blocks=3511296, imaxpct=25

             =                       sunit=0      swidth=0 blks

    naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

    log      =internal               bsize=4096   blocks=2560, version=2

             =                       sectsz=512   sunit=0 blks, lazy-count=1

    realtime =none                   extsz=4096   blocks=0, rtextents=0

    data blocks changed from 3511296 to 5870592

    [root@wendang ~]# df -h

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

    /dev/mapper/centos-root   23G  1.1G   22G    5% /

    devtmpfs                 908M     0  908M    0% /dev

    tmpfs                    920M     0  920M    0% /dev/shm

    tmpfs                    920M  8.8M  911M    1% /run

    tmpfs                    920M     0  920M    0% /sys/fs/cgroup

    /dev/sda1               1014M  145M  870M   15% /boot

    tmpfs    

                   184M     0  184M    0% /run/user/0

    以下为纯命令

    1. fdisk /dev/sda 分区
    2. lsblk                    列出分区
    3. partprobe     刷新分区
    4. lsblk
    5. pvcreate /dev/sda3          创建物理卷
    6. vgs                                        查看卷组
    7. vgextend centos /dev/sda3     扩展卷组
    8. lvs              查看逻辑卷
    9. df –h    查看挂载
    10. pvdisplay           显示物理卷    
    11. vgdisplay        显示卷组
    12. lvdisplay          显示逻辑卷
    13. lvextend -L +9G /dev/mapper/centos-root            扩展逻辑卷 (若增加的为9G,需要小于9G,是因为PE的大小,可以为8.9G)
    14. xfs_growfs /dev/mapper/centos-root              刷新文件系统容量
    15. df –h                   确认已经扩容
    16. ls
    17. pwd

    /sbin/fdisk /dev/sda
     partprobe #同步分区表到硬盘
     ls /dev/sda*
     pvcreate /dev/sda3
     vgs
     vgextend centos /dev/sda3
     vgs
     lvs
     df -h
     vgs
     lvextend -L +200G /dev/mapper/centos-root
    xfs_growfs /dev/mapper/centos-root #扩容真实大小

    可怜一片无暇玉, 误落风尘花草中。 羡他村落无盐女, 不宠无惊过一生。
  • 相关阅读:
    ES6/ES2015核心内容(上)
    集合转数组的toArray()和toArray(T[] a)方法
    重复输出一个给定的字符串
    10道典型的JavaScript面试题
    用 JavaScript 检测浏览器在线/离线状态(JavaScript API — navigator.onLine)
    List<实体>与List<String>数据互转
    CSS实现四种loading动画效果
    Windows上安装Mac OS
    Android应用层View绘制流程之measure,layout,draw三步曲
    推断输入信息是否为空
  • 原文地址:https://www.cnblogs.com/wwtao/p/11531937.html
Copyright © 2011-2022 走看看