Attach a new hard disk to fdisk in centos 7
Note:
The fdisk tool does not support GPT. For GPT-format partitions, you need to use the powerful partition tool parted released by GNU.
-
++
Basic commands:
Fdisk # disk partition
Mkfs # format each partition
++
Common options for fdisk interactive commands
Example:
The system has two disks, SDA and SDB. SDA has been divided and partitioned and formatted for use. SDB is a disk without any operation.
Now we need to divide the 32 GB disk of SDB into two partitions, one 10 GB and the other 22 GB. And mount to/app-sdb1 and/app-sdb2 directory.
Start partitioning/dev/SDB
Fdisk/dev/SDB
Enter n to create a partition (primary partition or extended partition), Partition Number (1-4), Sector, partition size (10 Gb)
Create a 10 Gb partition and use P to view it
When creating the second disk partition, you do not need to enter the partition size at the end, indicating that all the remaining capacity is allocated to this partition. Finally, use P to view
After the two are distinguished, input W to save all the operations before
Format two partitions
Mkfs. XFS
To mount a formatted partition, you must first create two directories to partition and mount the two partitions.
Mkdir/app-sdb1-10GB
Mkdir/app-sdb2-22GB
Finally, use DF-h to check whether the mounting is successful.
Change the partition type of a disk partition
Currently, the partition types of the two partitions are XFS. Here we want to convert the sdb2 partition to the NTFS partition type.
Fdisk/dev/SDB
After the restart, mount the file to the corresponding directory and the original file also exists. If you format the partition, the data will be lost.
Attach a new hard disk to fdisk in centos 7