Nico Kadel-Garcia
2012-Jan-07 16:24 UTC
[Samba] Samba autofs autoumount problem with C$, D$, etc refusing to unmount
This is primarily an autofs issue, but I wanted to get the problem and the workaound into the Samba lists for reference. I use RHEL 5 and RHEL 6 these days, and take advantage of CIFS automounting with the built-in Samba pacakges. The problem still occurs with the more modern cifs-utils that's been separated out in more recent Samba 3.6.x and Samba 4 toolkits as well. I use a very simple automounting setup. From /etc/auto.master: /mnt/cifs /etc/auto.cifs --timeout=600 --ghost>From /etc/auto.cifs:# Default automounting for CIFS, all hosts # Restrictions go in auto.cifs.sub * -fstype=autofs,-Dhost=& file:/etc/auto.cifs.sub>From /etc/auto.cifs.sub# Default "mount anything", not corrently enabled # 491 is a restricted loal user and gid, locked with no active shell. * -fstype=cifs,ro,credentials=/root/.cifs,uid=491,gid=491 ://${host}/& That lets automounting work cleanly, with the credentials *out* of the backups of the the /etc/ directory that I do for system maintenance. (Never, never, never use your own credentials and leave them in the backup system: that's begging to have your passwords stolen: and be very careful about what uid and gid you use.) The problem is that when I auto-mount drives such as \\windowsbox\C$ as /mnt/cifs/windowsbox/C$, the automounter can become confused by the $. The result is that "mount" and "df" report things like "/mnt/cifs/windowsbox/C$$$$" as being mounted, but they're not there, and life gets very cofusing. This drives varous reporting of disk usage insane. Rebooting clears it, but that sucks to do. I have to assume it's a problem with how autofs parsing of the "/mnt/cifs/windowsbox/C$" and logging it as "/mnt/cifs/windowsbox/C$$$$$" and similar even longer names, and then it can't be unmounted because it does not exist. But it causes problems and complaints for CIFS and Samba users. The workaround is to simply create the directories as needed: Duplicate the entry from the error messages, and run these commands. mkdir -p 'mnt/cifs/windowsbox/C$$$$' umount 'mnt/cifs/windowsbox/C$$$$' Note the single quotes!!!! Do not try to get cutesy and outsmart this in shell scripting, the necessary backslash handling to get the $ into the commands is awkward. If folks want it, I'll publish a cleanup script. I just found this workaround and wanted to get it into the search engines for the next poor sucker.