Disclaimer: This topic may contain information about third-party products. The information is for reference only. Alibaba Cloud does not make a guarantee in any form of the performance and reliability of the third-party products, and potential impacts of operations on these products.
When you purchase a Linux ECS instance, no data disks are purchased. After a period of use, the existing system disks can no longer meet the business requirements as the business increases. Run the
df -h command to query the space usage. If the system disk usage is close to 100%, you need to migrate data to the newly purchased data disk.
Take note of the following items:
- Before you perform high-risk operations such as modifying the specifications or data of an Alibaba Cloud instance, we recommend that you check the disaster recovery and fault tolerance capabilities of the instance to ensure data security.
- Before you modify the specifications or data of an Alibaba Cloud instance, such as an Elastic Compute Service (ECS) instance or an ApsaraDB RDS instance, we recommend that you create snapshots or enable backups for the instance. For example, you can enable log backups for an ApsaraDB RDS instance.
- If you have granted specific users the permissions on sensitive information, such as usernames and passwords, or submitted sensitive information in the Alibaba Cloud Management Console, we recommend that you modify the sensitive information at the earliest opportunity.
For more information about how to solve this problem, see the following:
Note: This solution involves data operations. Before the operations, you must create a snapshot to back up data.
- Purchase a data disk. After creating partitions, mount the data disk to the
/mnt/shujupandirectory in the system.
- Create a snapshot backup of the system disk to roll back when the operation fails.
- For data security reasons, you must stop the running service program to ensure smooth migration. For more information, see the following example:
- Assume that the
/mnt/wwwdirectory of the current system disk is the directory where data migration is required. Run the following command to migrate all files in the
wwwdirectory to the data disk:
cp -arp /mnt/www/* /mnt/shujupan/
Note: This topic uses the
/mnt/wwwdirectory as an example.
- Run the following command to uninstall the
- Run the following command to mount the
- Run the following command to modify the fstab file and specify the mount directory of the data disk to enable startup.
vi /etc/fstabAdd the following content at the end of the file to save and restart the instance.
/dev/xvdb1 /mnt/www ext4 defaults 0 0
Note: ext4 indicates the file system type of the data disk, and xvdb1 indicates the partition of the data disk.
- After the restart, check whether the program services in the system are running normally, and test whether the site and database can be connected and accessed normally. If no exception occurs, the data is migrated. At this time, the system and program are still accessing the
/mnt/wwwdirectory, but the directory is located on the data disk. Run the
df -hcommand to confirm that the system disk space usage is back to normal.
- Elastic Compute Service (ECS)