Tutorials Resizing storage

Resizing storage

Before resizing storage devices, there are a couple of things you need to consider. While increasing storage size is safe to do on existing devices, and can even be done while the device is attached to a server, decreasing the storage size is not as straightforward. Imagine shrinking the storage too much and accidentally erasing part of your data. The storage resizing instructions in this guide will help you perform these operations safely.

Test hosting on UpCloud!

Safely increasing storage size

Increasing storage size is a two-phase operation.

  1. First, you will need to reserve the additional storage space by expanding your current storage device at your UpCloud Control Panel.
  2. Then, execute a couple of commands at the operating system level to allow your cloud server to take advantage of the added storage space.

We highly recommend making a backup of your server before resizing storage.

Start by increasing the storage size at the UpCloud Control Panel. You will need to shut down your cloud server before you can change the storage configuration.

When your server is powered down, open your server settings and go to the Resize tab. At the Storage resources list, adjust the storage device size by using the slider or by entering the desired value in the text field on the right.

Storage scaling

Afterwards, just click the Save changes button to confirm the change.

Once the storage size has been successfully increased, the new capacity will show up at the device information. The capacity indicates the storage space allocated to the device.

Next, boot up your cloud server again and continue on to perform the required operations at the OS-level for Linux in the following section or for Windows servers below that.

Increasing storage size on Linux

First, check your disk and partition names with the command below.

vda    253:0   0  50G  0  disk
└─vda1 253:1   0  25G  0  part /

Commonly you would be resizing the primary disk, which is usually called vda. Any secondary disk would have different dev-name such as vdb, or vdc. You will notice that only the disk size is showing the whole storage space you set in the control panel, like 50 GB in the example output above. Follow through with the rest of this section to get the partition extended to use the whole storage space.

Before making any changes, you should save the current partition table by using the next command. Note that you need to replace <disk> in the examples with the disk name you are resizing as shown in the output of the previous command e.g vda.

sudo sfdisk -d /dev/<disk> > ~/part_table_backup.txt

After backing up the partition table, you will need to repartition the disk. Check the information of the current partition.

sudo sfdisk -uS -d /dev/<disk>

Look for the start sector (probably 2048) and partition ID (probably 83) in the first partition. Then use those values in the following command in place of the bolded numbers. Note that these values are not constants, and may be different in your case. See the output of the above command for your system’s correct values.

sudo echo "2048,,83,-" | sudo sfdisk --force -uS /dev/<disk>

Afterwards, reboot your server before continuing.

sudo reboot

Once your server is up and running again, finish the operation by running resize2fs. Notice that the <partition> means the part on the disk you are expanding. Check the output of the lsblk command if you are unsure. For example, if your disk is called vda, then your partition is probably named vda1.

sudo resize2fs /dev/<partition>

Some distributions like CentOS 7 might be using XFS file system instead of EXT4. On these servers, you will need to use xfs_growfs to expand the partition. Install the following utility if it cannot already be found.

sudo yum install xfsprogs

Then use the command underneath to resize your partition. Make sure to include the “/” in the command as it indicates the root directory required for the operation.

sudo xfs_growfs /

With the resizing complete, reboot your server again.

sudo reboot

You are then done! The disk should now be using all of the space allocated at the control panel. You can verify this by checking the disk size with the command below.

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        50G  2.1G   46G   6% /

The example here demonstrates the process to extend a single 25GB disk to 50GB. These steps are necessary when permanently upgrading your cloud server to a higher tier monthly plan, which comes with additional disk space included.

Increasing storage size on Windows

Windows servers include management tools that can help you with resizing disks at the OS level. Log into your server for example with the Remote Desktop connection.

Start by opening the Disk Management panel. Right-clicking the Windows start icon and selecting it from the list, or type diskmgmt.msc in the search or run and then pressing enter.

The management application will indicate the unallocated space available on your disk with a black colour bar above the segment. Right-click the primary partition you wish to resize and select Extend volume.

Windows extend volume

In the wizard, the default values will extend the partition to use up all of the unallocated storage. Simply click Next on first and second window unless you wish to only extend a certain amount. On the last screen check that the values are correct and click Finish to confirm the changes.

Windows extend volume wizard

Once the requested operation is complete, the Disk Management panel will update to show the partition you extended now occupying the space previously unallocated. You are then done and can close the Disk Management window. The added storage space is ready to use with no additional restarts required.

Safely decreasing storage size

Decreasing the storage size involves a few steps:

  1. First, creating a new storage device with the desired size
  2. Transferring all data from the old drive to the new one
  3. And lastly deleting the old storage device.

This way all data is kept secure during the operation and everything gets safely copied as long as it can fit in the target space.

We highly recommend taking a backup of your server before resizing storage.

Note that decreasing storage size is currently not supported on Windows servers.

Start by creating a new storage device with the preferred size in the UpCloud Control Panel. Note that your server must be powered down before the required options become available.

Go to the Resize section in your server settings and click the Add new device button underneath the list of your existing storage devices.

In the following dialogue window, select New storage device, give the storage the required size and name, then click the Add a storage device button to confirm.

Create new smaller disk

You should now see a second storage device below the original.

After the attaching process is complete, start your server up again.

Once your server is up and running, you can continue the resizing process at the OS level.

Decreasing storage size on Linux

Check the name of the newly added storage disk using the following command.

vda    253:0   0  50G  0  disk
└─vda1 253:1   0  50G  0  part /
vdb    253:16  0  25G  0  disk

The disk you are looking for is usually the last on the list and will not have partitions on it like vdb in the example above. Create a new partition on the new disk using fdisk. Replace the <disk> in the command below with the new disk name.

sudo fdisk /dev/<disk>

The utility will open its own command prompt showing Command (m for help): instead of the usual [email protected]:/$. The following one letter commands will be entered there.

First, start the new partition wizard with the command n. Use default values by just pressing enter on each of the options, or type in the required parameter if no default value is given.

> n
# Primary p, partition 1, start sector 2048, end sector at disk end.

With the partition created, make it bootable with the command a.

> a
# Partition 1 if asked.

Afterwards, you can check that the partition was configured properly and is marked bootable with p, it should show something along the lines of the example underneath.

> p
Device     Boot Start      End  Sectors  Size Id Type
/dev/vdb1  *     2048 52428799 52426752   25G 83 Linux

If everything is in order, write partition changes to the disk using the command w. In case there was a mistake in the setup, delete the faulty partition by entering the command d and then create a new one again with command n.

> w

Once fdisk has finished writing the partition table to the disk, it will exit and return you to the usual command prompt. Check that the new partition shows up using the lsblk command.

vda    253:0   0  50G  0  disk
└─vda1 253:1   0  50G  0  part /
vdb    253:16  0  25G  0  disk
└─vdb1 253:17  0  25G  0  part

You should see both disks and their partitions with their correct sizes. The disks will be named like vda or vdb and their partitions with the added partition identifier number e.g. vda1 or vdb1. Notice that some of the commands below require you to enter the disk name while others use the partitions.

Set up the partition with a file system type appropriate for your server. Ubuntu and other Debian variants should use EXT4, while CentOS 7 machines might prefer using XFS instead.

# Creating an EXT4 file system on Debian, Ubuntu or CentOS 6.5
# Check your current disk's UUID.
sudo cat /etc/fstab
# Replace the <UUID> in the next command with it.
sudo mkfs.ext4 -U <UUID> /dev/<partition>
# Creating an XFS file system on CentOS 7.0
sudo mkfs.xfs /dev/<partition>

Afterwards, mount the new storage disk on your system so that you can copy the files over.

sudo mount /dev/<partition> /mnt

We recommend using rsync to copy such large amounts of files that your operating system might contain. It provides convenient options for copying all the files from your current disk to the new one, while also keeping track of the copy process allowing you to continue from where you left off if you have to cancel the copying for some reason.

On CentOS server, you’ll also need to temporarily disable SELinux to allow the copy.

sudo setenforce 0

Install rsync if you do not already have it.

sudo apt-get install rsync
sudo yum install rsync

The rsync command here uses the options for verbose output so that you can easily see what is getting copied. However, having a large amount of output on the display might slow down the process with a larger number of small files.

You can disable the printout by omitting the parameter –v from the command, or having the output redirected to a file by adding ‘> ~/filename.txt‘ to the end of the command.

sudo rsync -avxHAX / /mnt

Once the copy process has finished, check the disk space usage to see that everything was copied. The used space will not be exactly the same, but the difference should be minimal.


Lastly, install a boot manager on the new disk so that you can boot again with a new main storage device. You need to install the correct version of GRUB depending on your system.

Commonly Ubuntu and Debian use the first version.

sudo grub-install /dev/<disk> --root-directory=/mnt --recheck

While at least the newer CentOS and other Red Hat variants opt for the newer version.

sudo grub2-install /dev/<disk>

You should see a confirmation like in the example output below.

Installing for i386-pc platform.
Installation finished. No error reported.

CentOS 7 users should now set the UUID for the new disk, check it from the /etc/fstab with the following command, and then replace <UUID> in the next command with it while selecting the new disk partition, vdb1 for example.

sudo umount /mnt
sudo cat /etc/fstab
sudo xfs_admin -U <UUID> /dev/<partition>

After that, shut down your server either with the Shutdown request at your UpCloud Control Panel or by using the following command in your server terminal

sudo shutdown -h now

With your server powered down, go to the Resize tab again and click the eject icon on the former main disk, then start up your server. Confirm that all of your data was copied successfully and is available on the new disk.

In case the server cannot find the boot section and fails to start. Shut down the server and attach the original disk again to boot from. Then reinstall the GRUB and try booting from the new disk again by detaching the old disk.

Afterwards, you can delete the old disk at your UpCloud control panel in the Storage device section.

Decreasing storage size on Windows

Decreasing storage size on Windows is currently not supported using this method. Your best option is to deploy a new Windows server with the storage size you want and then copy over necessary files while attaching both storage devices to a single server.

Editor-in-chief and Technical writer at UpCloud since 2015. Cloud enthusiast writing about server technology and software.

11 thoughts on “Resizing storage

    1. Hi Eddie, the -x/--one-file-system option tells rsync to avoid crossing a filesystem boundary which should prevent any looping on the mounted filesystem. If unsure, use -xx to omits all mount-point directories from the copy.

  1. Hi everyone, followed this aricle step by step for saftely dreceasing
    When doing
    [email protected]:~# grub-install /dev/vdb1 –root-directory=/mnt –recheck
    Installing for i386-pc platform.
    grub-install: warning: File system `ext2′ doesn’t support embedding.
    grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged..
    grub-install: error: will not proceed with blocklists.
    System debian 10
    file system ext4.

    1. Hi Claudio, thanks for the question. The grub-install should be run on the storage device directly, not the partition. In your case try the following:

      grub-install /dev/vdb --root-directory=/mnt --recheck
  2. How to if with this error.

    Centos 7:

    #sudo resize2fs /dev/vda1

    Bad magic number in super-block while trying to open /dev/vda1
    Couldn’t find valid filesystem superblock.

    1. Hi there, thanks for the comment. The resize2fs command is intended to be used with Ubuntu and other Debian derivatives. On CentOS 7, you should use the xfs_growfs as instructed below the resize2fs command.

  3. Thanks for this tutorial. I used it to successfully increase storage after upgrading.

    However, I now need to downgrade, replacing the 80 GB boot drive with a 50GB one. I’m using Debian 10.

    I followed your instructions exactly. After rsyncing the data to the new drive, the command “grub-install /dev/ –root-directory=/mnt/mymountpoint –recheck” gave no errors.

    However, after shutdown/detach old drive/reboot, the server is hung at “Booting from hard disk…” I tried “grub-install /dev/ –boot-directory=/mnt/mymountpoint/boot –recheck ” with no success.

    I’d appreciate any advice.

  4. Hi Janne, as an update to my comment, I discovered that when there are multiple disks associated with a server, when downsizing and it is time to detach the unneeded larger disk (so the sever can reboot onto the new smaller disk), it is necessary to detach ALL disks, then reattach them starting with the new (smaller) boot disk. It took me many hours of experiments and guesswork to find this solution.

    1. Hi Lloyd, thanks for the comment, glad to hear you found the solution. This might have been caused by a bug in the system boot order, I’ll pass your report to the rest of the team for further investigation.

      1. Suggest you add that simple step “detach all disks, then reattach with your new disk first” to the tutorial. When there are multiple disks attached, this will save so much frustration and even Upcloud support personnel time.

        Thanks again for an excellent tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *


Helsinki (HQ)

In the capital city of Finland, you will find our headquarters, and our first data centre. This is where we handle most of our development and innovation.


London was our second office to open, and a important step in introducing UpCloud to the world. Here our amazing staff can help you with both sales and support, in addition to host tons of interesting meetups.


Singapore was our 3rd office to be opened, and enjoys one of most engaged and fastest growing user bases we have ever seen.


Seattle is our 4th and latest office to be opened, and our way to reach out across the pond to our many users in the Americas.