Ali cloud after a new data disk to mount ECS instance, you must create and mount at least one file system. This example uses the I / O optimization example, the operating system CentOS 7.6, a single partition 300GiB new data disk (device name / dev / vdb) Create a MBR format ext4 file system is mounted.
- Remote Connection
- Run
fdisk -l
command to view the data plate on the instance.
NOTE After the command, if there is no
/ dev / vdb, you no instance data disk. Are you sure the data disk is mounted.
- Run the following command in turn, create a partition.
- Run
fdisk -u /dev/vdb
command data disk partition.
- Enter the ppartitioning view the data disk.
In this example, no data disk partition.
- Enter nto create a new partition.
- Input pSelect partition type primary partition.
Instructions to create a single data disk partitions can be created only primary partition. If you want to create more than four partitions, you should choose at least once
e
(extended), create at least one extended partition.
- Enter the partition number and press Enter.
In this example, only to create a partition, input
1
.
- Enter the first available sector number, press the ENTER key to the default value 2048.
- Enter the last sector number.
In this example, only to create a partition,
press the Enter
key to the default value.
- Enter pto see the zoning case data disk.
- Enter wthe beginning of the partition, and quit after the completion of the partition.
4.运行fdisk -lu /dev/vdb
命令查看新分区。
如果出现/dev/vdb1的相关信息,表示新分区已创建完成。
5.
运行mkfs.ext4 /dev/vdb1
命令在新分区上创建一个文件系统。
本示例中,创建一个ext4文件系统。其他文件系统格式请自行修改mkfs.ext4命令。例如,如果您需要在Linux、Windows和Mac系统之间共享文件,可以运行mkfs.vfat /dev/vdb1
命令创建VFAT文件系统。
6.向/etc/fstab写入新分区信息,启动开机自动挂载分区。
- 运行命令
cp /etc/fstab /etc/fstab.bak
,备份etc/fstab。
- 运行命令
echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstab
,向/etc/fstab里写入新分区信息。
如果要把数据盘单独挂载到某个文件夹,例如单独用来存放网页,则将命令中/mnt
替换成所需的挂载点路径。
7.运行cat /etc/fstab
命令查看/etc/fstab中的新分区信息。
8.运行mount /dev/vdb1 /mnt
命令挂载文件系统。
如果运行
df -h
命令后出现新建文件系统的信息,表示文件系统挂载成功。
来自阿里云,方便记录