大网数据广告活动
服务器运维问答

Extend CentOS partition - Already have 4 Primary Partitions

· 52CE 我爱测

I have a CentOS server, acting as my syslog server (CentOS Linux release 7.4.1708 (Core)). As my syslogs have grown in size, we've had to extend the volume a couple time. Now the main disk is 500 GB. We recently increased the siz…

问题原文

原帖链接 · Jake · CC BY-SA 4.0

I have a CentOS server, acting as my syslog server (CentOS Linux release 7.4.1708 (Core)). As my syslogs have grown in size, we've had to extend the volume a couple time. Now the main disk is 500 GB. We recently increased the size in VMWare up to 800 GB. I have been following this excellent document https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-machine-disk/.

Here is what my disk looks like:

fdisk -l

Disk /dev/sda: 859.0 GB, 858993459200 bytes, 1677721600 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: 0x000a207b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    62914559    30944256   8e  Linux LVM
/dev/sda3        62914560   524287999   230686720   83  Linux
/dev/sda4       524288000   943718399   209715200   8e  Linux LVM


lsblk

NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
fd0               2:0    1     4K  0 disk 
sda               8:0    0   800G  0 disk 
├─sda1            8:1    0   500M  0 part /boot
├─sda2            8:2    0  29.5G  0 part 
│ ├─centos-root 253:0    0 447.5G  0 lvm  /
│ └─centos-swap 253:1    0     2G  0 lvm  [SWAP]
├─sda3            8:3    0   220G  0 part 
│ └─centos-root 253:0    0 447.5G  0 lvm  /
└─sda4            8:4    0   200G  0 part 
  └─centos-root 253:0    0 447.5G  0 lvm  /
sr0              11:0    1  1024M  0 rom  

When attempting to create a new partition, I receive the following error message:

If you want to create more than four partitions, you must replace a primary partition with an extended partition first.

It appears that I have reached the limit of 4 primary partitions, so now I'm trying to figure out my options. Is there a way to extend onto this new 300 GB without formatting the drive? Can I convert one my current primary partitions to an extended partition without destroying my data?

已采纳解答

原帖链接 · g_bor · CC BY-SA 4.0

You could do it like described here: https://nacko.net/resizing-a-raw-virtual-machine-lvm-partition-using-fdisk/

Restating the main points: you can unmount the partition, delete it using a partitioning tool, then recreate it with identical data, except the end of partiton, which can be greater. You can only do this to the last partition on the disk.

Be aware that this requires extra caution, please have backups before doing this.

After that you should make sure that the changes are picked up.

Once that is done, you can pvresize, lvextend and finally resize2fs.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-09-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。