1

I had a virtual machine which had no space left on my server using Proxmox Hypervisor.

I used this command to add 5Go of space to the VM putting the max space to 15Go:

qm resize <vmid> <device> <incrementsize>
qm resize 110 scsi0 +5

As you can see on the figure below, I have my 15 Go of space. But it's not allocated to the partition sda2.

Sample

Then my question is, how to resize this sda2 partition without recreating it from scratch ?

Thank you

EDIT :

sudo resize2fs /dev/sda2

Resizing the filesystem doesn't work because my partition is of type LVM.

3
  • Note: partitions and filesystems are different concepts. Recreating a partition while leaving the filesystem in it intact is one step in a standard procedure of expanding to the right. See this question and my answer there. So do you mean exactly "without recreating the partition"? or rather "without recreating the filesystem"? The latter is virtually equivalent to "without losing the data in the filesystem". What is the filesystem type? Commented Mar 7, 2021 at 11:46
  • Hello, thank you for your comment. Indeed, I want to resize a filesystem, but I can't do it with resize2fs for example because my partition is of type LVM.
    – LuckyFr
    Commented Mar 7, 2021 at 11:59
  • Note to users who happen to find this question because their problem is similar: "my partition is of type LVM" does not mean LVM is involved. The partition type tells programs what to expect, the actual content of the partition can be anything. The accepted answer does not deal with LVM at all. It helped the OP and got accepted, so apparently the OP does not use LVM. With LVM you need additional steps in the right sequence. Start your research here: How do you add more space to a Fedora (LVM) partition? Commented Mar 7, 2021 at 14:51

1 Answer 1

1

This might seem scary but it's safe. First, open a tmux or screen; you do not want to do that over a session that might go down due to a network glitch. Second, run fdisk -l /dev/sda and copy somewhere the output. It will be something like this:

enter image description here

Get a snapshot of it with your mobile, put it on paper, but copy it. Then the tricky part. You want to delete sda2 and recreate it with the same starting sector and a higher ending sector, or just hit enter and it will be extended to the end of the available space. If needed change its type to the partition type listed under the Type column of whatever fdisk -l /dev/sda's output says. An example session would be like the following:

enter image description here

In this case the disk is vda and the partition vda1, but the procedure is the same. All you need to do next, is extend the file system, which you will accomplish with the appropriate tool for the file system you're using.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .