How to mount partitions in CentOS?
In CentOS systems, you can mount disk partitions by following these steps:
- Confirm disk partitions: Use the command lsblk or fdisk -l to view disk and partition information in the system.
- Create a mount point: Choose a directory to be the mount point for the disk partition, such as /mnt/data. You can create the mount point using the following command:
- Create a new directory called “data” in the “/mnt” directory.
- Mount partition: Use the mount command to mount the partition to the mount point. The syntax is as follows:
- Please mount the partition device named [分区设备名] to the /mnt/data directory using the sudo command.
- The [partition device name] is the name of the partition device file to be mounted, such as /dev/sdb1.
- Verification of mounting: You can use the command ‘df -h’ to view a list of mounted partitions and confirm if the newly mounted partition is included in the list.
- Automatic mounting: In order to automatically mount a partition after system reboot, you need to add the corresponding mount information in the /etc/fstab file. You can open and edit this file using the following command:
- Open the file /etc/fstab using the sudo command with vi editor.
- Append a line at the end of the file with content similar to the following (using ext4 file system as an example):
- /dev/[partition device name] /mnt/data ext4 defaults 0 0
- Save and exit the editor.
- Re-mounting: To apply the mounting information in the /etc/fstab file, you can use the following command to re-mount all file systems.
- Please execute the command “mount -a” with superuser privileges.
After completing the above steps, the partition will be successfully mounted to the designated mount point.