Content is empty
If you don't find the content you expect, please try another search term
Last updated:2021-07-01 14:37:51
Linux operating systems allow you to directly create file systems on raw disks. If you do not need to create logical partitions such as /dev/vdb1 or /dev/vdb2 on your data disk, you can directly create a file system on the raw data disk. This topic describes how to create a file system on a raw data disk in the Ubuntu operating system.
The following procedure shows you how to create an ext4 or XFS file system on a data disk with a capacity of 2,400 GB. The data disk is attached to a KEC instance that runs 64-bit Ubuntu 16.04. After you configure the file system, you can mount the file system to the /mnt/data_disk01 directory and configure the file system to be automatically mounted upon operating system startup.
Note: By default, the device names of data disks are assigned by the system, which ascend from /dev/vdb to /dev/vdz.
Procedure
Run the following command to view the information about the EBS volumes on the KEC instance:
fdisk -l
The following figure shows the output. The following table describes the information extracted from the figure. | EBS volume | Partition | Partition description |
---|---|---|---|
/dev/vda is the system disk with a capacity of 50 GB. | /dev/vda1 | MBR partition, with a capacity of 50 GB | |
/dev/vdb is a data disk with a capacity of 2,400 GB. | /dev/vdb | No partition |
Note: If the /dev/vd* data disk that you purchase is not displayed in the command output, check whether the data disk is attached to the instance. In this example, the data disk is /dev/vdb. For more information about how to attach a data disk to a KEC instance in the EBS console, see Attach an EBS volume.
Run the mkfs.<fstype> <Data disk name>
command to create a file system. In this example, create an ext4 file system.
To create an ext* file system, for example, ext4, run the following command:
Create a file system for the /dev/vdb data disk
mkfs.ext4 /dev/vdb
The following figure shows the output.
Note: In the preceding command,
/dev/vdb
is the data disk name. You must change it based on your business requirements.
To create an XFS file system, run the following command:
Create a file system for the /dev/vdb data disk
mkfs.xfs -f /dev/vdb
The following figure shows the output.
Note: In the preceding command,
/dev/vdb
is the data disk name. You must change it based on your business requirements.
mkdir <Mount point>
command to create a mount point for the data disk. In this example, create a mount point named /mnt/data_disk01
.
mkdir /mnt/data_disk01
mount <Data disk name> <Mount point>
command to mount the data disk. In this example, mount the /dev/vdb
data disk to the /mnt/data_disk01
mount point.
mount /dev/vdb /mnt/data_disk01
df -Th
The following figure shows the output.
Description of optional actions If you want the data disk to be automatically mounted to the KEC instance when the KEC instance starts or restarts, perform the following steps to add the information about the data disk to the /etc/fstab file.
Confirm the mount method and obtain the required information. An EBS volume can be automatically mounted by using the UUID or name of the EBS volume. Perform the corresponding operation to obtain the UUID or name.
To obtain the UUID of the /dev/vdb data disk, run the following command:
blkid /dev/vdb
To obtain the information about the data disk, run the following command:
lsblk
The following figure shows the output. Note: If you detach or delete an EBS volume from a running KEC instance, the names of other EBS volumes attached to the KEC instance may change. We recommend that you reference an EBS volume by adding the UUID of the EBS volume to the /etc/fstab file.
Run the following command to back up the etc/fstab file:
cp /etc/fstab /etc/fstab.bak
/dev/vdb
data disk to the /mnt/data_disk01
mount point.
echo 'UUID=acafe6be-158e-4f22-8d08-6d9bae8af2c2 /mnt/data_disk01 ext4 defaults 0 0' >> /etc/fstab
echo '/dev/vdb /mnt/data_disk03 ext4 defaults 0 0' >> /etc/fstab
cat /etc/fstab
command to view the auto-mount configuration.
cat /etc/fstab
The following figure shows the output.
mount -a
If the command is successfully run, the /etc/fstab file is successfully configured, and the file system created on the data disk will be automatically mounted when the operating system starts.
Pure Mode