Linux hard disk partition, partition, delete partition, format, mount, detach, linux Mount

Source: Internet
Author: User

Linux hard disk partition, partition, delete partition, format, mount, detach, linux Mount
1. Create a partition

Check whether the disk is not partitioned.

fdisk -l  

The first and second boxes are the disks that have been divided into different zones.

Start partitioning

# Enter the name of the disk to be partitioned
Fdisk/dev/sdb

 

Enter m to view the operations

Enter p to view the current hard disk partition. Currently, there is a partition.

Enter n to create a partition, enter p to create a partition, and enter Partition Number 2 to create a second partition.

Then, you will be asked to set the start sector. If you press enter directly, it means that you do not enter the information and divide the data directly from the starting part of the vacant disk.

Then, end the slice and set the custom partition to 300 GB, which can be divided as needed. Note that the "+" setting must be added before GB.

If you want to create a third partition, enter n, p, and then define the partition size.

Last save partition input w

Finally, check whether the partition has been created! If the red area appears, it indicates that it has been created.

 

In fact, the created partitions are not available yet and need to be mounted for use. However, before mounting, you must format it.

2. format the partition

1) fdisk-l | grep sd view partition information

Or fdisk-l

2) create a data storage directory and customize the storage path

Mkdir-p/openstack/glance

Mkdir-p/openstack/mysql

Mkdir-p/openstack/data

......

3) format the partition disk.

Mkfs. xfs/dev/sdb1 format sdb1 Disk

Mkfs. xfs/dev/sdb2 format sdb2 Disk

Mkfs. xfs/dev/sdb3

......

4) vim/etc/fstab

/Dev/sdb1/openstack/glance/xfs defaults 0 0
/Dev/sdb2/openstack/mysql/xfs defaults 0 0
/Dev/sdb3/openstack/data/xfs defaults 0 0

 

The/etc/fstab file is used to configure partitions automatically mounted when Linux is started.

The first column can be the actual partition name or the Lable of the actual partition)

The second column is the mount point. The mount point must be an existing Directory.

The third column is the file system type for this partition.

The fourth column is the mounting option, which is used to set the mounting parameters.

Auto: automatic mounting. fstab is the default option.
Ults: rw, suid, dev, exec, auto, nouser, and async.
Noauto is not automatically mounted upon startup
Nouser can be mounted only by Super Users.
Ro mounting by read-only permission
Rw mount by read/write permission
User any user can mount
Note that the optical drive and soft drive can be mounted only when the media is installed, so it is noauto

 

The Fifth Column is the dump Backup Settings. When the value is set to 1, the dump backup program is allowed to back up; when the value is set to 0, the backup operation is ignored;

The sixth column is The fsck disk check settings. The values are in an order. When its value is 0, it will never be checked; and The/root directory partition will always be 1. When other partitions start from 2, the smaller the number, the first check. If the numbers of the two partitions are the same, check at the same time.

 

5) mount-a to attach a disk

6) df-a to view the mounting status

 

3. unmount

1) fdisk-l | grep sd view partition information

Or fdisk-l

2) umount/dev/sdb3 unmount sdb3.

The unmount function can be mounted, and the data will be stored.

4. delete partitions
fdisk /dev/sdb  m  d  3  w

Enter w to save. At this time, the partition is deleted and you can recreate it.

 

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.