Home/Server & Website Managed Operations/Alibaba Cloud Disk Expansion: Lossless Partition Expansion for Windows and Linux
Server & Website Managed Operations

Alibaba Cloud Disk Expansion: Lossless Partition Expansion for Windows and Linux

When Alibaba Cloud first launched, disk upgrades required purchasing a new disk. If the old disk was insufficient in size, it had to be discarded and replaced with a larger one. Although the launch of Elastic Block Storage (EBS) allowed for the release of old disks at any time, data migration remained a significant challenge. Eventually, Alibaba Cloud introduced the disk expansion feature. Recently, a client had spare servers for our studio to test lossless disk partition expansion, which we have documented here for sharing.

Since this involves disk operations, it is strongly recommended to create a custom snapshot backup before proceeding. Data is priceless; one mistake can be disastrous~~

Linux Operations:

Below is a 7GB non-LVM partition.

12

Expand the disk to 8GB via the console, then restart the VM from the console to apply the new disk size (for testing EBS, unmounting and remounting from the console also works; this method is useful for servers that cannot be restarted).

22

After restarting, check the disk. It is now 8GB, but the original /dev/xvdc1 partition remains 7GB.

21

To test if this is truly lossless, we first create a file containing “test” on this 7GB partition.

1 [root@AY140627175005145240Z ~]# cd /mnt/
2 [root@AY140627175005145240Z mnt]# echo "test">>test.txt

As a precaution, run a filesystem check on the partition before proceeding:

1 [root@AY140627175005145240Z ~]# fsck -f /dev/xvdc1

Once completed, perform the most critical step: “Delete the current partition and recreate it.”

Press d to delete the current partition 1. Note: Do NOT press w to save after deletion! Immediately press n to create a new partition, starting from the original cylinder and extending to the end of the available space (press Enter twice for default values; if the previous partition did not start at the first cylinder, you must record the starting cylinder). After completing the new partition operation, press w to save.

1 [root@AY140627175005145240Z ~]# fdisk /dev/xvdc < <EOF
2 d
3 n
4 p
5 1
6
7 w
8 EOF

After the operation, re-check the disk using fsck -f /dev/xvdc1.

Then, redefine the partition size using resize2fs:

1 [root@AY140627175005145240Z ~]# resize2fs /dev/xvdc1
2 resize2fs 1.41.12 (17-May-2010)
3 Resizing the filesystem on /dev/xvdc1 to 2096474 (4k) blocks.
4 The filesystem on /dev/xvdc1 is now 2096474 blocks long.

Remount the partition and verify that it has become 8GB.

1 [root@AY140627175005145240Z ~]# mount /dev/xvdc1 /mnt/
2 [root@AY140627175005145240Z ~]# df -h
3 Filesystem Size Used Avail Use% Mounted on
4 /dev/xvdb1 20G 7.5G 12G 41% /
5 tmpfs 938M 0 938M 0% /dev/shm
6 /dev/xvdb1 20G 7.5G 12G 41% /alidata
7 /dev/xvdc1 7.9G 144M 7.4G 2% /mnt

Check the files in the previous partition; they remain intact.

1 [root@AY140627175005145240Z ~]#
2 [root@AY140627175005145240Z ~]# cd /mnt/;cat test.txt
3 test

 

Windows Operations (Methods for versions 03, 08, etc., are consistent; for 2003, you must right-click the disk and convert it to a dynamic disk before the extend option becomes available)

Below is a small 6GB disk.

11

Expand it to 7GB.

2

The new disk capacity takes effect after restarting from the console.

32

If the expanded partition appears as RAW after restarting, simply delete it. Then, right-click the old disk partition, select “Extend Volume,” choose the additional 1GB of space, and click Next to confirm.

41

You will be prompted to convert the disk to a dynamic disk. Select “Yes” here; this will not affect your data.

51

After completion, the original 6GB small partition becomes a 7GB large partition.

6

 

FREE CHECKUP

Free server checkup

We will send a problem checklist and remediation advice within one business day — no obligation to engage.

135 410 16684
Weekdays Mon – Fri 10:00 – 22:00 (UTC+8) · 7×24 emergency response
Call now
CONTACT

Contact Us

How can we help?

* Required