ORIGIN

How to mount mechanical hard disk on Linux

BlogLinux 3 mins526 words

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:

  1. create a new folder
  2. mount the disk
  3. 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.

1
pwd

I got:

1
/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:

1
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.

1
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:

1
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

1
gparted

And it opens a new window.

So my type is “ntfs”. Yours might be “ext4”

Add a statement

type the following command:

1
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.

1
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

1
/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.

TOP
COMMENT
  • ABOUT
  • |
o_oyao
  The Jigsaw puzzle is incomplete with even one missing piece. And I want to be the last piece to make the puzzle complete.
Like my post?
Default QR Code
made with ❤️ by o_oyao
©o_oyao 2019-2024

|