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
Published 2015-08-15By adminCategory Server & Website Managed Operations11 min read
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.
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).
After restarting, check the disk. It is now 8GB, but the original /dev/xvdc1 partition remains 7GB.
To test if this is truly lossless, we first create a file containing “test” on this 7GB partition.
This table is wide — scroll sideways to see it all
1
[root@AY140627175005145240Z ~]# cd /mnt/
This table is wide — scroll sideways to see it all
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.
This table is wide — scroll sideways to see it all
This table is wide — scroll sideways to see it all
2
resize2fs 1.41.12 (17-May-2010)
This table is wide — scroll sideways to see it all
3
Resizing the filesystem on /dev/xvdc1 to 2096474 (4k) blocks.
This table is wide — scroll sideways to see it all
4
The filesystem on /dev/xvdc1 is now 2096474 blocks long.
Remount the partition and verify that it has become 8GB.
This table is wide — scroll sideways to see it all
1
[root@AY140627175005145240Z ~]# mount /dev/xvdc1 /mnt/
This table is wide — scroll sideways to see it all
2
[root@AY140627175005145240Z ~]# df -h
This table is wide — scroll sideways to see it all
3
Filesystem Size Used Avail Use% Mounted on
This table is wide — scroll sideways to see it all
4
/dev/xvdb1 20G 7.5G 12G 41% /
This table is wide — scroll sideways to see it all
5
tmpfs 938M 0 938M 0% /dev/shm
This table is wide — scroll sideways to see it all
6
/dev/xvdb1 20G 7.5G 12G 41% /alidata
This table is wide — scroll sideways to see it all
7
/dev/xvdc1 7.9G 144M 7.4G 2% /mnt
Check the files in the previous partition; they remain intact.
This table is wide — scroll sideways to see it all
1
[root@AY140627175005145240Z ~]#
This table is wide — scroll sideways to see it all
2
[root@AY140627175005145240Z ~]# cd /mnt/;cat test.txt
This table is wide — scroll sideways to see it all
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.
Expand it to 7GB.
The new disk capacity takes effect after restarting from the console.
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.
You will be prompted to convert the disk to a dynamic disk. Select “Yes” here; this will not affect your data.
After completion, the original 6GB small partition becomes a 7GB large partition.