Saturday, January 28, 2012

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.

Sunday, January 8, 2012

VirtualBox installation on CentOS 5.6

Headless Virtualbox 4.1.8 install and setup on CentOs 5.6 Host

Create a user account
# groupadd vbox_admin (whatever user you would like here)
 
# useradd -d /home/vbox_admin -m -g admin -s /bin/bash vbox_admin


Enable the RPMforge repository as the dkms package (Dynamic Kernel Module Support Framework). It isn't available in the official CentOS 5.6 repositories.

# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

# cd /usr/local/src

# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

# rpm -ivh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

Install additional dependencies
# yum groupinstall 'Development Tools'

# yum groupinstall 'Development Libraries'

# yum install SDL kernel-devel kernel-headers dkms

 Verify your Kernel version
# uname -r

Example:
# uname -r
2.6.18-238.19.1.el5 

And now the architecture

# uname -m

Verify the headers located at /usr/src/kernels.

Create a symbolic link if necessary to resolve otherwise VirtualBox will fail when it attempts to build the kernel modules and can't find the necessary directory.

Example:
# ln -s 2.6.18-274.12.1.el5-x86_64 `uname -r`-`uname -m`

Download and register the VirtualBox public rpm key.
# wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc

# rpm --import oracle_vbox.asc

# rm -f oracle_vbox.asc

Enable the repository
# cd /etc/yum.repos.d/

# wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

Install VirtualBox Software
# yum install VirtualBox-4.1

Should complete with the following or something similar

Running Transaction
  Installing     : VirtualBox-4.0                        1/1

Creating group 'vboxusers'. VM users must be member of that group!


No precompiled module for this kernel found -- trying to build one. Messages

emitted during module compilation will be logged to /var/log/vbox-install.log.

Stopping VirtualBox kernel modules [  OK  ]

Uninstalling old VirtualBox DKMS kernel modules [  OK  ]
Trying to register the VirtualBox kernel modules using DKMS [  OK  ]
Starting VirtualBox kernel modules [  OK  ]

Installed:

  VirtualBox-4.1-4.1.8_75467_rhel5-1.i386

Complete!

If you get an error on kernel modules go back and verify the kernel headers and symlink. 

Download and install the Extension pack associated with the installed version of VirtualBox.  This is required in order to run the system headless as it will establish the remote desktop session.

# wget http://download.virtualbox.org/virtualbox/4.1.8/Oracle_VM_VirtualBox_Extension_Pack-4.1.8.vbox-extpack 

Sudo or as root... 
# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.8-75467.vbox-extpack

Note:  There is extensive documentation at virtualbox.org on the configuration and setting of all parameters including the use of multiple remote desktop sessions.  https://www.virtualbox.org/manual/

Add the user that will be running VirtualBox

# /usr/sbin/usermod -G vboxusers vbox_admin 
 
Command line -  Creating a VM (Windows 2003 Server, 3G, 200GB)

I wanted to use the mounted CD but found that problematic.  I'm sure there is a solution but for the the time being, I created an iso located at /home/vbox_admin/iso

# dd if=/dev/cdrom of=/home/vbox_admin/2003.iso

Become the vbox_admin user.

Review Options
# VBoxManage --help

# VBoxManage createvm --name "2003 Server" --register

#  VBoxManage modifyvm "2003 Server" --memory 3072 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0

#  VBoxManage createhd --filename 2003_Server.vdi --size 200000

#  VBoxManage storagectl "2003 Server" --name "IDE Controller" --add ide

#  VBoxManage storageattach "2003 Server" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium 2003_Server.vdi

#  VBoxManage storageattach "2003 Server" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /home/vbox_admin/iso/2003.iso

Just for good measure...
# VBoxManage modifyvm "2003 Server" --vrde on

Review your VM's settings 
# VBoxManage showvminfo "2003 Server"

2003 Server
Guest OS:        Other/Unknown
UUID:            ******-*****-*********-*****
Config file:     /home/vbox/VirtualBox VMs/2003 Server/2003 Server.vbox
Snapshot folder: /home/vbox/VirtualBox VMs/2003 Server/Snapshots
Log folder:      /home/vbox/VirtualBox VMs/2003 Server/Logs
Hardware UUID:   *******-*******-********-****
Memory size:     3072MB
Page Fusion:     off
VRAM size:       8MB
CPU exec cap:    100%
HPET:            off
Chipset:         piix3
Firmware:        BIOS
Number of CPUs:  1
Synthetic Cpu:   off
CPUID overrides: None
Boot menu mode:  message and menu
Boot Device (1): DVD
Boot Device (2): DVD
Boot Device (3): HardDisk
Boot Device (4): Not Assigned
ACPI:            on
IOAPIC:          off
PAE:             on
Time offset:     0 ms
RTC:             local time
Hardw. virt.ext: on
Hardw. virt.ext exclusive: on
Nested Paging:   on
Large Pages:     off
VT-x VPID:       on
State:           running (since 2012-01-08T06:37:19.857000000)
Monitor count:   1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address:
Teleporter Password:
Storage Controller Name (0):            IDE Controller
Storage Controller Type (0):            PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  2
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on
IDE Controller (0, 0): /home/vbox/VirtualBox VMs/2003 Server/2003_server.vdi (UUID: )
IDE Controller (1, 0): /home/vbox/iso/2003_server.iso (UUID:)
NIC 1:           MAC: 080027431395, Attachment: Bridged Interface 'br0', Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny
NIC 2:           disabled
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled
Pointing Device: PS/2 Mouse
Keyboard Device: PS/2 Keyboard
UART 1:          disabled
UART 2:          disabled
Audio:           disabled
Clipboard Mode:  Bidirectional
Video mode:      1024x768x32
VRDE:            enabled (Address 0.0.0.0, Ports 3389, MultiConn: off, ReuseSingleConn: off, Authentication type: null)
VRDE port:       3389
Video redirection: disabled
VRDE property: TCP/Ports  = "3389"
VRDE property: TCP/Address =
VRDE property: VideoChannel/Enabled =
VRDE property: VideoChannel/Quality =
VRDE property: VideoChannel/DownscaleProtection =
VRDE property: Client/DisableDisplay =
VRDE property: Client/DisableInput =
VRDE property: Client/DisableAudio =
VRDE property: Client/DisableUSB =
VRDE property: Client/DisableClipboard =
VRDE property: Client/DisableUpstreamAudio =
VRDE property: H3DRedirect/Enabled =
VRDE property: Security/Method =
VRDE property: Security/ServerCertificate =
VRDE property: Security/ServerPrivateKey =
VRDE property: Security/CACertificate =
USB:             disabled

USB Device Filters: 
Available remote USB devices: 
Currently Attached USB Devices: 
Shared folders: 

VRDE Connection:    not active
Clients so far:     0

Guest:

Configured memory balloon size:      0 MB
OS type:                             Other
Additions run level:                 0

Guest Facilities:
No active facilities.

Start the VM (Headless)

VBoxHeadless --startvm "Ubuntu 11.04 Server"

$ Oracle VM VirtualBox Headless Interface 4.1.8
(C) 2008-2011 Oracle Corporation
All rights reserved.

VRDE server is listening on port 3389.

 
You can now manage the VM from most remote desktop clients.  I used Remote Desktop Connection from my MacBook which worked but mouse control was somewhat problematic while completing the initial server setup.  

As soon as I was able to enable remote desktop within the Virtual Machine itself and connect directly it functioned normally.

Additional commands to control the VM Headless found @ http://www.virtualbox.org/manual/ch07.html#vboxheadless

Basic Controls
# VBoxManage controlvm "2003 Server" poweroff|reset|pause

_______________________________________________