- New Home Server
- Installing Proxmox
- Proxmox Quirks & Configurations
- Shiny New DC
- DNS, DHCP, and Redundancy
- Active Directory Structure and Config
- File server replication with Robocopy
- Windows shares on Linux
- Install Plex on CentOS
- Ubiquiti UniFi Controller
- Centreon Monitoring
- Centreon 2 – Electric Boogaloo
Since I elected to use Server 2012 R2 as my file & print server, I had a need to map various windows shares on my Linux containers. There are a few prerequisites that need to be in place in order to make this work, at least on CentOS 7. First things first, every machine needs to have the cifs-utils package installed.
1 |
yum install cifs-utils -y |
In order to make an entry in /etc/fstab and have these shares mounted automagically at boot, I needed to create credential files to allow them to authenticate. You can put these files wherever you want, I chose to store them in /etc.
1 2 3 4 |
vi /etc/share-creds user=youruser@yourdomain.com password=yoursupersecretpassword :wq |
Then you want to make this file read/write only for root to protect the credentials:
1 |
chmod 0600 /etc/share-creds |
You can now reference this file in /etc/fstab to pass credentials when mounting a share. Initially, that line looked like this:
1 |
//myserver/myfolder /mnt/myfolder cifs soft,rw,credentials=/etc/share-creds 0 0 |
To break it down for those who might not know:
- //myserver/myfolder – this is your windows UNC path
- /mnt/myfolder – this is the mount point on the system
- cifs – this is the filesystem type
- soft – if for whatever reason the share disconnects while the system is accessing it, it will return an error. By default this is hard, meaning that the program will hang/crash instead.
- rw – mount it in a read/write state
- credentials= – path to the credentials file that was created earlier
- 0 0 – dump/pass numbers. Dump indicates whether and how often the file system should be backed up by the dump program, pass indicates the order in which fsck should check the drive on boot… root file system is 1, others can be 0 (for never) or 2 (indicating after root).
However, I was running into an issue where the share would disconnect after 5-10 minutes and the only way I could get it to restore would be to unmount/remount like so:
1 |
umount /mnt/myfolder -f && mount -a |
For just the standard shares this wasn’t a big deal, but I had a share setup for my Plex media, as well as VM backups being copied onto a different share. So it was causing me some headaches for a bit until I got it figured out. It would cause the rsyncs for my backup jobs to fail, as well as making my Plex server timeout on the first attempt to use it after it had been idle for awhile. For a quick & dirty fix I ended up temporarily setting up cron jobs on the machines that would touch a file on the share every few minutes and act as a keep alive of sorts.
To solve the issue, I found that I needed to add the cifs version to the fstab:
1 |
//myserver/myfolder /mnt/myfolder cifs vers=3.0,soft,rw,credentials=/etc/share-creds 0 0 |
Since making this change, I haven’t had any more issues.
Leave a Reply