How to mount partitions in CentOS?

In CentOS systems, you can mount disk partitions by following these steps:

  1. Confirm disk partitions: Use the command lsblk or fdisk -l to view disk and partition information in the system.
  2. 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:
  3. Create a new directory called “data” in the “/mnt” directory.
  4. Mount partition: Use the mount command to mount the partition to the mount point. The syntax is as follows:
  5. Please mount the partition device named [分区设备名] to the /mnt/data directory using the sudo command.
  6. The [partition device name] is the name of the partition device file to be mounted, such as /dev/sdb1.
  7. 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.
  8. 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:
  9. Open the file /etc/fstab using the sudo command with vi editor.
  10. Append a line at the end of the file with content similar to the following (using ext4 file system as an example):
  11. /dev/[partition device name] /mnt/data ext4 defaults 0 0
  12. Save and exit the editor.
  13. Re-mounting: To apply the mounting information in the /etc/fstab file, you can use the following command to re-mount all file systems.
  14. 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.

Leave a Reply 0

Your email address will not be published. Required fields are marked *