当前位置:首页 > 服务器系统 > Centos > 正文内容

centos7 添加磁盘到/(根目录下),扩展VG卷和lv

一二三5年前 (2020-12-03)Centos919

1.创建pv

fdisk /dev/xvdc

输入n增加分区

输入p类型设置为:主分区

输入1分区编号设置为1

回车 为默认大小

回车 为默认 大小

输入w退出

2.把pv加入vg中,相当于扩充vg的大小

扩展vg,使用vgextend命令

[root@localhost ~] # vgextend centos /dev/xvdc1

   Volume group  "centos"  successfully extended

vgextend名字命令接的vg的名字,后面是磁盘的位置

3.我们成功把vg卷扩展了,在用vgs查看一下

[root@localhost ~] # vgs

   VG      #PV #LV #SN Attr   VSize  VFree

   centos   2   2   0 wz--n- 39.50g 20.04g

[root@localhost ~] # lvs

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

   root centos -wi-ao---- 17.47g                                                   

   swap centos -wi-ao----  2.00g  <br><br>虽然我们把vg扩展了,但是lv还没有扩展

4.扩展lv,使用lvextend命令

[root@localhost ~] # lvextend -L +20G /dev/mapper/centos-root

   Size of logical volume centos /root  changed from 17.47 GiB (4472 extents) to 37.47 GiB 


   (9592 extents).


   Logical volume root successfully resized.<br>-L 


指定扩展多大的空间到lv中去,后面的 /dev/mapper/centos-root 是指定扩展的文件位置,可在 df -h中看见


查看lv大小

[root@localhost ~] # lvs

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

   root centos -wi-ao---- 37.47g                                                   

   swap centos -wi-ao----  2.00g  

查看df  -h中变化没有

[root@localhost ~] # df -h

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

/dev/mapper/centos-root    18G  1.1G   17G    6% /

devtmpfs                 479M     0  479M    0%  /dev

tmpfs                    489M     0  489M    0%  /dev/shm

tmpfs                    489M  6.7M  483M    2%  /run

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

/dev/sda1                 497M  125M  373M   25%  /boot

tmpfs                     98M     0   98M    0%  /run/user/0 <br><br>没有变化。

那么我们要使用[root@localhost ~]# xfs_growfs /dev/mapper/centos-root 命令使系统重新读取大小

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

meta-data= /dev/mapper/centos-root  isize=256    agcount=4, agsize=1144832 blks

          =                       sectsz=512   attr=2, projid32bit=1

          =                       crc=0        finobt=0

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

          =                       sunit=0      swidth=0 blks

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

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 4579328 to 9822208

再使用df  -h查看

[root@localhost ~] # df -h

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

/dev/mapper/centos-root    38G  1.1G   37G    3% /

devtmpfs                 479M     0  479M    0%  /dev

tmpfs                    489M     0  489M    0%  /dev/shm

tmpfs                    489M  6.7M  483M    2%  /run

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

/dev/sda1                 497M  125M  373M   25%  /boot

tmpfs                     98M     0   98M    0%  /run/user/0

到这里我们就成功扩展了。


备注:我们可以自行生产vg组以及在新的vg中生成lv


vgcreate       创建新的vg组


lvcreate        在新的vg中创建新的lv,但是要指定对vg名字


vgreduce      把pv从vg中移除,若vg中只有一个pv则直接使用vgremove

fdisk /dev/xvdc 
vgextend centos /dev/xvdc1
lvextend -L +200G /dev/mapper/centos-root
xfs_growfs /dev/mapper/centos-root


扫描二维码至手机访问

扫描二维码推送至手机访问。

版权声明:本文由一二三博客发布,如需转载请注明出处。

分享给朋友:

相关文章

MYSQL 查看最大连接数和修改最大连接数

MySQL查看最大连接数和修改最大连接数1、查看最大连接数show variables like '%max_connections%';2、修改最大连接数set GLOBAL max...

CentOS7 配置163 yum源

1、下载repo文件 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo2、备份并替换系统的repo文件 cp Cent...

Centos7 mariadb 10.5集群式部署常见故障处理

Centos7 mariadb 10.5集群式部署常见故障处理

1、It may not be safe to bootstrap the cluster from this node. It was not the last one一、故障现象查看mysql错误...

Centos7 mariadb 10.5数据库的数据目录修改

1、查看MySQL/MariaDB数据库的数据目录MariaDB [(none)]> select @@datadir;+-----------------+| @@datadir ...

Nginx TCP协议配置

stream {     upstream zifangsky {      ...

Centos7 LVS+Keepalived+Nginx基于NAT模式构建高可用方案

Centos7 LVS+Keepalived+Nginx基于NAT模式构建高可用方案

1、准备机器名称网卡0网卡1VIPlvsmaster58.218.92.185(网关:58.218.92.1)10.77.1.20(不配置网关)58.218.92.187lvsbackup58.218...