# \[Guide\] Auto-Mounting Filesystems in Linux

**URL:** <https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761>\
**Category:** Software\
**Tags:** guide, official\
**Created:** [September 5, 2019, 6:40am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761 "2019-09-05T06:40:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mthrboard](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/mthrboard/32/3288_2.png) [@Mthrboard](https://forums.serverbuilds.net/u/Mthrboard)\
**Post date:** [September 5, 2019, 6:40am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/1 "2019-09-05T06:40:41Z")

</div>

If you’re like me and use NFS to share files between multiple servers, you may occasionally run into a connection issue when you reboot - if the client comes up before the server, it won’t mount the NFS filesystems automatically. If you’re around, you can just remount them manually, but if it happens when you’re away you could be out of luck. One way to make sure this doesn’t happen is to use autofs for your NFS mounts. It’s super easy to set up, and once it’s configured the filesystems will mount and remount automatically whenever they are accessed, as long as the remote system is available.

Before we begin, I should note that autofs will **NOT** fix `stale file handle` errors. That’s a separate issue that is usually caused by hard links on union filesystems. If you get these stale file errors in unraid, you should disable hard links. You can find this setting under `Settings` \> `Global Shares Settings`. Look for `Tunable (support Hard Links):` and set it to `No`. Once you’ve made this change, reboot both your unraid system and your ubuntu system and you should be back in business.

> **Prerequisites**
>
> - If you haven’t already done so, make sure you disable automatic emptying of the trash in Plex. Go to `Settings` \> `Library`, and uncheck the option `Empty trash automatically after every scan`, then scroll down and save your changes. This will prevent Plex from deleting any custom posters or metadata you may have in the event that something goes wrong and Plex can’t find your files.

> **0. Install autofs**
>
> - Open a terminal and run the following command to install autofs:

> **1. Configure autofs**
>
> - You need to edit a couple of configuration files using your favorite text editor. I recommend using nano if you’re new to linux, so these steps will use nano.

> **2. Disable and remove the previous mounts**
>
> - Now that the auto-mounting is configured, you’ll need to disable the standard mounting of the folders in `fstab`, if you are re-using the folders for the autofs mounts.

> **3. Restart the autofs service**
>
> - Now that the folders are unmounted and the configuration files have been updated, you need to restart the autofs service so it will read the new configuration. Run the following command to start the service:
> 
> - Next, verify the service started correctly by running:
> 
> - Change to one of the folders you want mounted and make sure you can see files in the folder. Run `ls /mnt/nfs/tv` for my example. This may take a few seconds to load the first time, but as long as it shows your files, then you’re nearly done. If it doesn’t show anything, double-check the configuration files above to make sure the folders and parameters were all spelled correctly, then restart the autofs service again and repeat this step.

> **3.5 Special Note for Plex Libraries**
>
> - If you already have your Plex libraries configured with your old folders from the `fstab` file, you will need to do one of two things:
> 1. Edit your libraries in Plex for the new folders (follow these same steps for every library you have)
> - Add the new folders where your media is located. **DO NOT** delete the old folder from the library yet.
> - Rescan the library if it doesn’t start scanning automatically.
> - Once finished scanning, edit the library again and remove the old folder.
> - Empty the Plex trash to remove the entries from the old folder
> 
> 2. Create a symbolic link pointing the old folder to the new folder (follow these steps for every library you have)
> - In the terminal, enter the following command `ln -s /<new_media_folder> /<old_media_folder>`
> - For example, if my old folder was `/mnt/tv` and my new folder is `/mnt/nfs/tv` I would type `ln -s /mnt/nfs/tv /mnt/tv`

> **4. Reboot and verify your work**
>
> - As long as you’ve made it this far, everything should work smoothly on subsequent reboots. While not technically required, I would recommend rebooting the system and checking that the folder mounted properly after the reboot.

---

<div class="post-metadata">

**Author:** ![Etumos](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/etumos/32/216_2.png) [@Etumos](https://forums.serverbuilds.net/u/Etumos)\
**Post date:** [December 23, 2019, 6:01am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/2 "2019-12-23T06:01:57Z")

</div>

Just went through this guide successfully and there are two things I want to emphasize:

1. It is critical that what ever path you put in /etc/auto.master for the parent folder ends in a / is it does not this will not work.
2. It is critical that if you are currently using an fstab set up that you unmount them per the instructions otherwise they will still be running on fstab even if you reboot.
3. It is critical that if you are currently using an fstab set up that you use a different folder inside of /mnt to do your new mounts

These things are more or less stated above but I wanted to be double sure everyone avoids my trials and tribulations

---

<div class="post-metadata">

**Author:** ![COZisBack](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/cozisback/32/204_2.png) [@COZisBack](https://forums.serverbuilds.net/u/COZisBack)\
**Post date:** [February 7, 2020, 3:20pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/3 "2020-02-07T15:20:32Z")

</div>

Here’s what I’m getting on step zero:

 ![image](https://serverbuilds-files.b-cdn.net/original/2X/f/f43524f874086dea2acd3edd09aa5285153b96ab.png)

---

<div class="post-metadata">

**Author:** ![Mthrboard](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/mthrboard/32/3288_2.png) [@Mthrboard](https://forums.serverbuilds.net/u/Mthrboard)\
**Post date:** [February 7, 2020, 3:29pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/4 "2020-02-07T15:29:54Z")

</div>

All of those operations succeeded properly. It looks like you had the support libraries installed already, so it just had to install autofs itself. You’re good to proceed with step 1.

---

<div class="post-metadata">

**Author:** ![COZisBack](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/cozisback/32/204_2.png) [@COZisBack](https://forums.serverbuilds.net/u/COZisBack)\
**Post date:** [February 7, 2020, 3:32pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/5 "2020-02-07T15:32:51Z")

</div>

Thank you. I followed your “[Migrating Plex Metadata from Unraid to Ubuntu](https://forums.serverbuilds.net/t/migrating-plex-metadata-from-unraid-to-ubuntu/2858)” guide, so are there any tweaks I need to make from the guide above?

I have my stuff in “/mnt/user/media” in Unraid and mounted as “/media” in Ubuntu for Plex.

---

<div class="post-metadata">

**Author:** ![Mthrboard](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/mthrboard/32/3288_2.png) [@Mthrboard](https://forums.serverbuilds.net/u/Mthrboard)\
**Post date:** [February 7, 2020, 3:55pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/6 "2020-02-07T15:55:58Z")

</div>

If you migrated your metadata, you’re going to need to do a couple extra steps. Autofs needs exclusive access to whatever root folder you point it at. This is fine if you’re pointing it at a subfolder, like the `/mnt/nfs` folder I use above, but that won’t work if Plex is expecting the media to be in folders directly under the root folder `/`. The good news is there’s an easy workaround in symbolic links. Follow the guide above as normal, throwing your autofs mounts in `/mnt/nfs` or whatever subfolder you want under `/mnt`. Test the mounts to make sure they work, and then, before you reboot, perform the following step for each path you added to autofs:

`sudo ln -s /mnt/nfs/tv /tv` (Substitute your paths as necessary)

Check that they work by typing `ls /tv` and verify that your TV folders are listed properly. After you reboot, run the same command again as a final check.

---

<div class="post-metadata">

**Author:** ![lordmarqui\_US](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/lordmarqui_us/32/3592_2.png) [@lordmarqui\_US](https://forums.serverbuilds.net/u/lordmarqui_US)\
**Post date:** [February 13, 2020, 12:02pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/7 "2020-02-13T12:02:48Z")

</div>

having a new issue and need a hand from the masters… i set this up last year and all was working perfectly until maybe a month ago.

i have sonarr/radarr/lidarr on my anniversary build server, and plex on a separate box running ubuntu, as desrcibed by jdm in the transcode post. shares are mounted within ubuntu as per this thread. all was working perfectly but the other week i noticed that the TV episodes stopped pulling into plex automatically. only the tv shows. movies and music worked fine. but on reboot, tv shows would import correctly into plex.

sonarr is working perfectly fine, as is plex – i’ve posting about them in their respective forums and the logs look good. i’ve traced the problem (i think) to the automounting file system.

This is weird: tv shows stream fine and I’m able to view them without any issue at all. But when I check all the shares in `/mnt` on ubuntu, the `/tv` share isn’t there! But then I run an `ls /mnt` command and all three media directories are present but the `/tv` share is either missing or i cannot `cd /mnt/tv` into it.

Looks like when I reboot `/mnt/tv` is there and an ls command works fine. But after a while I lose it.

No clue how or why this is happening, since all 3 directories are located Within the same unraid share and they’re all streaming fine.

any thoughts?

i’ve retraced all my steps using this post and checked that all settings in `fstab` and `autofs` are correct, which they are. any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Mthrboard](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/mthrboard/32/3288_2.png) [@Mthrboard](https://forums.serverbuilds.net/u/Mthrboard)\
**Post date:** [February 13, 2020, 4:19pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/8 "2020-02-13T16:19:49Z")

</div>

I haven’t experienced your issue, so I don’t have a quick answer for you, but I do have a couple suggestions. First, disable the automatic library scan in Plex, and configure Sonarr, Radarr and Lidarr to use Plex Connect to notify Plex when new media is added. To enable Plex Connect, follow these steps in Sonarr, Radarr and Lidarr:

1. Go to `Settings` \> `Connect`, and click the add button.
2. Select `Plex Media Server` from the available options.
3. Enter a name for your server at the top
4. Enter the IP or hostname for your Plex server in the `hostname` field. Leave all other settings at their defaults.
5. Click the `Authenticate with Plex.tv` button and log in to your Plex account.
6. Click the `Test` button
7. If the test was successful, save the connection.

After you’ve enabled the connections, go into your Plex server settings, and disable the options to `Scan my library automatically` and `Run a partial scan when changes are detected`. You can leave the periodic scan enabled, and set it to run daily.

Run your system like this for a few days and see if the issue comes up again. If it does, then I’d recommend enabling debug logging for autofs temporarily so the logs can hopefully be used to pinpoint the issue. To enable logging, open the file `/etc/autofs.conf` in your text editor, scroll down until you see `# logging = none`, and change it to `logging = debug`. Save the file, then restart the autofs daemon `sudo systemctl restart autofs`. Once debug logging is enabled, **everything** autofs does will be logged in `/var/log/syslog`, hopefully including whatever is causing the issue. If it comes to this point, please note that the `syslog` file isn’t used exclusively by autofs, so the relevant information may be scattered among log lines from other programs. I wouldn’t recommend posting the log file anywhere without filtering it first to display only the automount logs.

---

<div class="post-metadata">

**Author:** ![lordmarqui\_US](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/lordmarqui_us/32/3592_2.png) [@lordmarqui\_US](https://forums.serverbuilds.net/u/lordmarqui_US)\
**Post date:** [February 13, 2020, 4:27pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/9 "2020-02-13T16:27:13Z")

</div>

thanks mthrboard! will make those changes and report back!

---

<div class="post-metadata">

**Author:** ![Mazzy](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/mazzy/32/248_2.png) [@Mazzy](https://forums.serverbuilds.net/u/Mazzy)\
**Post date:** [March 24, 2020, 3:27am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/10 "2020-03-24T03:27:42Z")

</div>

If you are like me and named your unraid Share “TV Shows” you will need to take an extra step in your auto fs command. that hinders you from automounting it.

Replace tv with below:  
“TV\ Shows”

---

<div class="post-metadata">

**Author:** ![WexfordStyle](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/wexfordstyle/32/3975_2.png) [@WexfordStyle](https://forums.serverbuilds.net/u/WexfordStyle)\
**Post date:** [April 9, 2020, 5:15pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/11 "2020-04-09T17:15:24Z")

</div>

I have migrated successfully to autofs on my system. Interestingly enough, I originally wanted to do this because I was getting “stale file handle” when using fstab. Unfortunately, I am still having the same issue.

In checking the logs, I see the following entries repeatedly:

Apr 9 12:49:51 dionysus kernel: [684639.585302] fsid 0:73: expected fileid 0x901000025857ba7, got 0x27000011a31bce  
Apr 9 12:49:51 dionysus kernel: [684639.585797] NFS: server 192.168.86.2 error: fileid changed  
Apr 9 12:49:51 dionysus kernel: [684639.585797] fsid 0:73: expected fileid 0x901000025857ba7, got 0x27000011a31bce

I currently trying to figure this out but wondering if this has to do with using cache and then moving to the array? Does anyone have any experience with this?

---

<div class="post-metadata">

**Author:** ![ephies](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/ephies/32/2936_2.png) [@ephies](https://forums.serverbuilds.net/u/ephies)\
**Post date:** [May 3, 2020, 3:54pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/12 "2020-05-03T15:54:26Z")

</div>

If you run into stale stale file handlers or similar things, read up on the unraid forums about this hot mess.

[https://forums.unraid.net/bug-reports/stable-releases/nfs-is-about-useless-in-unraid-680-r822/?tab=comments#comment-8059](https://forums.unraid.net/bug-reports/stable-releases/nfs-is-about-useless-in-unraid-680-r822/?tab=comments#comment-8059)

The TL;DR; fix: Settings \> Global Shares Settings: Shut down array, switch Tunables Hard Links to No.

 ![image](https://serverbuilds-files.b-cdn.net/original/2X/1/1deb558c2579a7b2643d09b03f77939c5b0c3b8b.png)

I’m testing a resolution which is to disable Hard Links on NFS Shares in Unraid 6.8. In the next minor release, there is a slight promise of seeing Hard Links per NFS share.

---

<div class="post-metadata">

**Author:** ![SOUL\_VICE](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/soul_vice/32/898_2.png) [@SOUL\_VICE](https://forums.serverbuilds.net/u/SOUL_VICE)\
**Post date:** [June 28, 2020, 8:14pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/13 "2020-06-28T20:14:50Z")

</div>

Thanks very much for this guide! Working great, just have 1 issue which I am hoping you can point me in the right direction for -  
Any advice on what would be the best way to set permissions to allow the default ‘plex’ user to be able to delete files through the Plex UI?

Right now when I try to do this I get a permissions error (400) from the logs.  
“Jun 28, 2020 14:23:40.641 [0x7f9920cfb700] DEBUG - Completed: [172.16.1.49:53976] 400 DELETE /library/metadata/6473?includeExternalMedia=1 (13 live) TLS GZIP 14ms 463 bytes (pipelined: 13)”

I did a test of trying to change one of the lines in /etc/auto.nfsdb from -fstype=nfs, **ro** to -fstype=nfs, **rw** but that didnt seem to work.  
Then I added the ‘plex’ user to the group ‘users’ because I see that group has full permissions to all of my folders in /mnt/nfs but not down to the file level which is what I need it seems.

I know that I need to give addtional permissions to the plex user but just not sure of the best/cleanest/easiest way to do it.

---

<div class="post-metadata">

**Author:** ![dwell](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/dwell/32/868_2.png) [@dwell](https://forums.serverbuilds.net/u/dwell)\
**Post date:** [June 29, 2020, 4:28am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/14 "2020-06-29T04:28:14Z")

</div>

> [@SOUL\_VICE](#):
>
> “Jun 28, 2020 14:23:40.641 [0x7f9920cfb700] DEBUG - Completed: [172.16.1.49:53976] 400 DELETE /library/metadata/6473?includeExternalMedia=1 (13 live) TLS GZIP 14ms 463 bytes (pipelined: 13)”

What are you using for NAS? I would think the permissions would be controlled there, not on the Plex side.

---

<div class="post-metadata">

**Author:** ![KeyboardDabbler](https://serverbuilds.b-cdn.net/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@KeyboardDabbler](https://forums.serverbuilds.net/u/KeyboardDabbler)\
**Post date:** [August 19, 2020, 2:12am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/15 "2020-08-19T02:12:24Z")

</div>

I am able to mount my NFS shares via the autofs guide you have kindly posted. I am however having issues when trying to mount a second drive that is on my network. This one is a mergerfs mount so i believe this should be mounted with the “fuse” para.

this is what i am trying,

> mergerfs -fstype=fuse,ro,timeo=100,noatime :192.168.1.10/mnt/user/mount\_mergerfs#:192.168.1.10:/mnt/user/mount\_mergerfs

---

<div class="post-metadata">

**Author:** ![faultline](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/faultline/32/5390_2.png) [@faultline](https://forums.serverbuilds.net/u/faultline)\
**Post date:** [August 19, 2020, 2:15am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/16 "2020-08-19T02:15:17Z")

</div>

We were just talking about this in the Discord. You have to add a \_netdev parameter to your fstab

[https://unix.stackexchange.com/questions/169697/how-does-netdev-mount-option-in-etc-fstab-work](https://unix.stackexchange.com/questions/169697/how-does-netdev-mount-option-in-etc-fstab-work)

---

<div class="post-metadata">

**Author:** ![KeyboardDabbler](https://serverbuilds.b-cdn.net/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@KeyboardDabbler](https://forums.serverbuilds.net/u/KeyboardDabbler)\
**Post date:** [August 19, 2020, 2:40am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/17 "2020-08-19T02:40:05Z")

</div>

thank you for the link,

So i should now revert back to connecting my drives with fstab and not use autofs?

---

<div class="post-metadata">

**Author:** ![faultline](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/faultline/32/5390_2.png) [@faultline](https://forums.serverbuilds.net/u/faultline)\
**Post date:** [August 19, 2020, 2:52am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/18 "2020-08-19T02:52:23Z")

</div>

Wrong issue, Keep calm and configure on.

---

<div class="post-metadata">

**Author:** ![areyesrn](https://serverbuilds.b-cdn.net/user_avatar/forums.serverbuilds.net/areyesrn/32/706_2.png) [@areyesrn](https://forums.serverbuilds.net/u/areyesrn)\
**Post date:** [December 14, 2020, 6:46pm UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/19 "2020-12-14T18:46:52Z")

</div>

> [@Mthrboard](#):
>
> `tv -fstype=nfs,ro,timeo=100,noatime 192.168.1.10:/mnt/user/tv`

For those who use PlexDVR, you should change “ro” to “rw”

---

<div class="post-metadata">

**Author:** ![tofuboi123](https://serverbuilds.b-cdn.net/letter_avatar_proxy/v4/letter/t/e495f1/32.png) [@tofuboi123](https://forums.serverbuilds.net/u/tofuboi123)\
**Post date:** [January 19, 2021, 3:43am UTC](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761/20 "2021-01-19T03:43:09Z")

</div>

What’s the significance of the prerequisite (disable automatic trash emptying in Plex)? I’m not using any custom posters or metadata so will I be okay to keep automatic emptying enabled?

[Next page](https://forums.serverbuilds.net/t/guide-auto-mounting-filesystems-in-linux/1761.md?page=2)
