Home > Jake B > Fix for mount error(12): Cannot allocate memory

Fix for mount error(12): Cannot allocate memory

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.

Categories: Jake B Tags: , , ,
  1. Colin
    May 23rd, 2012 at 16:03 | #1

    Worked perfectly for Windows 7 and ubuntu 12.04. Thanks!

  2. Irina
    October 8th, 2012 at 06:02 | #2

    It worked like a charm. It fixed a problem I had been searching a solution for for a long time.

  3. Fernando
    October 31st, 2012 at 11:07 | #3

    Thanks a lot!
    I was receiving this error, and wondering what I could did wrong…
    Very helpfull

  4. November 2nd, 2012 at 19:33 | #4

    Thank you very much…I will post about this later on the blog, but you just saved me hours and much *face*!!!

  5. Sofija
    November 5th, 2012 at 08:43 | #5

    Works perfectly!

  6. Trackerjmp
    December 30th, 2012 at 08:07 | #6

    Thanks fixed my problem too! Saved me hours of figuring this out. Gotta love Windows!

  7. Tay
    January 9th, 2013 at 16:21 | #7

    Thanks a ton, this has been tormenting me for years. You da’man!!!!

  8. Paul
    March 14th, 2013 at 16:23 | #8

    I knew intuitively that this had to be a bug, not surprised it was Windows’ problem, not Linux. Worked like a champ for me – Win 7, FC 16 running as a guest under VM Ware player. Thanks, chap.

  9. dave
    March 27th, 2013 at 12:06 | #9

    Perfect solution! Thanks!

  10. Calmarius
    April 5th, 2013 at 07:01 | #10

    What would you do if you have no access to the Windows side?

  11. Mike
    April 30th, 2013 at 04:56 | #11

    I would never have resolved this in a trillion years without your help. Many thanks!

  12. JWC
    May 3rd, 2013 at 18:33 | #12

    Wow very helpful thanks. No way I woulda figured this out on my own.

  13. fu
    May 7th, 2013 at 22:33 | #13

    Thanks for your help. Worked for me CentOS 6.4 to Win7 Enterprise

  14. rich
    July 16th, 2013 at 18:47 | #14

    Worked great for Windows 7 and Centos 6.4 …..

    Did I mention hate Windows ……..

  15. kevin
    July 22nd, 2013 at 23:38 | #15

    Worked for me. LOVED the fact I only had to restart a service. Will you take over microsoft please?

  16. Keith
    September 29th, 2014 at 13:12 | #16

    One typically views suggested “fixes” with a jaundiced eye … this one worked and worked immediately. Many thanks!
    Our IT department is looking for good people …

  1. October 4th, 2011 at 20:18 | #1
  2. August 30th, 2012 at 15:06 | #2
  3. December 28th, 2012 at 12:26 | #3
  4. May 16th, 2013 at 10:24 | #4