Linux root卷扩展

由于Linux 根卷使用率非常高,影响了应用正常运行,现将linux 系统的根卷扩展步骤如下:

 

1: 新增一个磁盘LUN

/dev/sdb  
[root@node-16 bookinfo]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0009e924

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   104660991    51280896   8e  Linux LVM

Disk /dev/mapper/centos-root: 52.5 GB, 52504297472 bytes, 102547456 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 /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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
创建PV [root@node-1 bookinfo]# pvscan
  PV /dev/sda2   VG centos          lvm2 [48.90 GiB / 4.00 MiB free]
  Total: 1 [48.90 GiB] / in use: 1 [48.90 GiB] / in no VG: 0 [0   ]
[root@node-1 bookinfo]#
pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created.
[root@node-1 bookinfo]# v
vg扩容 [root@node-1 bookinfo]# vgscan
  Reading volume groups from cache.
  Found volume group "centos" using metadata type lvm2
[root@node-1 bookinfo]# pvscan
  PV /dev/sda2   VG centos          lvm2 [48.90 GiB / 4.00 MiB free]
 
PV /dev/sdb                       lvm2 [100.00 GiB]
  Total: 2 [148.90 GiB] / in use: 1 [48.90 GiB] / in no VG: 1 [100.00 GiB]
[root@node-1 bookinfo]#
vgextend centos  /dev/sdb
  Volume group "centos" successfully extended
[root@node-1 bookinfo]#

[root@node-1 bookinfo]# pvscan
  PV /dev/sda2   VG centos          lvm2 [48.90 GiB / 4.00 MiB free]
 
PV /dev/sdb    VG centos          lvm2 [<100.00 GiB / <100.00 GiB free]
  Total: 2 [<148.90 GiB] / in use: 2 [<148.90 GiB] / in no VG: 0 [0   ]
[root@node-1 bookinfo]#
LV 扩展 [root@node-1 bookinfo]# lvscan
  ACTIVE           
'/dev/centos/root' [<48.90 GiB] inherit
[root@node-1 bookinfo]#
lvextend -l 100%FREE /dev/centos/root
  Size of logical volume centos/root changed from <48.90 GiB (12518 extents) to 100.00 GiB (25600 extents).
  Logical volume centos/root successfully resized.
[root@node-1 bookinfo]#
[root@node-1 bookinfo]#
[root@node-1 bookinfo]# lvscan
  ACTIVE            '/
dev/centos/root' [100.00 GiB] inherit
[root@node-1 bookinfo]#
[root@node-1 bookinfo]#

[root@node-1 ~]# lvscan
  ACTIVE            '/dev/centos/root' [100.00 GiB] inherit
[root@node-1 ~]# pvscan
  PV /dev/sda2   VG centos          lvm2 [48.90 GiB / 0    free]
  PV /dev/sdb    VG centos          lvm2 [<100.00 GiB /
<48.90 GiB free]
  Total: 2 [<148.90 GiB] / in use: 2 [<148.90 GiB] / in no VG: 0 [0   ]
[root@node-1 ~]#
lvextend -L +48G /dev/centos/root
  Size of logical volume centos/root changed from 100.00 GiB (25600 extents) to 148.00 GiB (37888 extents).
  Logical volume centos/root successfully resized.
[root@node-1 ~]#
[root@node-1 ~]#
[root@node-1 ~]# lvscan
 
ACTIVE            '/dev/centos/root' [148.00 GiB] inherit
[root@node-16 ~]# pvscan
  PV /dev/sda2   VG centos          lvm2 [48.90 GiB / 0    free]
  PV /dev/sdb    VG centos          lvm2 [<100.00 GiB / 920.00 MiB free]
  Total: 2 [<148.90 GiB] / in use: 2 [<148.90 GiB] / in no VG: 0 [0   ]
[root@node-1 ~]#
[root@node-1 ~]# 
resizefs 刷新文件系统信息 [root@node-1 ~]#
[root@node-1 ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  8.3G     0  8.3G   0% /dev
tmpfs                   tmpfs     8.3G     0  8.3G   0% /dev/shm
tmpfs                   tmpfs     8.3G   45M  8.2G   1% /run
tmpfs                   tmpfs     8.3G     0  8.3G   0% /sys/fs/cgroup

/dev/mapper/centos-root xfs        49G   42G  7.2G  86% /
/dev/sda1               xfs      1014M  228M  787M  23% /boot



[root@node-1 ~]#
xfs_growfs  /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3204608 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=12818432, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6259, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 12818432 to 38797312
[root@node-1 ~]#
[root@node-1 ~]#
[root@node-1 ~]#
[root@node-1 ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  8.3G     0  8.3G   0% /dev
tmpfs                   tmpfs     8.3G     0  8.3G   0% /dev/shm
tmpfs                   tmpfs     8.3G   45M  8.2G   1% /run
tmpfs                   tmpfs     8.3G     0  8.3G   0% /sys/fs/cgroup

/dev/mapper/centos-root xfs       148G   42G  107G  28% /
/dev/sda1               xfs      1014M  228M  787M  23% /boot

你可能感兴趣的:(centos,系统)