0

I'm stuck with a centos 7 vm with 1 disk that has 4 primary partitions created... and now I need to add more space:

It currently looks like this - simplified:

mount
/dev/mapper/centos-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  175G   14G  162G   8% /

lsblk
sda               8:0    0  250G  0 disk
├─sda1            8:1    0  500M  0 part /boot
├─sda2            8:2    0 59.5G  0 part
│ └─centos-root 253:0    0  175G  0 lvm  /
├─sda3            8:3    0   60G  0 part
│ └─centos-root 253:0    0  175G  0 lvm  /
└─sda4            8:4    0   80G  0 part
  └─centos-root 253:0    0  175G  0 lvm  /

The disk /dev/sda has already been extended, with 50gb free and unpartitioned. Normally, I would do one of the following:

  • create a new partition with the free space and add it to the centos-root LV. Unfortunately, sda1-4 are all primary partitions, so I can't actually create any more.

  • use resize2fs to shrink the filesystem, then lvreduce the LV. But this filesystem is xfs, and cannot be reduced.

I also tried to create a new virtual disk /dev/sdb, and run the following to clear one of the partitions:

pvcreate /dev/sdb
vgextend centos /dev/sdb
pvmove /dev/sda4 /dev/sdb
  /dev/sda4: Moved: 0.00%
  /dev/sda4: Moved: 3.06%
  [kernel panic] ????

But this actually crashes the whole VM... and now I'm stuck. How can I clean up at least one of these partitions, or at least add the space I've already extended?

2 Answers 2

1

It seems that you started out with sda2 as the sole physical volume. Later, you added sda3, then sda4 (I don't understand why you did that, given that your root filesystem only uses 14GB). Now you have a disk sda with four partitions but still roughly 50GB free, if I calculate right.

LVM exists for automating storage space management and making it more flexible. You, however, manage the space on sda manually and still use LVM. This doesn't make much sense. Instead of adding partitions, you should have given sda2 the entire remaining space from the onset, then use LVM to manage that space.

I don't know what /dev/sdb is and why your system crashes during the pvmove. I am not sure in what state your volume group is right now. Assuming it is still OK, I would simply extend sda4. With the right version of parted, this is a simple command resizepart. See Red Hat's blog entry on parted.

Unfortunately, some versions of Centos 7 include a limited parted that doesn't have resizepart. If that is your case, try to update parted, or use fdisk to remove then recreate the partition. Or use the gparted Live DVD.

If you use the above Live DVD, I think you are done, since it also deals with LVM and filesystems. If not, pvresize /dev/sda4 is needed to inform LVM about the new size.

Ideally, you should combine the three PVs on sda into one, but that requires copying data around, for example with pvmove. Which fails in your case, for reasons I don't understand.

1
  • yep, an unfortunate situation. this vm requires 150-200gb of cache space. I found some similar issues online pointing to a weird kernel bug that was never fixed. parted + resizepart, pvresize, and xfs_growfs were what I needed. Commented Jan 29, 2021 at 14:27
0

This article helped me install extra ssd drive and add it using LVM.

The article is in the Fedora Magazine, Same stable as CentOS.

Add storage to your Fedora system with LVM

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.