After a newly created data disk is attached to a server, you must log in to the server and initialize the disk before you can use the disk.
When your disk is greater than 2 TiB, you can only use the parted tool and create GPT partitions. The initialization operations may vary depending on the server OS. Perform initialization operations based on your server OS. To learn about the differences between MBR and GPT, see Partition Styles.
Operation | Partition Style | OS Requirements | Common File Systems | Partitioning Tool | Example Configuration |
|---|---|---|---|---|---|
GPT | None | ext* (such as ext2, ext3, and ext4), xfs, and btrfs | parted |
|
The disk has been attached to a server. For how to attach disks, see Attaching an EVS Disk.
Major initialization steps include creating partitions and file systems, mounting partitions, and configuring auto mount at system startup.
The following example shows you how to use parted to create a GPT partition on the /dev/vdb data disk.
For how to log in to an ECS, see the Elastic Cloud Server User Guide.
lsblk
The command output shows that there are two EVS disks. /dev/vda is the system disk, and /dev/vdb is the new data disk, whose 3 TiB is not partitioned.
parted /dev/vdb
p
Partition Table: unknown means that no partition style is set for the new disk.
If error message -bash: parted: command not found is returned, the system cannot identify the command. In this case, run yum install -y parted to install the command. Then, run the command again.
mklabel gpt
unit s
p
(parted) mklabel gpt(parted) unit s(parted) pModel: Virtio Block Device (virtblk)Disk /dev/vdb: 6442450944sSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags:Number Start End Size File system Name Flags(parted)
mkpart /dev/vdb1 2048s 100%
p
(parted) mkpart /dev/vdb1 2048s 100%(parted) pModel: Virtio Block Device (virtblk)Disk /dev/vdb: 6442450944sSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags:Number Start End Size File system Name Flags1 2048s 6442448895s 6442446848s /dev/vdb1
[root@ecs-centos74 ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTvda 253:0 0 40G 0 disk├─vda1 253:1 0 40G 0 part /vdb 253:16 0 3T 0 disk└─vdb1 253:17 0 3T 0 part
mkfs -t ext4 /dev/vdb1
[root@ecs-test-0001 ~]# mkfs -t ext4 /dev/vdb1mke2fs 1.42.9 (28-Dec-2013)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks201326592 inodes, 805305856 blocks40265292 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=295279001624576 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,102400000, 214990848, 512000000, 550731776, 644972544Allocating group tables: doneWriting inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done[root@ecs-test-0001 ~]#
parted /dev/vdb
p
If ext4 is displayed under File system, the creation is successful.
Enter q and press Enter to exit parted.
mkdir -p /mnt/sdc
mount /dev/vdb1 /mnt/sdc
lsblk
[root@ecs-test-0001 ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTvda 253:0 0 40G 0 disk├vda1 253:1 0 40G 0 part /vdb 253:16 0 3T 0 disk├vdb1 253:17 0 3T 0 part /mnt/sdc
You should now see that partition /dev/vdb1 is mounted on /mnt/sdc.
UUIDs are the unique character strings for identifying partitions in Linux. Mounts become invalid after a system reboot. You can configure auto mount at startup by adding information of the new partitions into the /etc/fstab file. blkid /dev/vdb1 Take note of the partition UUID, which will be used in the next step. In this example, the UUID of the /dev/vdb1 partition is 0b3040e2-1367-4abb-841d-ddb0b92693df. vi /etc/fstab Press i to enter the editing mode, move the cursor to the end of the file, press Enter, and add the following content: Press Esc, enter :wq, and press Enter to save the settings and exit the vi editor. Example Value Description UUID=0b3040e2-1367-4abb-841d-ddb0b92693df The UUID of the partition. /mnt/sdc The mount point of the partition. ext4 The file system format of the partition. defaults The partition mount option. Normally, this parameter is set to defaults. 0 2
You can restart the server to check whether auto mount takes effect. Alternatively, you can perform the following steps to simulate auto mount.
umount /dev/vdb1
mount -a
mount | grep /mnt/sdc
If information similar to the following is displayed, auto mount has taken effect:
root@ecs-test-0001 ~]# mount | grep /mnt/sdc/dev/vdb1 on /mnt/sdc type ext4 (rw,relatime,data=ordered)