If the capacity of system disk partitions is inconsistent with the actual system disk capacity after an ECS is created, you can manually adjust the partitions to expand the system disk.
There are two ways to expand a system disk:
This section uses an ECS running CentOS 7.3 64bit as an example. A 60 GB system disk was created with the ECS. However, the capacity of the system disk partition is displayed as only 40 GB.
To use the 20 GB capacity, performing the following operations:
sudo su -
In the following command output, /dev/xvda or /dev/vda indicates the system disk.
fdisk /dev/xvda
Information similar to the following is displayed:
[root@ecs-8d6c ]# fdisk /dev/xvda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help):
Because the system disk has two existing partitions, the system automatically creates the third one.
Information similar to the following is displayed.
The start cylinder number must be greater than the end cylinder numbers of existing partitions. In this example, use the default value for the new partition's start cylinder number and press Enter. Information similar to the following is displayed.
In this example, use the default value for the new partition's end cylinder number and press Enter. Information similar to the following is displayed.
Information similar to the following is displayed.
The system automatically writes the partition result into the partition list. Then, the partition is created.
Information similar to the following is displayed.
partprobe
mkfs -t ext4 /dev/xvda3
Formatting the partition requires a period of time. During this time, observe the system running status and do not exit the system.
Information similar to the following is displayed:
[root@ecs-86dc ]# mkfs -t ext4 /dev/xvda3 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1790544 inodes, 7156992 blocks 357849 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2155872256 219 block groups 32768 blocks per group, 32768 fragments per group 8176 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
If you mount the new partition to a directory that is not empty, the subdirectories and files in the directory will be hidden. It is a good practice to mount the new partition to an empty directory or a newly created directory. If you want to mount the new partition to a directory that is not empty, temporarily move the subdirectories and files in the directory to another directory. After the partition is mounted, move the subdirectories and files back.
mkdir /root/new
mount /dev/xvda3 /root/new
Information similar to the following is displayed:
[root@ecs-86dc ]# mount /dev/xvda3 /root/new [root@ecs-86dc ]#
Information similar to the following is displayed:
Do not set automatic mounting upon system startup for unformatted disks because this will cause ECS startup failures.
According to the preceding figure, the UUID of the new partition is 96e5e028-b0fb-4547-a82a-35ace1086c4f.
vi /etc/fstab
UUID=96e5e028-b0fb-4547-a82a-35ace1086c4f /root/new ext4 defaults 0 0
:wq
If you want to detach a new disk for which automatic mounting upon system startup has been set, you must delete the automatic mounting configuration before you detach the disk. Otherwise, the ECS cannot be started after you detach the disk. To delete the automatic mounting configuration, perform the following operations:
vi /etc/fstab
UUID=96e5e028-b0fb-4547-a82a-35ace1086c4f /root/new ext4 defaults 0 0
:wq