error 12 = Cannot allocate memory and error windows 7 shares

por | 31 Octubre, 2011

Summary:
mount error 12 = Cannot allocate memory solved:

In HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management, set the LargeSystemCache key to 1 (hex).
In HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters, set the Size key to 3 (hex).’

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer
\Parameters\IRPStackSize increase to ( 15 )

I am posting this for the benefits of any others that are confounded by
the mount error:
mount error 12 = Cannot allocate memory

Okay, this is what was wrong with the mount.cifs command and what I did
to correct it. This is the error you receive in Linux when you try to
mount a Windows XP, 2000, or NT share and it fails:

mount error 12 = Cannot allocate memory

This is not a Linux problem, but the Windows machine is the one that is
causing it and refusing to allow the mount. I found this by running tail
on the messages file in one term and then running the command in another
terminal window, then watching the tail command to see what errors were
generated by the mount commmand.

The command that generates the error:

[root@ohmster ~]# mount -t cifs //missy/ohmster_music /mnt/test -o
username=my_user,password=my_password,rw
mount error 12 = Cannot allocate memory
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
[root@ohmster ~]#

The tail results that showed me the error:

[root@ohmster samba]# tail -f /var/log/messages
Oct 23 21:15:40 ohmster kernel: CIFS VFS: cifs_mount failed w/return
code = -12
Oct 23 21:19:43 ohmster kernel: Status code returned 0xc0000205
NT_STATUS_INSUFF_SERVER_RESOURCES
Oct 23 21:19:43 ohmster kernel: CIFS VFS: cifs_mount failed w/return
code = -12
[root@ohmster samba]#

The NT_STATUS message gave it away, this shows that a Windows based NT
machine caused the error, not a Linux machine.

Read on for the fix.

The Windows Fix, A.K.A.
———————————————————————
The Solution!
———————————————————————

Check the Event Log on the Windows machine that fails to allow it’s share
to be mounted under System. Look for a red X, and the word Error. The
Source is Srv. The error will be:

The server’s configuration parameter “irpstacksize” is too small for the
server to use a local device. Please increase the value of this
parameter.

If you have this error on the Windows machine that fails to have it’s
share mounted, then do the following…

This key in the system registry must be modifed or created:

In HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management, set the LargeSystemCache key to 1 (hex).
In HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters, set the Size key to 3 (hex).’

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer
\Parameters\IRPStackSize increase to ( 15 )

If the key is there, increase it a bit to say 15 or 18. If the key does
not exist, as in my case, create a new DWORD Valute. Name it
IRPStackSize. Double click on it to edit the value, put a check on the
Decimal radio button for the Base so that you can see the parameter value
as a decimal value and not a hexidecimal value. Give the new key a value
of 15 and reboot. If that is not enough, raise it a litte to let’s say 18
and then reboot again. The problem is solved. Go mount your samba shares

Do you have the following situation:

You’ve got a share on Windows (XP, Vista, 7) that you’re trying to access from a Linux system, in this case Ubuntu.
Mounted through /etc/fstab or directly through the command line.
Initially, it works great, but then loses the mountpoint – you’ll go to, say, /mnt/server/mountpoint but there are no directory contents. “mount” shows the path as still mounted.
umount’ing the directory and then trying to remount it provides this gem of a message:

mount error(12): Cannot allocate memory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

Of course, since you’re probably a reasonable system administrator, you go and check the memory allotment. top looks fine and nothing else on the system is complaining.

The solution, kindly provided by Alan LaMielle’s blog, gives a registry fix on the Windows side of things. In case that link ever breaks, here is the summary of what needs to happen on the Windows system:

In HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management, set the LargeSystemCache key to 1 (hex).
In HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters, set the Size key to 3 (hex).’
Restart the “Server” service and its dependencies (on my Windows 7 box, these were “Computer Browser” and “Homegroup Listener”, and I had to restart the service twice for the dependencies to also come back up.) Alternatively you can just restart the Windows system as you’re probably due for a large set of updates anyway.

Then re-run the mount command (for entries defined in /etc/fstab, use sudo mount -a) and your shares should be restored to their former glory.