Ali Cloud Linux formatted data disks, partitions and mount a file system

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.

  1. Remote Connection
  2. Run fdisk -lcommand 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.
  3. Run the following command in turn, create a partition.
    1. Run fdisk -u /dev/vdbcommand data disk partition.
    2. Enter the ppartitioning view the data disk.
      In this example, no data disk partition.
    3. Enter nto create a new partition.
    4. 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.
    5. Enter the partition number and press Enter.
      In this example, only to create a partition, input 1 .
    6. Enter the first available sector number, press the ENTER key to the default value 2048.
    7. Enter the last sector number.
      In this example, only to create a partition, press the Enter key to the default value.
    8. Enter pto see the zoning case data disk.
    9. 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写入新分区信息,启动开机自动挂载分区。

  1. 运行命令cp /etc/fstab /etc/fstab.bak,备份etc/fstab。
  2. 运行命令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命令后出现新建文件系统的信息,表示文件系统挂载成功。

来自阿里云,方便记录

Guess you like

Origin www.cnblogs.com/hiit/p/12106099.html