Creating and Attaching a Block Storage Disk onto an ECS

By Anish Nath, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

In Alibaba Cloud Elastic Compute Service (ECS) Linux servers, whenever you need to add additional storage capacity in an ECS server, adding disk is a possible and convenient solution. This tutorial is all about

  1. Creating a disk in Alibaba Cloud ECS instance.
  2. mounting this disk to a running ECS instance
  3. partitioning the cloud disk using fdisk.
  4. Unmounting the disk
  5. Remounting the Disk without performing partition.

Alibaba Cloud allows you to create a virtual block storage device (disks) that you can attach in to your virtual machines (ECS Instance).

Before You Begin

Make sure you have a valid Alibaba Cloud account to try out this experiment. You’ll also need an Alibaba Cloud ECS instance to follow the tutorial. The example shown in this document will only work on UNIX-based (Linux & OS X) machines which is running on Alibaba Cloud ECS instances.

Creating a Volume

Now let’s get started on creating the first Volume.

In the Alibaba cloud ECS console dashboard, click the Disks menu under Block storage.

Select the following (this may vary based on user need)

  1. Regions and zones vary based on the ECS regions,
  2. the Allocated disk sizes

Carefully review the setting of the new disk and finally hit the create button

Once the disk is Activated, it’s status will go to unmounted state

The first step is to mount or attach this disk to the running ECS instance

Once the disk is attached to the ECS instance, the disk status will be shown as In-Use.

You will see now in the “Mounting Point” column that the disk is attached into the ECS instance, in a device called “/dev/xvdb”

Now let’s login to ECS Linux Server instance as root.

To verify if the volume was attached properly, execute: fdisk -l

You should see some message like this:

If you didn’t see the /dev/vdb getting detected, try rebooting the instance and check it again.

To format your device, execute

It will output something like this:

  1. Press n to create a new disk partition.
  2. Press p to create a primary disk partition.
  3. Press 1 to denote it as 1st disk partition.
  4. Press ENTER twice to accept the default of 1st and last cylinder — to convert the remainder of hard disk to a single disk partition

It will output something like this:

Now, the next thing to do is enter these commands:

  1. Press t, then select the new partition you made.
  2. Press 83 change your new partition to 83, i.e. Linux partition type.

Now, the next thing to do is to enter these commands:

  1. Press p, to display the partition
  2. Press w to write the partition table.

Finally, reboot the server

Check if the partition table is available: The new disk /dev/vdb is available for mounting

Now create the filesystem in the /dev/vdb partition by mkfs.ext4

Warning This step assumes that you’re mounting an empty disk volume. If you’re mounting a volume that already has data on it, don’t use mkfs before mounting the volume Otherwise, you’ll format the volume and delete the existing data, refer to the section below.

Check the UUID of the volume by executing:

The line with /dev/vdb1 is what we are interested in the b70ec0bd-042f-4204–948d-59061c006e21 is the UUID

Create the Data folder

Mount the volume to data directory using the volume UUID and the directory you just created

Verify the disk space, the new data directory is shown

Use the lsblk command to view your available disk devices and their mount points

mount to persist after a reboot edit your fstab file to add the mount command:

Warning: Errors in the /etc/fstab file can render a system unbootable. Do not shut down a system that has errors in the /etc/fstab file.

Congratulations! you had now attached a Disk to an ECS instance successfully, the same step is documented in Video Demo here

Unmount File Systems and Remounting Again

This disk contains the data, by any chance you need to add this data disk to another instance then you can perform the following step.

unmount the disk partition by using umount command, and remove the entry containing this disk information from the fstab

and from the ECS console, select the disk and click on Unmount option as shown in below diagram.

After successful of the above operation, the disk can be mount again


you’re mounting a volume that already has data on it, don’t use mkfs before mounting the volume otherwise, you’ll format the volume and delete the existing data.

Repeat the step of mounting the disk from the ECS console to another running ECS instance. Once the ECS console operation done successfully, carefully execute the below step, this will preserve the data as no mkfs command is used.

Mount the volume and verify the operation.

The data is persisted in the disk

Check the disk Usage of the new partition.


Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store