mount.cifs : mount error(12) : Cannot allocate memory

37,373

Solution 1

I've finally solved this the solution was to add the ''sec=ntlm'' option for mount.cifs because the default behaviour changed. From

man mount.cifs
...
The default in mainline kernel versions prior to v3.8 was sec=ntlm. In v3.8, the default was changed to sec=ntlmssp.
...

So my /etc/fstab entries now look like...

# Network drives
//Server/to_mount1/mnt/network1 cifs     credentials=/etc/nfs_share.credentials,users,rw,uid=slackline,gid=slackline, sec=ntlm 0 0
//Server/to_mount2/another/dir /mnt/network2    cifs        credentials=/etc/nfs_share.credentials,users,rw,uid=slackline,gid=slackline,sec=ntlm 0 0
//Server/to_mount3  /mnt/network3   cifs        credentials=/etc/nfs_share.credentials,users,rw,uid=slackline,gid=slackline,sec=ntlm 0 0

Solution 2

Not sure if there is a workaround on the Linux side, but the fix on the Windows side definitely works.

Most posts on the web mention 2 registry keys and a reboot. In fact, only one registry change is needed on Windows 7, and no reboot. Only a service restart.

Talk to your Windows sysadmin. If you can get him/her to copy/paste this into a command prompt, it should work:

reg add HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /v Size /t REG_DWORD /d 3 /f
sc stop  LanmanServer
sc start LanmanServer

Solution 3

When I encountered this, I just restarted the 'Server' service in Windows 7, and then the mount worked.

Solution 4

A combination of using sec=ntlm in fstab and changing the Size parameter of the LanmanServer service in Windows, solves this problem.

Share:
37,373

Related videos on Youtube

TryingToLearn
Author by

TryingToLearn

Statistician / Data Scientist

Updated on September 18, 2022

Comments

  • TryingToLearn
    TryingToLearn almost 2 years

    I encountered this problem a while ago when upgrading my kernel but put off upgrading until now.

    On my system I can happily mount network shares using CIFS running kernel 3.7.10, however when I've tried with newer kernels (currently trying with 3.13.1, but have been trying since 3.12.6) I get the following errors when I attempt to mount them with /etc/init.d/netmount start (I'm running Gentoo):

    # /etc/init.d/netmount restart
    * Unmounting network filesystems  ...                                      [ ok ]
    * Mounting network filesystems ...
    mount error(12): Cannot allocate memory
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
    mount error(12): Cannot allocate memory
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
    mount error(12): Cannot allocate memory
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)   
    

    Attempting to mount manually results in the same error...

    # mount -t cifs //Server/to_mount1 /mnt/network1 -o credentials=/etc/nfs_share.credentials,users,rw,uid=slackline,gid=slackline
    mount error(12): Cannot allocate memory
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
    

    The error occurs three times as I've three network shares I'm attempting to mount, here are my /etc/fstab entries (which are completely unchanged between kernel versions):

    # Network drives
    //Server/to_mount1/mnt/network1 cifs        credentials=/etc/nfs_share.credentials,users,rw,uid=slackline,gid=slackline 0 0
    //Server/to_mount2/another/dir /mnt/network2    cifs        credentials=/etc/nfs_share.credentials,users,rw,uid=slackline,gid=slackline 0 0
    //Server/to_mount3  /mnt/network3   cifs        credentials=/etc/nfs_share.credentials,users,rw,uid=slackline,gid=slackline 0 0
    

    Searching around I found quite an old solution to this problem which requires access to the Windows server to make some modifications, this is detailed here.

    Unfortunately this is at work and not only do I not have access to the Windows server to test whether these changes would make any difference, but also its only happening with the newer 3.12.6 kernel, I can reboot into the 3.7.10 kernel and the network shares are mounted without any problem.

    This leads me to think that there is a problem with the newer kernel, so I've looked at the CIFS options under both the 3.7.10 kernel configuration:

    # grep -i cifs /usr/src/linux-3.7.10-gentoo-r1/.config
    CONFIG_CIFS=y
    CONFIG_CIFS_STATS=y
    # CONFIG_CIFS_STATS2 is not set
    CONFIG_CIFS_WEAK_PW_HASH=y
    # CONFIG_CIFS_UPCALL is not set
    CONFIG_CIFS_XATTR=y
    CONFIG_CIFS_POSIX=y
    CONFIG_CIFS_ACL=y
    # CONFIG_CIFS_DEBUG2 is not set
    CONFIG_CIFS_DFS_UPCALL=y
    CONFIG_CIFS_SMB2=y
    # CONFIG_CIFS_FSCACHE is not set
    

    ...and under the 3.12.6 configuration:

    # grep -i cifs /usr/src/linux-3.13.1-gentoo/.config
    CONFIG_CIFS=y
    CONFIG_CIFS_STATS=y
    # CONFIG_CIFS_STATS2 is not set
    CONFIG_CIFS_WEAK_PW_HASH=y
    # CONFIG_CIFS_UPCALL is not set
    CONFIG_CIFS_XATTR=y
    CONFIG_CIFS_POSIX=y
    CONFIG_CIFS_ACL=y
    CONFIG_CIFS_DEBUG=y
    # CONFIG_CIFS_DEBUG2 is not set
    CONFIG_CIFS_DFS_UPCALL=y
    CONFIG_CIFS_SMB2=y
    # CONFIG_CIFS_FSCACHE is not set
    

    ...and they are the same (no real surprise there since I didn't change anything!).

    I re-emerged net-fs/cifs-utils just in case there was something awry there but it made no difference.

    Is there a way I can work around this without having access to the Windows share to test the suggested solution (if that is indeed the underlying cause) or is there something else that is causing the problem?

  • TryingToLearn
    TryingToLearn over 10 years
    Hi, thanks that very similar to the work arounds I've come across every time I've searched for a solution. I guess it looks like there is no client-side solution so will have to ask the sysadmins nicely (they're nice and we generally get on so hopefully won't be too big an issue). Cheers
  • TryingToLearn
    TryingToLearn over 10 years
    Yes, but as I wrote I don't have control of the Windows server as this is at work. I'm pretty sure the system will have been re-booted once or twice as we've had some network outages since I started trying with kernels > 3.7.*
  • KCD
    KCD about 9 years
    Thanks. I couldn't stop LanmanServer with sc ([SC] ControlService FAILED 1051: A stop control has been sent to a service that other running services are dependent on.) but powershell worked stop-service lanmanserver -force -PassThru
  • phk
    phk over 7 years
    Seems quite odd, any idea why it fixes it?
  • Dawied
    Dawied over 7 years
    The best explanition I found so far is here: speedguide.net/articles/lan-tweaks-for-windows-7-8-10-5819