After the console attaches the data disk for the Linux instance, you need to login the instance to partition and format the data disk, and attach a file system before you can use it normally.
How to complete attaching using script and manually are described respectively in the following.
Under Linux, you can use the script provided by JD Cloud to detect whether there is a data disk that has not been partitioned, and automatically complete formatting and attaching of the data disk, which will leave out the complicated commands and steps you need to enter. Attach Script: MountDataDisk.
You can use the script in the following two ways:
sh auto_fdisk.sh /dev/vdb /jddata1 ext4
Data loss may occur due to related operations. Therefore, before executing the operation, please make sure that the data has been effectively backed up by the means of snapshots, etc., or please confirm that no effect will be caused due to the data loss;
This script is only applicable to the un-partitioned and un-attached Cloud Disk. Therefore, it will not operate on hard disks that have been partitioned or attached;
This script creates a partition for the hard disk by default and cannot be modified;
This script will realize the automatic attaching of cloud disk by writing the UUID and attaching information of the disk in the /etc/fstab file. If you need to detach the cloud disk, please delete the information corresponding to this file. Otherwise, the Virtual Machines may be unable to start normally.
If you need to manually partition, format and create a file system, we take the Centos operating system as an example, as follows:
Note: If the hard disk capacity you created is greater than 2T, please do not use the partition or refer to the following steps to use parted to partition: 1) Create a partition table and select GPT format: <br>![ ](https://jdcloud-portal.oss.cn-north-1.jcloudcs.com/en/image/vm/Getting-Start-Linux-mount2.png)<br> 2) Create a partition <br>![ ](https://jdcloud-portal.oss.cn-north-1.jcloudcs.com/en/image/vm/Getting-Start-Linux-mount3.png)<br> 3) Re-run the fdisk -l command and confirm the partition <br>![ ](https://jdcloud-portal.oss.cn-north-1.jcloudcs.com/en/image/vm/Getting-Start-Linux-mount4.png)
mkfs -t ext4 /dev/vdb1
Note: This example creates a file system in ext4 format, and you can choose to create other file systems. In order to ensure data integrity and availability from the file system level, it is not recommended to use a format such as ext2 that does not provide a jounral mechanism.
mkdir -p /mnt/vdb1 && mount -t ext4 /dev/vdb1 /mnt/vdb1
Please note that if the system is Centos 7 or above, you must use the nofail parameter when writing in fstab. Otherwise, if you create a private image for the current Virtual Machines, the new Virtual Machines created based on this private image will not start normally.