Format and Mount Data Disks
Last updated: 2018-08-06 15:39:45PDF
- After formatting, all the data in the data disk will be cleared. Before formatting, make sure there is no data in the data disk or important data has been backed up. To avoid service exceptions, ensure that the CVM has stopped external services before formatting.
Manual Formatting and Mounting Data Disk
Format and mount a data disk by following the steps below.
- When executing the following commands, remember to modify the data disk drive letter. The drive letter is
vdbin this example.
Step 1: Format the data disk
When formatting partitions, developers can decide the file system format on their own, such as
ext4is used in this example.
Format the data disk by performing the mkfs command:
Step 2: Mount the data disk
Create a mount point - data directory:
Mount new partitions:
mount /dev/vdb /data
Verify whether the data disk is mounted successfully:
The following message indicates that it is mounted successfully (i.e. the data disk is mounted on the Linux CVM):
Filesystem Size Used Avail Use% Mounted on /dev/vdb 50G 53M 47G 1% /data
Step 3: Enable auto mount upon launch
Add the data disk mount information to
/etc/fstab to enable auto mount upon launch.
To allow your CVM to be automatically mounted with data disk when it is restarted or launched, add the mount information to
/etc/fstab. Otherwise, the data disk cannot be automatically mounted to the CVM when the CVM is restarted or launched.
- Execute the following command to add partition information:
echo '/dev/vdb /data ext4 defaults 0 0' /etc/fstab
- Execute the following command to view the partition information:
The following message indicates that the data disk mount information is added successfully.
/dev/vdb /data ext4 defaults 0 0
Auto Formatting and Mounting Data Disk
You can format and mount a data disk on Tencent Cloud Linux CVM by running the following Shell script:
type=ext4 mount_dir=/data mkfs.$type /dev/vdb mkdir -p $mount_dir echo "/dev/vdb $mount_dir $type defaults 0 0" >> /etc/fstab mount -a