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

cifskernelmount

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?

Best Answer

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
Related Question