How to Automount CIFS Shares on RHEL 5.5 Using Autofs: Solving Common Mount Issues


2 views

When dealing with RHEL 5.5 systems in enterprise environments, mounting Windows shares via CIFS can be particularly tricky when using autofs instead of fstab. The key advantage here is that autofs handles network availability issues gracefully during system boot.

Let's examine the existing configuration mentioned in the question:

# /etc/auto.master snippet
/test    /etc/auto.test    --timeout=60
# /etc/auto.test content
test    -fstype=cifs,username=testuser,domain=domain.com,password=password ://server/test

While this appears correct at first glance, several potential issues need addressing.

Here's the improved version that typically works in RHEL 5.5 environments:

# Updated /etc/auto.test
test -fstype=cifs,credentials=/etc/cifspass,uid=500,gid=500,noperm,file_mode=0664,dir_mode=0775 ://server/test

Key improvements include:

  • Moving credentials to a secure file
  • Setting proper permissions and ownership
  • Adding uid/gid parameters for file access

For the credentials file (/etc/cifspass):

username=testuser
password=password
domain=domain.com

Set strict permissions:

chmod 600 /etc/cifspass
chown root:root /etc/cifspass

When troubleshooting, these commands are invaluable:

# Check autofs status
service autofs status

# View mounting attempts in logs
tail -f /var/log/messages

# Test direct mount (bypass autofs)
mount -t cifs //server/test /test/test -o credentials=/etc/cifspass

For better performance in RHEL 5.5, consider these additional mount options:

test -fstype=cifs,credentials=/etc/cifspass,cache=strict,rsize=65536,wsize=65536 ://server/test

These settings can significantly improve throughput for large file operations.

After making changes:

service autofs restart
ls -la /test/test

If files appear, your configuration is working. If not, check SELinux contexts:

ls -Z /test
restorecon -Rv /test

When dealing with network shares in enterprise environments, autofs provides dynamic mounting capabilities that fstab can't match. However, getting CIFS mounts working correctly on RHEL 5.5 requires precise configuration.

First, let's verify the critical configuration files with proper syntax:

# /etc/auto.master (should end with)
/test    /etc/auto.test    --timeout=60
# /etc/auto.test (correct format)
test -fstype=cifs,credentials=/etc/cifs.credentials,uid=500,gid=500,noperm ://server/test

Never store credentials in plain text config files. Instead, create a secure credentials file:

# /etc/cifs.credentials
username=testuser
domain=domain.com
password=password

# Set permissions:
chmod 600 /etc/cifs.credentials

If the mount still fails, try these diagnostic commands:

# Check autofs service status
service autofs status

# Test manual mount (verify CIFS works)
mount -t cifs -o credentials=/etc/cifs.credentials //server/test /mnt/test

# View autofs logs
tail -f /var/log/messages | grep autofs

For better reliability, consider these additional mount options:

test -fstype=cifs,credentials=/etc/cifs.credentials,uid=500,gid=500,file_mode=0644,\
dir_mode=0755,iocharset=utf8,sec=ntlmssp ://server/test

Common pitfalls include:

  • Missing cifs-utils package: yum install cifs-utils
  • Incorrect DNS resolution (try using IP address instead of hostname)
  • Firewall blocking ports 445/tcp and 137-139/udp