Resize an existing ext4 virtual HDD in your EDIS KVM

VPS > KVM
This manual can be used to resize the ext4 virtual HDD of your KVM in case you upgrade to a bigger plan.
 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
          We strongly recommend that you perform a backup of your system before starting this procedure! 
                                                        This procedure can lead to data loss!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
Connect to your server over ssh and execute fdisk -l
You will get an output like this:
Disk /dev/vda: 15 GiB, 16106127360 bytes, 31457280 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
Disklabel type: dos
Disk identifier: 0x09ecbc38
Device     Boot    Start      End  Sectors  Size Id Type
/dev/vda1  *        2048   391167   389120  190M 83 Linux
/dev/vda2         391168 30275583 29884416 14.3G 83 Linux
/dev/vda3       30275584 31457279  1181696  577M 83 Linux
 
As you can see in this case the virtual HDD has a size of 15GiB
You now need to power off your KVM. You can do this with the command poweroff.
 
Please go to our control panel and login with your credentials: https://manage.edis.at/vps/
Find the server that you upgraded in the control panel.

In the control panel please Power the server back on. This process is important so the new KVM config is load and that the virtual disk is expanded.
 
Again connect to the server with SSH and execute fdisk -l
You should get a similar output:
Disk /dev/vda: 45 GiB, 48318382080 bytes, 94371840 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
Disklabel type: dos
Disk identifier: 0x09ecbc38
Device     Boot    Start      End  Sectors  Size Id Type
/dev/vda1  *        2048   391167   389120  190M 83 Linux
/dev/vda2         391168 30275583 29884416 14.3G 83 Linux
/dev/vda3       30275584 31457279  1181696  577M 83 Linux
 
In this case, the size of the virtual HDD was expanded from 15GB to 45 GB.
 
Please return to the control panel and select from the CD-ROM drop-down menu one of the System rescues CDs (we recommend you use the last version)
 
Confirm the inserting of the CD
 
 
For the next step, you need to activate the VNC.
You can do that by clicking on the enable VNC button in the control panel 
 
 
Please set a password of your choosing (the button "enable VNC" appears after you inserted the password and confirmed it)
 
 
Now start you favoured VNC Viewer and use the IP and the port to connect to your KVM or press the button "Start browser-based terminal" this will open a new window where you insert the password and connect directly to your KVM.
 
 
Over ssh execute the command reboot and switch to your VNC screen.
When the server reboots you need to press F12 or ESC to get into the boot menu
In the boot menu press 2 or 3 to boot the System rescue CD.
 
 
 
In the System Rescue CD boot menu select the first or the 2nd option ("Boot SystemRescuecD using default option" or "Boot SystemRescuecD and copy system to RAM" ) and wait for the system to boot
 
 
To make sure you have the correct designation of the virtual HDD execute fdisk -l
You should get the same output as before (in our case the drive designation is /dev/vda)
 
This is the list of partions:
/dev/vda1  *        2048   391167   389120  190M 83 Linux <-- /boot
/dev/vda2         391168 30275583 29884416 14.3G 83 Linux <-- / (root filesystem )
/dev/vda3       30275584 31457279  1181696  577M 83 Linux  <-- SWAP
 
First, we need to move the SWAP partition. We will do that by deleting it and creating a new SWAP partition.
For that please use the following commands:
parted /dev/vda
rm 3 <-- this will delete the SWAP partition
print
you should now get a list of partition without the 3rd SWAP partition
 
 
execute the command:
resizepartition 2
To know the size where the partition should end you need to do a small calculation:
“Disk /dev/vda: 48.3GB” is total size MINUS Swap 518MB = 47.8GB for the partition
 So 47.8GB is where the partition should end in our case, with the 518MB Swap.
 
if you now execute print you will see the new partition size is 47.6GB
 
 
now we need to create the SWAP partition.Please execute:
mkpart primary linux-swap 47.8GB 48.3GB <-- the first number represents the start of the SWAP partition the 2nd the end  of the partition
if make a print you should see this output 
 
 
The command quit will exit the disk tool Parted.
 
Now we need to resize the filesystem. To do that please execute
e2fsck -f /dev/vda2
 
 
now execute 
resize2fs /dev/vda2
 
 
now mount the partition to the /mnt for example with
mount /dev/vda2 /mnt
if you now perform a df -h you will see that the mount partition has a new size.
 
 
Because we deleted the SWAP partition we need to check/modify /etc/fstab. Please execute
vim /mnt/etc/fstab <-- please be careful not to modify the /etc/fstab since this is not your fstab but the one from the System Rescue your fstab is located in /mnt/etc/fstab
if you see a line like /dev/vda3             none     swap    sw
press :q!
this will exit vim without saving it. 
if you have the drives mount via UUID you need to modify the SWAP to mache:
/dev/vda3             none     swap    sw
press :wq
to exit and save.
 
 
now just reboot the server by executing reboot and wait for the system to come back online. 

Add Feedback