Extending / Creating Ext4 partition after increasing VMDK size

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

IamSpartacus

Well-Known Member
Mar 14, 2016
2,516
650
113
I have an Ubuntu Server 16.04 VM that I've been using to test a new Media Server configuration I'm planning to use. I started off with the recommended size of 16GB for the vmdk just for test purposes. Now that I have the server pretty much configured as I'd like it to be, I've increased the vmdk size to 100GB in order to make room for me to rsync all my docker appdata folders over.

My question is, how do I extend the current ext4 partition to utilize the full size of the vmdk? Or would it be a better solution to just create a second partition for the remaining 84GB of unused space to put all my appdata on? If so, what tool would be recommended for this purpose?
 

xnoodle

Active Member
Jan 4, 2011
258
48
28
IIRC what I've done in the past - Boot into a linux livecd that has gparted.
Move/resize the swap partition to the end of the disk.
Resize the ext4 partition to use up the available space in the middle of the disk.
You can then use resize2fs.
 

IamSpartacus

Well-Known Member
Mar 14, 2016
2,516
650
113
IIRC what I've done in the past - Boot into a linux livecd that has gparted.
Move/resize the swap partition to the end of the disk.
Resize the ext4 partition to use up the available space in the middle of the disk.
You can then use resize2fs.
Ok I've booted to Ubuntu Live CD and loaded up gparted but I don't see how to move the swap file.




How to extend an ext4 partition and filesystem?

The same way you'd do it if it were non-VM.
Forgive me, I'm a Linux noob.
 

xnoodle

Active Member
Jan 4, 2011
258
48
28
I think the padlock means they are mounted/in-use. File up a shell and umount /dev/sda2 and /dev/sda5. Might need to use sudo
 

Danic

Member
Feb 6, 2015
84
35
18
jrdm.us
I think swap is in use, I see the swapoff option. I would turn off and remove the swap partition. Then resize main partition but leave room for 2GB swap. Then add swap in left over space.
 

RTM

Well-Known Member
Jan 26, 2014
956
359
63
In cases like this, I would suggest deleting the swap partition (and the extended partition, because it is most likely not needed) and create a new at the end, just remember to mount the main ext4 partition and replace the UUID (use blkid to find UUIDs) of the swap disk in the file /etc/fstab with the new UUID (if you mount the ext4 partition on /mnt it will be /mnt/etc/fstab).

As you are using virtualization, I would suggest creating a separate disk exclusively for swap, that way you can easily extend the main disk in the future.
 

dataoscar

Member
Dec 2, 2013
68
10
8
In cases like this, I would suggest deleting the swap partition (and the extended partition, because it is most likely not needed) and create a new at the end, just remember to mount the main ext4 partition and replace the UUID (use blkid to find UUIDs) of the swap disk in the file /etc/fstab with the new UUID (if you mount the ext4 partition on /mnt it will be /mnt/etc/fstab).

As you are using virtualization, I would suggest creating a separate disk exclusively for swap, that way you can easily extend the main disk in the future.
I cheat and use a swap file.