The World

[as I find it]

Unmount Samba filesystems before shutdown or reboot

Merry Christmas, everyone!

This post is essentially an addendum to my earlier post, Mount Samba Shares on a GNU/Linux machine. I found that my system was hanging toward the end of a shutdown because the Samba shares I had mounted weren’t being unmounted properly. I was seeing strange console messages saying things like “CIFS VFS: no response for cmd 50…” and the system would sit there, apparently unresponsive, for several minutes before actually turning off or restarting. I apologize if my earlier post created this problem for anybody.

The solution is to unmount the Samba shares a little earlier in the shutdown process, when networking is still available. This is as easy as adding a couple of symbolic links to the runlevels for shutdown and reboot that point to the /etc/init.d/ script, which unmounts virtual filesystems.

Note: the following instructions are distribution-specific; they should work on Debian and Ubuntu GNU/Linux, and probably any other distribution with a System V-style init script system. If you have a different distribution, particularly one with a BSD-style init system, check its documentation on how scripts are run when changing runlevels.

To unmount Samba shares before shutting down network services, run the following commands as root:

ln -s /etc/init.d/ /etc/rc0.d/
ln -s /etc/init.d/ /etc/rc6.d/

This will create two symbolic links to the script, one in runlevel 0 (shutdown) and one in runlevel 6 (reboot). The links have a “K” prefix to let the init system know that the script should be called with “stop” as an argument, and they have a priority of 15 to ensure that they are run before avahi-daemon and dhcdbd are stopped, which I believe was what was causing my problem. (For more information about runlevels and the symbolic link naming scheme, see this article on Debian Administration. Note that the Debian policy manual states that new runlevel links should have a default priority of 20, but I found that 20 was too low a priority; 15 seems to work.)

By the way, if you’re looking for a more automated way to manage your runlevels, try the update-rc.d utility. I think it would be more of a burden in this case than just creating the links by hand, but you may find it useful for more general runlevel management tasks.

Everything seems to be working smoothly now! Again, sorry for the trouble created by my incomplete earlier post. Please let me know if this works for you.

Written by whereofwecannotspeak

December 25, 2007 at 10:21 pm

30 Responses

Subscribe to comments with RSS.

  1. Hello! Could you post your ? =) (Maybe Email it to me.)


    December 30, 2007 at 8:59 am

  2. […] causing the following error when you shut down your Ubuntu box (a fuller explanation can be found here): CIFS VFS: no response for cmd […]

  3. works like a charm! thanks for sharing dude!


    May 2, 2008 at 8:00 pm

    • Didnt help for me, and the other 100 solutions also dont fix this. If Im connected by eth0, no problem, but if Im connected by wlan, cpu will hang.


      March 7, 2010 at 4:39 am

      • Works ok on lucid 10.04 ! Thanx


        May 10, 2010 at 2:44 pm

  4. […] Well, the next bug is not new to hardy heron, but at least very annoying. Having some samba filesystem mounted the reboot/ shutdown process lasts longer as expected. When you disable the splash screen you can read the message CIFS VFS: no response for cmd 50…. I found the solution here: Unmount Samba filesystems before shutdown or reboot. […]

  5. Nice! that’s one of the easiest fixes I’ve had to do all week!


    May 8, 2008 at 4:23 pm

  6. thank you so much – no more nights without sleep and no more worn out fingertips – i´m a mouse freak.


    May 16, 2008 at 8:18 am

  7. Hi, my Kubuntu box has in rc0.d and rc6.d folders symlinks to /init.d/ but with the name of which is rigth?


    June 15, 2008 at 5:21 am

  8. Hi, in rc0.d/ and rc6.d/ folders I changed the symlinks to and works fine! I dont know why it works or if it should work but it does. Now the reason I did this was because the script name was, so it had to start to unmount the network shares not kill the umnount of network shares in shutdown or reboot. Anyway I am running Kubuntu 8.04 on a Fukitsu Siemens Amilo Xi1546 using kernel 2.6.24-19-generic. I hope my comment helps to, like the original post did.


    June 17, 2008 at 12:55 pm

  9. Thanks. Worked beautifully on Ubuntu that is connected to a Win2k server. Regards



    September 29, 2008 at 3:44 am

  10. the only problem is that its hard to realize why the thing wont shutdown in the first place.

    thanks a lot.


    October 10, 2008 at 4:39 pm

  11. […] On shutdown I get a error about CIFS that causes a lockup of about a minute. It’s caused because Ubuntu tries to unmount Samba shares after shutting down network services. (see here for a fix. […]

  12. Perfect!

    Thanks, worked like a charm!


    December 31, 2008 at 12:20 am

  13. […] meantime, the problem can be mitigated (although not entirely erased) by following the instructions here. I found other instructions, etc., online, but this was the simplest of them. I also figured out, […]

  14. […] on how to do this in the Ubuntu forums but I found a good blog with all this info in one place here. The code you need to run to make the symbolic links is here. ln -s /etc/init.d/ […]

  15. The fix worked like a charm on kubuntu 8.04. It does nothing for the kubuntu 8.10 though. The links are in place, but i still get CIFS errors on shutdown.

    Any help would be much appreciated.


    January 29, 2009 at 7:42 am

  16. Thanks for the fix. It works perfectly in Ubuntu 8.10 64bit edition.

    I wonder why since this been an issue for the past 2+ years didn’t they include this fix in the current releases?!?!?!


    February 17, 2009 at 12:26 am

  17. […] already disconnected your lan connection before smbfs could unmount your shares. There is however a work around. I have been using the work around for several weeks without adverse side effects. « […]

  18. […] It’s unbelievable that this still isn’t fixed in Jaunty, and I’ve never really got the workarounds working.  But the most common is to move the unmounting command up the stack of priorities when shutting down or suspending.  To do this, as The World shows: […]

  19. Your solution didnt work for me :S

    So i made up a little shell program to solve the problem. Maybe it will help someone else.

    Is an installer in fact, so just put it on a text file called with chmod+x and run it on a terminal:


    echo “Empieza!”

    echo ‘#!/bin/bash
    # desmontartodo – Unmounts samba-cifs filesystems
    # -> convenience script to be called in the shutdown/reboot sequence of Ubuntu Dapper
    # as K02desmontartodo
    # Written by Max Durden

    start() {
    echo “desmontartodo: nothing to do!”

    stop() {
    echo “Unmounting all filesystems but root…”
    umount -a

    status() {
    echo “Mounted samba-cifs filesystems…”
    mount -l

    restart() {
    echo “restart …”

    reload() {
    echo “start …”

    force_reload() {
    echo “force-reload …”

    case $1 in
    echo “Usage: c {start|stop|restart|reload|force-reload|status}”

    exit 0′ >


    sudo cp ./ “$direccionInit”
    sudo chmod 777 “$direccionInit”/
    sudo ln -s “$direccionInit”/ “$direccionR0″/K01aadesmonador
    sudo ln -s “$direccionInit”/ “$direccionR6″/K01aadesmonador

    sudo rm ./

    echo “Listo!”


    September 26, 2009 at 6:32 am

  20. i forgot to say that i based on someone elses solution (a guy called Max Durden in fact)

    And here is a remover:



    sudo rm “$direccionR0″/K01aadesmonador
    sudo rm “$direccionR6″/K01aadesmonador
    sudo rm “$direccionInit”/

    echo “Fue eliminado”


    September 26, 2009 at 6:35 am

  21. Thx dude!! help me allot!


    October 20, 2009 at 10:04 am

  22. Thank you for that info, and the links.
    Very succinct and clear instructions, which I found worked fine under Ubuntu 9.04.
    Without such admirable support, Linux would be dead in the water.
    Kindest Regards,
    (Old Swan Band, UK)

    Phil Headford

    March 22, 2010 at 4:36 am

  23. […] the system to shutdown. I have tried the solutions posted on the help wiki, the team wiki and on this blog. One of them worked for a few shutdowns but then the system went back to taking a minute to […]

  24. […] causing the following error when you shut down your Ubuntu box (a fuller explanation can be found here): CIFS VFS: no response for cmd […]

  25. Thanks for this article. While a bit old meanwhile, it helped me to fix the slow shutdown process on my Ubuntu 11.10 machine.


    January 10, 2012 at 1:15 pm

  26. […] have followed the wiki on this topic and applied this solution to fix the hang on shutdown and referred to a few other posts on here but can’t get a […]

Comments are closed.

%d bloggers like this: