# Mount

The `mount` command mounts a storage device or file system, making it accessible and attaching it to an existing directory structure. This attached directory is called a **mount point**. In this way, users can access a storage device or filesystem just like a normal directory.

Remember to **unmount** after using, otherwise the file system is not fully synchonized, which will cause loss of data.

## Steps <a href="#steps" id="steps"></a>

1. First, create a **mount point**:

   ```
   $ mkdir ~/rd
   ```
2. Then, we mount the disk to the **mount point**:

   ```
   $ sudo mount -t vfat -o loop test.disk ~/rd
   ```
3. After that, we can unmount the disk by:

   ```
   $ sudo umount ~/rd
   ```

## How to solve device busy problem  (Study by yourself) <a href="#how-to-solve-device-busy-problem" id="how-to-solve-device-busy-problem"></a>

There is the case where a process continously occupies the device such that you cannot unmount it.![](https://2015623591-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lp-5TQpuuM0wVgRDmqL%2F-Lp-5WZ7mVLwEZ2xvCJW%2F-Lp-5bP8VTYZk3V9kE2W%2Fumount_failed.png?generation=1568738587072122\&alt=media)

In this case,we can make use of either one of the two commands to locate the process.

### Method 1: lsof <a href="#method-1-lsof" id="method-1-lsof"></a>

```
$ lsof ~/rd
```

![](https://2015623591-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lp-5TQpuuM0wVgRDmqL%2F-Lp-5WZ7mVLwEZ2xvCJW%2F-Lp-5bPA-OGFF70SQ_nW%2Flsof.png?generation=1568738586998102\&alt=media)

### Method 2: fuser <a href="#method-2-fuser" id="method-2-fuser"></a>

```
$ fuser -vm ~/rd
```

![](https://2015623591-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lp-5TQpuuM0wVgRDmqL%2F-Lp-5WZ7mVLwEZ2xvCJW%2F-Lp-5bPCcp5aCqpyqh-D%2Ffuser.png?generation=1568738587221735\&alt=media)

By these two commands, you can know `tail` with PID 11793 is occupying the resource. By killing it using`kill -9`, you can umount the resource successfully.
