[SOLVED] How can I resize my disk (Proxmox 3.3-5, using DRBD and LVM and Ubuntu as VM)

Mannekino

New Member
Aug 23, 2014
14
0
1
Hi,

I am trying to resize a disk of one of my virtual machines but I am stuck and the articles I've read so far don't seem to work for my particular setup.

My setup is as follows.


  • Two servers and each server has two disks
  • The servers are in a Promox cluster
  • The second disk of each server are linked with each other using DRBD
  • The DRBD block device is used as a PV for LVM
  • There is one VG which is added in Proxmox as storage for virtual machines

I have shut down the virtual machine and increased the disk size using the "Resize disk" feature in Proxmox, I increased the disk from 20GB to 40GB.

Screenshot of my disks. As you can see the size of vm-100-disk-1 is now increased from 20GB to 40GB.

disks.png

After this I started the virtual machine again. When I login to the virtual machine and type "df -h" I see no changes. Here is the output:

Code:
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda7        16G  9.4G  5.4G  64% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            2.0G  4.0K  2.0G   1% /dev
tmpfs           396M  376K  395M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            2.0G     0  2.0G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/sda6       1.9G  3.0M  1.7G   1% /tmp
/dev/sda1       464M   38M  398M   9% /boot

On the Proxmox server where this particular VM is running on I see that the LV has changed in size.

Code:
$ lvdisplay
 --- Logical volume ---
  LV Path                /dev/vg0/vm-100-disk-1
  LV Name                vm-100-disk-1
  VG Name                vg0
  LV UUID                6sJdZu-qwqj-dmMd-Imak-NGk8-V0z8-DR2u9J
  LV Write Access        read/write
  LV Creation host, time pve3, 2014-09-04 18:49:22 +0200
  LV Status              available
  # open                 1
  LV Size                40.00 GiB
  Current LE             10240
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

The virtual machine itself doesn't use LVM for partitioning just normal regular partitions.

My question is how can I add the additional space to the /dev/sd7 device in the virtual machine.

Any help is greatly appreciated. If you need any more information please let me know.

Kind regards,

Mannekino
 
Last edited:
I managed to find a solution for my problem.

I downloaded the GParted Live ISO and uploaded this to my Proxmox environment. From there I restarted the VM and used the tool to simply resize my partitions. It worked perfectly. I first had to resize my extended partition with the extra 20 GB. After that I resized my /dev/sda7 partition and rebooted the VM. Verified everything after rebooting and I have the extra space available.

Code:
(parted) p
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End     Size    Type      File system     Flags
 1      1049kB  512MB   511MB   primary   ext4            boot
 2      513MB   42.9GB  42.4GB  extended
 5      513MB   2511MB  1999MB  logical   linux-swap(v1)
 6      2512MB  4511MB  1999MB  logical   ext4
 7      4512MB  42.9GB  38.4GB  logical   ext4

I think I lucked out with my root partition being the last one for this to work so easily, can anyone confirm? I've read a couple of how-to's where the swap partition was at the end and it had to be removed first before another second to last partition could be resized.
 
Last edited:
GParted Live ISO is a good solution for this case, and not very good solutions for LVM partitions.
If you have LVM partion into the VM, you can resize your partitions online into the VM by CLI.

Always that i create a new VM with Linux, and without LVM, my first partition is "/boot", and the second is "swap", of this mode, will be more easy to do a resize to the rest of partitions.

 
Ah yes, well as you can see I have one primary partition of 512 MB which I use for /boot

Then an extended partition with the remaining space of the entire drive. If I remember correctly this is how Ubuntu does it when you use the partitioner during installation.

Then my first logical partition is the swap, then one more for /tmp and then the rest for /root.

This is just the way I normally do things. This way I can mount /tmp with noexec,nosuid which is recommended I think. I used to also have a separate partition for /var but I moved on from that.
 
Do I need to mark this thread as "SOLVED" somehow so people can use this information when they search?