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


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? Any help would be greatly appreciated!



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.

  • Great solution! I just ran this on a clone of this machine to test, and it seems to have working perfectly. I'll try it out on my prod system next. Thanks! – Jake Sep 10 '19 at 22:32
  • I performed this on my prod server last night, and it worked like a champ. Thanks again for the solution. – Jake Sep 11 '19 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.