cdp集群主节点根目录磁盘扩容

本文介绍了如何在Linux系统中通过调整磁盘分区、使用GPT和LVM工具对根目录进行扩容,包括创建分区、更新GPT表、添加到LVM卷组、扩展逻辑卷及文件系统。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查看挂载点

df -h

在这里插入图片描述

可以看到,根目录容量只有37G,现在对根目录进行扩容

查看根目录挂载的磁盘大小

lsblk

在这里插入图片描述

挂载磁盘名字为vda,磁盘容量有80G,现在磁盘使用量为vda下面三个分区vda1,vda2,vda3容量之和,也就是说vda这块磁盘还有大约40G的容量未使用,现在增加一个分区,在把根目录挂上去就可以实现对根目录扩容了。

添加磁盘分区

fdisk /dev/vda

在这里插入图片描述

刷新磁盘分区

partprobe

出现报错:

这里是引用
Error: 备份 GPT 表不像应该的那样出现在磁盘的末尾。这可能意味这其它操作系统相信磁盘小一些。通过将备份移动到末尾 (并删除旧备份) 来修正?
Warning: Not all of the space available to /dev/vda appears to be used, you can fix the GPT to use all of the space (an extra 83886080 blocks) or continue with the current setting?

采用另一种分配资源的方式

划分磁盘

#安装gdisk磁盘分配工具
yum install gdisk -y
#划分磁盘
gdisk /dev/vda
[root@cloudcdp01 ~]# gdisk /dev/vda
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): p  
Disk /dev/vda: 167772160 sectors, 80.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 2591E18B-299A-44C7-9070-551E8E4FA2F6
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 83886046
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   EF00  EFI System Partition
   2          411648         2508799   1024.0 MiB  0700  
   3         2508800        83884031   38.8 GiB    8E00  

Command (? for help): n
Partition number (4-128, default 4): 4
First sector (34-83886046, default = 83884032) or {+-}size{KMGTP}: 
Last sector (83884032-83886046, default = 83886046) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/vda: 167772160 sectors, 80.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 2591E18B-299A-44C7-9070-551E8E4FA2F6
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 83886046
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   EF00  EFI System Partition
   2          411648         2508799   1024.0 MiB  0700  
   3         2508800        83884031   38.8 GiB    8E00  
   4        83884032        83886046   1007.5 KiB  8300  Linux filesystem

Command (? for help): w
Warning! Secondary header is placed too early on the disk! Do you want to
correct this problem? (Y/N): Y
Have moved second header and partition table to correct location.

Warning! Mismatched GPT and MBR partition! MBR partition 4, of type 0x83,
has no corresponding GPT partition! You may continue, but this condition
might cause data loss in the future!

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/vda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
[root@cloudcdp01 ~]# 

刷新磁盘分区

partprobe

可以看到新加的磁盘分区加上了

在这里插入图片描述

大小有点少,重新分配一下

[root@cloudcdp01 ~]# gdisk /dev/vda
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): d
Partition number (1-4): 4

Command (? for help): p
Disk /dev/vda: 167772160 sectors, 80.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 2591E18B-299A-44C7-9070-551E8E4FA2F6
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 167772126
Partitions will be aligned on 2048-sector boundaries
Total free space is 83890109 sectors (40.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   EF00  EFI System Partition
   2          411648         2508799   1024.0 MiB  0700  
   3         2508800        83884031   38.8 GiB    8E00  

Command (? for help): n
Partition number (4-128, default 4): 4
First sector (34-167772126, default = 83884032) or {+-}size{KMGTP}: 
Last sector (83884032-167772126, default = 167772126) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/vda: 167772160 sectors, 80.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 2591E18B-299A-44C7-9070-551E8E4FA2F6
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 167772126
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   EF00  EFI System Partition
   2          411648         2508799   1024.0 MiB  0700  
   3         2508800        83884031   38.8 GiB    8E00  
   4        83884032       167772126   40.0 GiB    8300  Linux filesystem

Command (? for help): w

Warning! Mismatched GPT and MBR partition! MBR partition 4, of type 0x83,
has no corresponding GPT partition! You may continue, but this condition
might cause data loss in the future!

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/vda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
[root@cloudcdp01 ~]# 

在这里插入图片描述

在刷新一下磁盘分区

partprobe

可以看到,4号分区(vda4)已经加进去了

在这里插入图片描述

接下来把根目录挂上去

创建物理卷

lvm
lvm> pvcreate /dev/vda4
lvm> pvdisplay

在这里插入图片描述

显示系统中所有卷组的信息

lvm> vgdisplay

在这里插入图片描述

/dev/vda4 中的空间添加到 centos 卷组中

lvm> vgextend centos /dev/vda4
lvm> vgdisplay

在这里插入图片描述

扩展逻辑卷 /dev/centos/root,并将其大小增加了100% 的可用空间。

lvm> lvextend -l +100%FREE /dev/centos/root
lvm> exit

在这里插入图片描述

添加成功

在这里插入图片描述

扩展文件系统,/dev/centos/root 是逻辑卷的路径,关联的 XFS 文件系统扩展到逻辑卷的整个大小.

xfs_growfs /dev/centos/root

在这里插入图片描述

查看根目录大小,根目录扩容成功

df -h

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值