欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos7 分区扩容 (新增磁盘)

程序员文章站 2024-03-09 09:47:05
...

新增一块60G硬盘,根分区及data分区各增加30G空间

一、初始大小

[[email protected] ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                   tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                   tmpfs     2.0G   12M  2.0G   1% /run
tmpfs                   tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/centos-root xfs        40G  1.5G   38G   4% /
/dev/mapper/centos-data xfs        40G   33M   40G   1% /data
/dev/sda1               xfs       497M  143M  354M  29% /boot
tmpfs                   tmpfs     407M     0  407M   0% /run/user/0

二、查看卷名

[[email protected] ~]# vgdisplay |grep -E "VG Name"   也可以查看剩余空间,FREE SIZE一行中,这里就不写了
  VG Name               centos
[[email protected] ~]# 

三、查看路径

[[email protected] ~]# lvdisplay |grep -E "LV Path"
  LV Path                /dev/centos/swap
  LV Path                /dev/centos/root
  LV Path                /dev/centos/data

四、查看新增磁盘大小及名称,这里是/dev/sdb

[[email protected] ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 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

五、格式化磁盘/dev/sdb

这一步一般可以省略

[[email protected] ~]# mkfs.xfs /dev/sdb
meta-data=/dev/sdb               isize=512    agcount=4, agsize=3932160 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=15728640, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=7680, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

六、/dev/sdb加入centos虚拟组

pvcreate /dev/sdb

vgextend centos /dev/sdb

[[email protected] ~]# pvcreate /dev/sdb
WARNING: xfs signature detected on /dev/sdb at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/sdb.
  Physical volume "/dev/sdb" successfully created.

七、增加/data分区空间

[[email protected] ~]# lvextend -L +30G /dev/centos/data 
  Size of logical volume centos/data changed from 39.46 GiB (10103 extents) to 69.46 GiB (17783 extents).
  Logical volume centos/data successfully resized.

八、刷新,**分区

[[email protected] ~]# xfs_growfs /dev/mapper/centos-data 
meta-data=/dev/mapper/centos-data isize=512    agcount=4, agsize=2586368 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=10345472, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=5051, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 10345472 to 18209792

九、同上,增加/根分区空间

[[email protected] ~]# lvextend -L +30G /dev/centos/root 
  Size of logical volume centos/root changed from 39.06 GiB (10000 extents) to 69.06 GiB (17680 extents).
  Logical volume centos/root successfully resized.
[[email protected] ~]# 
[[email protected] ~]# xfs_growfs /dev/mapper/centos-root 
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=2560000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=10240000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=5000, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 10240000 to 18104320
[[email protected] ~]# 
[[email protected] ~]# 
[[email protected] ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 2.0G     0  2.0G   0% /dev
tmpfs                    2.0G     0  2.0G   0% /dev/shm
tmpfs                    2.0G   12M  2.0G   1% /run
tmpfs                    2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/centos-root   70G  1.5G   68G   3% /
/dev/mapper/centos-data   70G   33M   70G   1% /data
/dev/sda1                497M  143M  354M  29% /boot
tmpfs                    407M     0  407M   0% /run/user/0

以上可以看出/根分区 及/data分区各增加了30G空间大小

另:
fdisk /dev/sda 磁盘分区
partprobe 重载分区表

-------------------------------end