01 CentOS根分区满了扩容

发布于:2025-05-20 ⋅ 阅读:(16) ⋅ 点赞:(0)

01 查看分区

# 环境介绍:本实验环境使用VMware Workstation 17PRO虚拟机复现,操作系统是CenrOS7操作系统
# 由图中可以看到根分区容量满了

图1 根分区容量满了

02 创建硬盘和分区

# 在设备上面加了150G的SCSI格式的硬盘

image-20250517152202450

图2 添加硬盘
# 这里有两种方法识别新添加的硬盘
	# 使用命令添加
	# 重启之后会重新识别硬盘
# 在这里面我们使用重启的方法识别硬盘

image-20250517152720048

图3 可以看到所有可用块设备信息

image-20250517153025613

图4 查看分区表,新添加的磁盘是/dev/sdb

image-20250517153643814

图5 创建分区,将sdb的空间全部分配给sdb1

image-20250517153942946

图6 查看刚刚创建的块设备信息
[root@harbor ~]#  mkfs.xfs /dev/sdb1 
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=9830336 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=39321344, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=19199, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

image-20250517160545298

图7 使用xfs格式格式化/dev/sdb1

image-20250517161144368

图8 PV分区
[root@harbor ~]# lvdisplay
...
  --- Logical volume ---
  LV Path                /dev/centos/home
...
[root@harbor ~]# vgextend centos /dev/sdb1
  Volume group "centos" successfully extended

image-20250517161355044

[root@harbor ~]# lvextend -l +100%FREE /dev/centos/root
  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 200.00 GiB (51200 extents).
  Logical volume centos/root successfully resized.

image-20250517161528224

把可用空间全部加给根分区

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

image-20250517161819875

[root@harbor ~]# df -Th
文件系统                类型      容量  已用  可用 已用% 挂载点
devtmpfs                devtmpfs  1.9G     0  1.9G    0% /dev
tmpfs                   tmpfs     1.9G     0  1.9G    0% /dev/shm
tmpfs                   tmpfs     1.9G   12M  1.9G    1% /run
tmpfs                   tmpfs     1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mapper/centos-root xfs       200G  2.0G  199G    1% /
/dev/sda1               xfs      1014M  151M  864M   15% /boot
/dev/mapper/centos-home xfs        96G   33M   96G    1% /home
tmpfs                   tmpfs     378M     0  378M    0% /run/user/0

image-20250517161855640


网站公告

今日签到

点亮在社区的每一天
去签到