Mount external hard disk in Linux environment

I. Introduction

In the process of debugging ARTIK, the external hard disk will not be automatically mounted for the first time, and the hard disk needs to be mounted under the system folder to read the contents of the hard disk. Therefore, the method of mounting the hard disk and automatically mounting the external hard disk configuration under the Ubuntu system is summarized. .

2. Mount the external hard disk steps

  1. Use the command fdisk -l to view hard disk resource information
	sudo fdisk -i

insert image description here

insert image description here

Here /dev/mmcblk1p4 is the 16GB hard disk mounted externally

  1. Create a hard disk mount directory

Create a folder disk in the ~ directory to mount the hard disk

	sudo mkdir disk

insert image description here

  1. Mount the hard disk to the folder

Mount the hard disk /dev/mmcblk1p4 to the disk folder, add permissions to the folder through chmod 777 disk, and enter the disk directory to read the contents of the external hard disk

	sudo mount /dev/mmcblk1p4 disk
	sudo chmod 777 disk
	cd disk

insert image description here

  1. The hard disk is unmounted from the mount point

Hard disk devices can be unmounted by device name or mount point

	sudo umount -v disk #通过挂载点卸载	
	sudo umount -v /dev/mmcblk1p4 #通过设备卸载

3. Automatic mount method at startup

The hard disk needs to be remounted every time it is turned on, so it is necessary to configure the /etc/fstab file to make the hard disk automatically mount when it is turned on

	sudo vim /etc/fstab

Add the following configuration at the end of the /etc/fstab file

	/dev/mmcblk1p4 /home/artik/disk ext4 defaults 0 0 

Mount the device /dev/mmcblk1p4 to /home/artik/disk, and the external hard disk can be automatically mounted after booting

Guess you like

Origin blog.csdn.net/weixin_43361652/article/details/128454072