LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices

Reply
 
LinkBack Search this Thread
Old 01-31-2007, 10:14 AM   #1
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,141

Rep: Reputation: 329Reputation: 329Reputation: 329Reputation: 329
Lightbulb A work-around for reboot/shutdown problems when cifs shares are open


In Fedora, when a reboot or shutdown is done, and if a cifs share is open, the network access may be terminated before the CIFS filesystems are unmounted. This produces an inordinate delay as each share must wait for it's umount request to time out.

Since I set up my cifs shares for automount with no timeout, I needed an automatic way to unmount them at the start of a reboot or shutdown.

The solution I took was to patch the stop function in /etc/init.d/dhcdbd to include the following code:
Code:
# Un-mount CIFS shares if there are any CIFS processes running
        if ! [ -z $(/sbin/pidof cifsd) ];
        then
            echo -n Umounting SMB shares;
            umount -a -t cifs
            if [ $? -eq 0 ];
            then
                success;
            else
                failure;
            fi
            echo
        fi
#
This is, of course, a "hack." A better solution might be to create a cifs program in in /etc/init.d/ and link to it from /etc/rc.d/rc5.d/ so that it's run before dhcdbd at shutdown. Something like this (which I've not tested):
Code:
$ cat tmp/cifs
#!/bin/bash
#
#  cifs:        Make sure that all cifs shares are unmounted before INIT 0
#
#  description: This is a pseudo init process that umounts any cifs shares
#               that are open when it's called
#
#  processname: cifs
#
. /etc/rc.d/init.d/functions
[ -e /etc/sysconfig/network ] && . /etc/sysconfig/network
[ "${NETWORKING}" = "no" ] && exit 0
prog=cifs

stop () {
# Un-mount CIFS shares if there are any CIFS processes running
        RETVAL=0
        if ! [ -z $(/sbin/pidof cifsd) ];
        then
            echo -n Umounting cifs shares:
            umount -a -t cifs
            RETVAL=$?
            if [ $RETVAL -eq 0 ];
            then
                success;
            else
                failure;
            fi
            echo
        fi
        return $RETVAL
}

status() {
# Report if any CIFS processes is running
        RETVAL=0
        if ! [ -z $(/sbin/pidof cifsd) ];
        then
          echo The CIFS process is running.
        else
          echo The CIFS process is not running.
        fi
        return $RETVAL
}

case "$1" in
    stop)
        stop;
        RETVAL=$?;
        ;;
    status)
        status;
        RETVAL=$?;
        ;;
    *)
# Just ignore any other arguments
        RETVAL=0;
        ;;
esac;

exit $RETVAL;
As an aside, for those who want to use automount for their cifs shares, here's my /etc/auto.master and /etc/auto.cifs:
Code:
$ cat /etc/auto.master
/smb    /etc/auto.cifs --timeout=0
+auto.master
$ cat /etc/auto.cifs
#!/bin/bash
credfile="/etc/auto.smb.$key"
mountopts="-fstype=cifs,file_mode=0775,dir_mode=0775,uid=$USER,gid=smb"
smbclientopts=""
SMBCLIENT=$(whereis -b smbclient | cut -d " " -f 2)
if ! [ -x $SMBCLIENT ]
then
    echo No smbclient executable found. Have you installed samba? >2
    exit 1
fi
if [ -r "$credfile" ]
then
        mountopts=$mountopts",credentials=$credfile"
        smbclientopts="-A "$credfile
else
        smbclientopts="-N"
fi
$SMBCLIENT $smbclientopts -gL $key\
   | awk -v key="$key" -v opts="$mountopts" -F'|' -- '
        BEGIN   { ORS=""; first=1 }
        /^Disk[^$]*$/  { if (first) { print opts; first=0 };
                  sub(/ /, "\\ ", $2);
                  if (length($2)==1) sub(/ ^/, "", $2);
                  print " \\\n\t /" tolower($2), "://" key "/" $2 }
        END     { if (!first) print "\n"; else exit 1 }
        '
 
  


Reply

Tags
automount, cifs, reboot, shutdown


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Need to change file shares to cifs from smbfs New2Linux2 Linux - Networking 1 12-01-2006 07:02 PM
mounting SMB/CIFS shares from FreeBSD scott2004 *BSD 2 10-21-2006 12:09 PM
No keyboard/mouse after reboot. Requires second reboot to work. rottie Linux - Hardware 6 01-16-2006 05:04 AM
Want to refresh Samba shares automatically after Windows reboot evdm Linux - Software 2 03-08-2005 04:59 PM
help with shutdown and reboot Paxmaster Fedora 2 09-26-2004 04:01 PM


All times are GMT -5. The time now is 09:41 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration