Linux mounting hard disk tutorial

Make sure you have the hard drive plugged in and the system recognizes it correctly. You can use one of the following commands to check whether the system detects the hard drive:

fdisk -l
 

In Linux, the hard disk needs to be mounted to a directory before it can be used. Therefore, you need to create a mount point first. You can use the following command to create a mount point:

sudo mkdir /mnt/mydisk
 

If the new hard drive is not partitioned or formatted, it needs to be partitioned and formatted. Partitioning can be done using tools such as fdisk or parted. Formatting can use the mkfs command, for example:

sudo mkfs.ext4 /dev/sdb1
 

Use the following command to mount the hard disk to the mount point:

sudo mount /dev/sdb1 /mnt/mydisk
 

You need to replace /dev/sdb1 with the device name of your own hard disk, and /mnt/mydisk with the mount point directory you created yourself.

If you want to automatically mount the hard disk every time you boot, you can modify the /etc/fstab file and add the following line:

/dev/sdb1 /mnt/mydisk ext4 defaults 0 0
 

Among them, /dev/sdb1 is the hard disk device name, /mnt/mydisk is the mount point directory, ext4 is the file system type, defaults is the mount option, 0 and 0 both represent Dump and fsck options, and the default is enough.

Save and exit the /etc/fstab file.

At this point, the tutorial on mounting a hard disk in Linux is over.

Guess you like

Origin blog.csdn.net/Python_life/article/details/131000907