Detailed description of CentOS data disk partition mounting and formatting

Source: Internet
Author: User
Tags mkdir centos

1. Common CentOS system

Related tools:

CentOS6.5 64bit

Putty

Data Disk

First, check whether the hard disk device has a data disk.

Unlike VPS hosts outside China, cloud host products in China are generally purchased, such as Alibaba Cloud hosts and Tencent Cloud hosts. Because the free system disk storage capacity is small, most of them will purchase additional data disks. First, check the host storage. Command:

Fdisk-l

We can see that the data disk with GB is not mounted, and the path of the data disk is/dev/vdb.

2. Data disk partitioning

Use the following command to partition the data disk

Fdisk/dev/vdb

Input n, p, 1, press enter, press enter, and wq

The path name of the data disk must be accurate. If the path name is different, replace it with your actual path name.

Third, ext3 format partition

Use the following command to format the data disk

Mkfs. ext3/dev/vdb1

4. Mount a new partition

1-create a directory

Mkdir/home

Create a directory name based on your own situation and needs. Because the LNMP environment used by the benefit file needs to be installed in HOME, create a/home directory.

2-Mount partitions

Mount/dev/vdb1/home

Fifth, write fstab to set automatic mounting upon startup

Echo '/dev/vdb1/home ext3 defaults 0 0'>/etc/fstab

6. Check whether the mounting is successful.

Df-h

Two drive letters are displayed, and the 247 GB (250 GB) has been mounted and mounted to the/home directory.

II. centos system of Tencent Qcloud

1. View data disk information

After logging on to the CentOS ECS, you can useFdisk-l"Command to view information about the data disk.
Use"Df-h"Command to see unpartitioned and formatted data disks.

 

2. Data disk partitioning

Run the following command to partition the data disk.
Fdisk/dev/xvdb

Enter "n" (new partition), "p" (new extended partition), and "1" (use 1st primary partitions) as prompted on the page ), press enter twice (use the default configuration), enter "wq" (save the partition table), and start partitioning.
This example uses creating one partition. You can also create multiple partitions as needed.

 

3. View New partitions

Use"Fdisk-lYou can see that the new partition xvdb1 has been created.

 

4. Format the new partition.

During partition formatting, you can determine the format of the file system, such as ext2 and ext3.
The following uses "ext3" as an example:
Use the following command to format the new partition.
Mkfs. ext3/dev/xvdb1

 
5. Mount a new partition

Run the"Mkdir/mydata"Create the mydata directory, and then use"Mount/dev/xvdb1/mydata"Command to manually mount the new partition, use"Df-hCommand to view, the following information indicates that the mounting is successful, you can view the data disk.

 

6. Add partition information

To automatically mount a data disk when the ECS instance is restarted or started, add the partition information to/etc/fstab. If no data disk is attached, the data disk cannot be automatically attached after the ECS instance is restarted or started.
Use"Echo '/dev/xvdb1/mydata ext3 defaults 0 0'>/etc/fstab"Command to add partition information, use"Cat/etc/fstabCommand to view, the following information indicates that the partition information is successfully added.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.