1. All Documents
Linux system has a concept: "Everything is a file", so the hardware of the computer in Linux is also in the form of "file" in the/dev directory.
The figure is part of the/dev directory in the CentOS 6.5 system. Different computers display similar content.
For example, the CD-ROM corresponding to the file is/dev/cdrom,cpu corresponding file is/dev/cpu. And the hard disk corresponds to the/dev/sd*. The first hard drive is/DEV/SDA, and the second disk is/dev/sdb.
However, a disk is usually divided into multiple partitions, so the partition is appended to the disk file followed by the ordinal of the partition. Refer to the examples in the table below.
Partition |
The corresponding path |
Section 1 of the first hard drive |
/dev/sda1 |
Section 2 of the first hard drive |
/dev/sda2 |
The first 2 partitions of the second hard drive |
/dev/sdb2 |
2. Create partitions
2.1 Create a partition using the Cfdisk command.
This example uses the/DEV/SDB disk in the previous illustration to demonstrate.
Start using the Cfdisk command to enter the Cfdisk interface.
Cfdisk/dev/sdb
[new]--[primary]--manually enter the partition capacity, in M. Enter, create success.
Finally select [Write], enter "Yes", and write the configuration to disk.
SELECT [Quit] to exit Cfdisk.
Ps:cfdisk command does not support GPT partition format temporarily
2.2 Format Partition MKFS
MKFS-Support ext2, ext3 (log), Ext4, VFAT, Msdos, JFS, ReiserFS, etc.
Usage 1:mkfs-t <fstype> <partition>
Cases:
Usage 2:mkfs.<fstype> <partition>
Cases:
This example is
PS: After formatting a partition, you can use the E2label command to add a volume label to the partition
E2label Partition path Volume label name
3. Mount Partition
Tip: Use the df-h command to view the partitions that are already mounted on the current system
3.1 Manually mount partitions
Mount-t/DEV/SDB1/MNT/SDB1
Uninstall partition umount command format:
umount [option] special | Node
When you uninstall a partition by using Umount, you can specify the mount point, or you can specify the path to mount
For example, to uninstall the mount of the SDB1 partition, use the
UMOUNT/DEV/SDB1 or UMOUNT/MNT/SDB1.
PS: When using Umount Uninstall, if the device path is specified, Umount will unload the mount point that the partition was last mounted in the Mount order.
3.2 Automatic Mount Partition
The Linux system mounts partitions automatically from the/etc/fstab file when it is started.
The figure is an example of a fstab file.
In Fstab, each configuration information is divided into 6 fixed parts
[1]: partition path, or UUID
[2]:fs_file-This field describes the directory points that you want the filesystem to load, none for swap devices, or spaces for loading directory names that contain spaces, 40来.
[3]:fs_type-Defines the file system on the device, generally common file types are Ext4 (common file types for Linux devices), VFAT (FAT32 format for Windows systems), NTFS, isoArray600, and so on. Auto can be used in case of uncertainty.
[4]:fs_options-Specifies that the file system that loads the device is a specific parameter option that needs to be used, and that multiple parameters are separated by commas.
For most systems, "defaults" can be used to meet your needs. Don't say much.
[5]:fs_dump-This option is used by the ' Dump ' command to check how quickly a file system should be dumped, if no dump is required
Set this field to 0
[6]:fs_pass-This field is used by the fsck command to determine the sequence of file systems that need to be scanned at startup, the root file system "/" to the word
The value for the segment should be 1, and the other file system should be 2. Set this field to 0 if the file system does not need to be scanned at boot time
In this example, the configuration of the SDB1 partition automatic mount is added to the Fstab file as follows:
/DEV/SDB1 /mnt/sdb1 ext4 defaults 0 2
PS: Other accounts (such as ORAC, MySQL) in the use of this new partition, you may encounter problems with insufficient permissions, use the following command to resolve
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.