All Products
Search
Document Center

Elastic Compute Service:Move application data to a data disk

Last Updated:Jun 20, 2026

Transfer business data from a system disk directory to a data disk to reduce system disk load on a Linux ECS instance.

Warning

Data migration may disrupt your business. Consider resizing the system disk instead. See Step 1: Resize a disk to extend the disk capacity.

Prerequisites

The following example transfers data from the /userdata directory to the /dev/vdb1 partition on Alibaba Cloud Linux 3.2104. Replace /userdata and /dev/vdb1 with your actual directory and partition names.

Workflow

image

Procedure

Step 1: Back up the system disk

Create a snapshot of the system disk to prevent data loss. See Create snapshot manually.

Note

Snapshots incur fees. See Snapshot billing.

Step 2: Copy data to the data disk

  1. Create the /temporary directory and mount the data disk partition. Replace /dev/vdb1 with your actual partition name.

    sudo mkdir /temporary
    sudo mount /dev/vdb1 /temporary
  2. Copy data from /userdata to the mounted /temporary directory. Replace /userdata with your actual directory name.

    sudo cp -rv /userdata/. /temporary

    Alternatively, use rsync to copy files with progress display.

    sudo yum install -y rsync
    rsync --progress /userdata/* /temporary

Step 3: Mount the data disk partition to the data directory

  1. Unmount the /temporary directory.

    sudo umount /temporary
  2. Rename /userdata to /userdata_bak as a short-term backup.

    sudo mv /userdata /userdata_bak
    Warning

    Renaming the data directory may cause business errors and short-term data loss. Evaluate the risks and perform this operation during off-peak hours.

  3. Rename /temporary to /userdata. Replace /userdata with your actual directory name.

    sudo mv /temporary /userdata
  4. Mount /dev/vdb1 to /userdata. Replace with your actual partition and directory names.

    sudo mount /dev/vdb1 /userdata
  5. Run the df -Th command to check if the data disk partition is mounted to the target directory. The following output shows that /dev/vdb1 is mounted to /userdata.

    [ecs-xxx                              ~]$ df -Th
    Filesystem     Type      Size  Used Avail Use% Mounted on
    devtmpfs       devtmpfs  867M     0  867M   0% /dev
    tmpfs          tmpfs     879M     0  879M   0% /dev/shm
    tmpfs          tmpfs     879M  436K  878M   1% /run
    tmpfs          tmpfs     879M     0  879M   0% /sys/fs/cgroup
    /dev/vda1      ext4       40G  2.8G   35G   8% /
    /dev/vdb1      ext4       40G  3.8G   34G  11% /userdata

Step 4: Verify business system operation

  1. Restart the business system and verify that it runs as expected.

    If an issue occurs, restore the business system:

    • Solution 1: Reverse the directory changes from Step 3.

      1. Unmount /userdata.

      2. Rename /userdata to /temporary.

      3. Rename /userdata_bak back to /userdata.

      4. Restart the business system.

    • Solution 2: Roll back the system disk with a snapshot. See Roll back disk using snapshot.

  2. After confirming the business system runs normally, delete the /userdata_bak directory.