How to mount a hard drive with data on CentOS?
To mount a hard drive with data on CentOS, you can follow the steps below:
- Make sure the hard drive is connected to the computer and recognized. You can use the commands lsblk or fdisk -l to view the device name of the hard drive, such as /dev/sdb.
- Create a directory for mounting a hard drive, such as /mnt/data. Use the following command to create the directory:
- Create a new directory named “data” inside the “mnt” directory using superuser privileges.
- Use the lsblk command or fdisk -l command to check the partition situation of the hard drive. If the hard drive is not partitioned, you can skip this step.
- Choose the partition to mount based on the hard disk partition layout. For example, if you want to mount the data on /dev/sdb1 partition, you can use the following command:
- Elevate to root privileges in order to mount the device located at /dev/sdb1 to the directory /mnt/data.
- If the hard drive is not partitioned, you can directly mount the entire hard drive to a specified directory, for example:
- Require elevated permissions to mount /dev/sdb to /mnt/data.
- To verify a successful mount, you can use the command df -h to check the mounting status. If the mount is successful, you should see the mount point for /dev/sdb1 or /dev/sdb as /mnt/data.
- To ensure that the hard drive is automatically mounted after the system reboots, you can add the mounting information to the /etc/fstab file. You can open the /etc/fstab file using the following command.
- Open the file /etc/fstab using the command sudo vi.
- Then add the following content at the end of the file (assuming you want to mount the /dev/sdb1 partition):
- Use the default settings to mount the ext4 filesystem on /dev/sdb1 to the /mnt/data directory.
- Save and close the file.
You have successfully mounted a disk with data on CentOS. You can access the data on the disk by accessing the /mnt/data directory.