CentOS cloud server data disk partition and format

The newly purchased CentOS cloud server cannot be used because the data disk has not been partitioned and formatted.
Please follow the steps below to partition and format the data disk, and mount the partition to make the data disk available.
Contents1
. View data disk information2
. Data disk partition3
. View new partition4
. Format new partition5.
Mount new partition6
. Add partition information1
. View data disk information After
logging in to the CentOS cloud server, you can use "fdisk -l" command to view information about the data disk.
Unpartitioned and formatted data disks cannot be seen using the "df -h" command.
disk.png

2. Data disk partition Run
the following commands to partition the data disk.
fdisk /dev/xvdb
Follow the interface prompts, enter "n" (new partition), "p" (new extended partition), "1" (use the first primary partition), press Enter twice (use the default configuration), Type "wq" (save partition table) to start partitioning.
Here is an example of creating one partition. Users can also create multiple partitions according to their own needs.
fdisk.png

3. View the new partition
Use the "fdisk -l" command to check that the new partition xvdb1 has been created.
partition.png

4. Format the new partition
When formatting the partition, the user can decide the format of the file system, such as ext2, ext3 and so on.
Here is an example of "ext3":
Format the new partition with the command below.
mkfs.ext3 /dev/xvdb1

format.png

5. Mount the new partition
Use the command "mkdir /mydata" to create the mydata directory, and then manually mount the new partition with the "mount /dev/xvdb1 /mydata" command, then use the "df - h" command to view, the following information appears indicating that the mount is successful, and the data disk can be viewed.
mount.png

6. Add partition information
If you want the cloud server to automatically mount the data disk when it is restarted or powered on, the partition information must be added to /etc/fstab. If it is not added, the data disk cannot be automatically mounted after the cloud server is restarted or powered on.
Use the "echo '/dev/xvdb1 /mydata ext3 defaults 0 0' >> /etc/fstab" command to add partition information, and use the "cat /etc/fstab" command to view it. The following information appears, indicating that the partition information was added successfully.
fstab.png

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327038317&siteId=291194637