Plex: Automount With VirtualBox

2 minute read


So, the last time I moved some folders around between my drives I setup a new Plex directory for movies and such and now it won’t auto mount like it used to. I used to fstab entries and it worked fine. I was tinkering around and I found a method, but I can’t seem to get it to work. Will update this post when it is complete, but right now what I do is:
Reboot the VM
Login and run a bash file that automounts the drives
Not sure why crontab isn’t working…

To Resolve:

  1. First, I setup the shared folders in Virtualbox and then expose them to the CentOS vm as read only and auto mount.

  2. I then set cron to start automatically before login:

    sudo systemctl enable crond
  3. Here is a bash script that will get called

    mount -t vboxsf google /mnt/google/
    mount -t vboxsf vids /mnt/vids/
  4. Here is the crontab entry

    sudo crontab -e
    @reboot sleep 15; /home/user/
  5. Reboot to test, didn’t work. Had to do steps in description…

UPDATE: 2018-04-01 - This was fixed by doing the following:

  1. Remove the auto mount drives for VirtualBox completely.

  2. In my Windows Host, I just created a new user “smb”.

  3. I took my two folders that Plex needs to access and gave the security permissions for “smb” to read only.

  4. In my CentOS VM, I tested:

    smbclient -m SMB3 -U smb //
    (enter password)
    # Prompt changes to: smb:> 
  5. So I know that it works interactively. Next I just made sure to enable “samba” and “samba-client” in the firewall.

  6. Now just need to update my /etc/fstab so it will automount:

    // /mnt/google cifs vers=3.0,username=smb,password=Pa$$word,rw,uid=1000,gid=976 0 0
    // /mnt/vids cifs vers=3.0,username=smb,password=Pa$$word,rw,uid=1000,gid=976 0 0
  7. It would be better to create a credentials file and put that in your home directory and access it that way:

    The quickest way to auto-mounting a password-protected share is to edit /etc/fstab (with root privileges), to add this line:

    //servername/sharename /media/windowsshare cifs username=msusername,password=mspassword,iocharset=utf8,sec=ntlm 0 0
    This is not a good idea however: /etc/fstab is readable by everyone and so is your Windows password in it. The way around this is to use a credentials file. This is a file that contains just the username and password.

    Using a text editor, create a file for your remote servers logon credential:

    gedit ~/.smbcredentials
    Enter your Windows username and password in the file:

    Save the file, exit the editor.

    Change the permissions of the file to prevent unwanted access to your credentials:

    chmod 600 ~/.smbcredentials
    Then edit your /etc/fstab file (with root privileges) to add this line (replacing the insecure line in the example above, if you added it):

    //servername/sharename /media/windowsshare cifs credentials=/home/ubuntuusername/.smbcredentials,iocharset=utf8,sec=ntlm 0 0
    Save the file, exit the editor.

    Finally, test the fstab entry by issuing:

    sudo mount -a
    If there are no errors, you should test how it works after a reboot. Your remote share should mount automatically.