Monday, December 29, 2014

CIFS failed to allocate memory?

If you are mounting your Windows network shares in your Ubuntu, do not hurry to move your files to this newly added mount point. Most probably you will be regret very soon, as the system may give you error Failed to allocate memory and soon after that your files will gone missing. Yes, all gone! That's what happened to me.

The issues seems to cause by Windows rather than Ubuntu itself. There is a good explanation in this link:
https://wiki.archlinux.org/index.php/Samba/Troubleshooting

But I will copy & paste some of the content here, in case the link broken in the future.

======== Copy & Paste from archlinux.org, please contact me if remove is required ========

Windows 7 connectivity problems - mount error(12): cannot allocate memory

A known Windows 7 bug that causes "mount error(12): cannot allocate memory" on an otherwise perfect cifs share on the Linux end can be fixed by setting a few registry keys on the Windows box as follows:
  • HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache (set to 1)
  • HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size (set to 3)
Alternatively, start Command Prompt in Admin Mode and execute the following:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "LargeSystemCache" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "Size" /t REG_DWORD /d 3 /f
Do one of the following for the settings to take effect:
  • Restart Windows
  • Restart the Server service via services.msc
  • From the Command Prompt run: 'net stop lanmanserver' and 'net start lanmanserver' - The server may automatically restart after stopping it.



Note: Googling will reveal another tweak recommending users to add a key modifying the "IRPStackSize" size. This is incorrect for fixing this issue under Windows 7. Do not attempt it.