See this article on my own blog https://dyingdown.github.io/2020/01/29/Mount-mechanical-hard-disk-on-Linux/
I’ve met a new problem recently: I switched into Linux but my Blog folder is under my mechanical hard disk. I want my Blog folder available to be achieved by command not manually. So to make this come true, I learned a word mount. By using mount, you can use my blog folder by command. There are three steps:
- create a new folder
- mount the disk
- make it mount automatically as long as booting Linux
What is mount
First, you need to know that all the things in Linux is represented as file directory. Your mechanical hard disk is not a folder. So you need to make it a folder in Linux. It’s like you wrap the disk using a folder, make it looks like a folder so that Linux can access it. That is how I understand Mount.
Mounting is a process by which the operating system makes files and directories on a storage device (such as hard drive, CD-ROM, or network share) available for users to access via the computer’s file system.[1]
In general, the process of mounting comprises operating system acquiring access to the storage medium; recognizing, reading, processing file system structure and metadata on it; before registering them to the virtual file system (VFS) component. ——Wikipedia
And the folder you use to wrap you disk is called Mount point.
Create a new directory
You can make it anywhere.
Take mine for example. I set the directory under /home/o_oyao directory.
See recent directory
type to see what directory you are in now.
pwd
I got:
/home/o_oyao
Create an new directory
using mkdir to create and rmdir to delete.
I want my directory under home/o_oyao and it’s name is Yao, so I typed:
mkdir Yao
There is no notification to show that you have successfully created the directory, to make sure it works, you can type command “ls” (no double quotes), to see all the directories.
If you want your dierectory to be somewhere else, check Absolute path and Relative path to see how to do.
Temporary mount
First type the following command to see what is the name of your disk.
df -h
So my disk name is sda2. Because the size of my disk is very large compared to other section.
So the command is:
sudo mount /dev/sda2 Yao
Now you open the directory you created, you can see all the things in your disk are now in the directory.
Permanent mount
Check the type of your file system
gparted
And it opens a new window.
So my type is “ntfs”. Yours might be “ext4”
Add a statement
type the following command:
sudo gedit /etc/fstab
open this file, and add a piece of data in it. If you know how to use vim, you can also type.
sudo vim /etc/fstab
I got this:
(UUID is the unique id of the file system, it can also be represented as directory)
add a new statement
/dev/sda2 /home/o_oyao/Yao ntfs defaults 0 2
It looks Like this:
Save it.
Restart
All done! Restart computer and check whether it works.