在Centos系统下给根分区进行扩容
当磁盘根分区不足时检查物理设备是否还有可用空间。如没有可用空间可新增一块硬盘来进行扩容根目录。
直接上干货
根分区扩容步骤:
1、查看分区内容
lsblk
查看没有挂载的分区
如果有挂载的分区并且没有盘符使用,直接接触挂载
注:这里选择了/dev/sdm这个盘符
umount /dev/sdm
2、分区格式化
mkfs -t ext4 /dev/sdm
-------------------
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
3、创建物理卷
pvcreate /dev/sdm
WARNING: ext4 signature detected on /dev/sdm at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sdm.
Physical volume "/dev/sdm" successfully created.
4、加入根分区的逻辑卷组
vgextend /dev/mapper/systemvg/rootlv /dev/sdm
或者执行如下:
vgextend /dev/systemvg /dev/sdm
Volume group "/dev/mapper/systemvg/rootlv" successfully extended
5、查看确认
vgdisplay
--- Volume group ---
VG Name systemvg
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 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 4.07 TiB
PE Size 4.00 MiB
Total PE 1068162
Alloc PE / Size 114301 / <446.49 GiB
Free PE / Size 953861 / <3.64 TiB
VG UUID 3fXX2F-QQmp-9Pud-7bWe-hr30-elsb-JtiAuu
6、扩容
lvextend -L +3000G /dev/systemvg/rootlv
Size of logical volume systemvg/rootlv changed from <442.49 GiB (113277 extents) to 3.36 TiB (881277 extents).
Logical volume systemvg/rootlv successfully resized.
7、操作生效
xfs_growfs /dev/systemvg/rootlv
meta-data=/dev/mapper/systemvg-rootlv isize=512 agcount=4, agsize=28998912 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=115995648, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=56638, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 115995648 to 902427648
8、查看是否成功扩容
df -Th
vgdisplay