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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eric-lo.gitbook.io/lab9-filesystem/important-commands/mount.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
