美文网首页
CentOS 7.x LVM 分区扩容

CentOS 7.x LVM 分区扩容

作者: 又语 | 来源:发表于2019-11-21 21:15 被阅读0次

本文介绍 CentOS 7.x 系统基于 LVM 分区扩容的命令与方法,阅读本文前建议参考:CentOS 7.x 创建 LVM 系统分区


目录

  • 版本说明
  • 方法步骤

版本说明

  • CentOS Linux release 7.6

方法步骤

  1. 执行命令 lsblk 查看当前分区状态。
[root@... opt]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0          11:0    1 1024M  0 rom  
xvda        202:0    0   40G  0 disk 
├─xvda1     202:1    0   36G  0 part /
└─xvda2     202:2    0    4G  0 part [SWAP]
xvde        202:64   0  380G  0 disk 
└─xvde1     202:65   0  200G  0 part 
  └─opt-opt 253:0    0  199G  0 lvm  /opt
  1. 执行命令 fdisk 创建新分区。
[root@... opt]# fdisk /dev/xvde
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 
First sector (419432448-796917759, default 419432448): 
Using default value 419432448
Last sector, +sectors or +size{K,M,G} (419432448-796917759, default 796917759): 
Using default value 796917759
Partition 2 of type Linux and of size 180 GiB is set

Command (m for help): p

Disk /dev/xvde: 408.0 GB, 408021893120 bytes, 796917760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x55a42d8e

    Device Boot      Start         End      Blocks   Id  System
/dev/xvde1            2048   419432447   209715200   8e  Linux LVM
/dev/xvde2       419432448   796917759   188742656   83  Linux

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
  1. 执行命令 pvcreate 创建物理卷。
[root@... opt]# pvcreate /dev/xvde2
  Physical volume "/dev/xvde2" successfully created.
[root@... opt]# pvscan
  PV /dev/xvde1   VG opt             lvm2 [<200.00 GiB / 1020.00 MiB free]
  PV /dev/xvde2                      lvm2 [<180.00 GiB]
  Total: 2 [<380.00 GiB] / in use: 1 [<200.00 GiB] / in no VG: 1 [<180.00 GiB]
  1. 执行命令 vgextend 将物理卷加入卷组。
[root@... opt]# vgextend opt /dev/xvde2
  Volume group "opt" successfully extended
[root@... opt]# vgs
  VG  #PV #LV #SN Attr   VSize   VFree  
  opt   2   1   0 wz--n- 379.99g 180.99g
  1. 执行命令 lvextend 扩展逻辑卷。
[root@... opt]# lvextend -L 379G /dev/opt/opt
  Size of logical volume opt/opt changed from 199.00 GiB (50944 extents) to 379.00 GiB (97024 extents).
  Logical volume opt/opt successfully resized.
[root@... opt]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0          11:0    1 1024M  0 rom  
xvda        202:0    0   40G  0 disk 
├─xvda1     202:1    0   36G  0 part /
└─xvda2     202:2    0    4G  0 part [SWAP]
xvde        202:64   0  380G  0 disk 
├─xvde1     202:65   0  200G  0 part 
│ └─opt-opt 253:0    0  379G  0 lvm  /opt
└─xvde2     202:66   0  180G  0 part 
  └─opt-opt 253:0    0  379G  0 lvm  /opt
  1. 执行命令 df -h 检查 /opt 所在分区大小未改变。
[root@... ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/xvda1            36G  5.5G   29G  17% /
devtmpfs             7.8G     0  7.8G   0% /dev
tmpfs                7.8G     0  7.8G   0% /dev/shm
tmpfs                7.8G   18M  7.8G   1% /run
tmpfs                7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/opt-opt  196G   61M  186G   1% /opt
tmpfs                1.6G   12K  1.6G   1% /run/user/991
tmpfs                1.6G     0  1.6G   0% /run/user/0
  1. 执行命令 resize2fs 重设卷组大小。
[root@... ~]# resize2fs /dev/opt/opt
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/opt/opt is mounted on /opt; on-line resizing required
old_desc_blocks = 25, new_desc_blocks = 48
The filesystem on /dev/opt/opt is now 99352576 blocks long.

[root@... ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/xvda1            36G  5.5G   29G  17% /
devtmpfs             7.8G     0  7.8G   0% /dev
tmpfs                7.8G     0  7.8G   0% /dev/shm
tmpfs                7.8G   18M  7.8G   1% /run
tmpfs                7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/opt-opt  373G   67M  356G   1% /opt
tmpfs                1.6G   12K  1.6G   1% /run/user/991
tmpfs                1.6G     0  1.6G   0% /run/user/0

相关文章

  • CentOS 7.x LVM 分区扩容

    本文介绍 CentOS 7.x 系统基于 LVM 分区扩容的命令与方法,阅读本文前建议参考:CentOS 7.x ...

  • Linux 服务器磁盘在线扩容

    CentOS 7 非 LVM 根分区扩容步骤 1、查看现有分区大小 [root@localhost ~]# df ...

  • KVM扩容VM磁盘

    环境 系统:CentOS 7.9 扩容VM磁盘 扩容系统分区 如果系统使用LVM,可参考此处[https://ww...

  • Linux 单磁盘根分区扩容-非 LVM

    Linux 单磁盘根分区扩容-非 LVM 硬件:DELL R720 系统:XEN 虚拟系统:CentOS 6.5 ...

  • linux下的fdisk和parted分区

    环境:CentOS 7,分区使用的是默认分区。在前面的文章里用到了fdisk分区进行lvm扩容。因为遇到了上限所以...

  • CentOS 7.x 创建 LVM 系统分区

    本文介绍 CentOS 7.x 系统创建 LVM 系统分区的命令与方法。 目录 版本说明 方法步骤 总结 版本说明...

  • CentOS7扩容根分区(LVM+非LVM)

    CentOS7,LVM根分区扩容步骤: 1.查看现有分区大小 df -TH 2.关机增加大小为30G(测试环境使用...

  • centos7 磁盘扩容

    LVM扩容(centos7) 一 、LVM扩容准备 1.1 查看fdisk 1.2 查看所有存储设备 其中 /de...

  • kvm虚拟机(centos7)磁盘扩容

    1·添加磁盘 2.创建分区 3.lvm扩容 对xfs格式的lvm扩容后需要使用xfs_growfs进行系统扩容,而...

  • Linux_126_LVM原理

    LVM原理 LVM动态扩容大小,其实就是通过互相交换PE的过程,达到能够弹性扩容分区大小 想要减少空间容量,就是剔...

网友评论

      本文标题:CentOS 7.x LVM 分区扩容

      本文链接:https://www.haomeiwen.com/subject/zldxwctx.html