Ubuntu 10.10 Guest in VirtualBox Shared Folders Issues.

Posted: November 29th, 2010 | Author: | Filed under: Ubuntu, Virtual Box | Tags: , , , , , , , , , , , , | No Comments »

I have recently installed Ubuntu 10.10 as a VM to check out the Android SDK. After the basic install, I find the Shared Folder feature doesn’t work, even though I have installed the Guest Additions. I keep get the following error: /sbin/mount.vboxsf: mounting failed with the error: No such Device

I checked and under /sys/modules/ there is no vboxsf module, so obviously something in the VBoxLinuxAdditions-amd64.run script is not working.

After digging around I was told the simple way is to install the Guest Additions OSE version from apt-get. However since I am using the Closed Source edition (differences between versions can be found here). I thought there must be a better solution.

What happened is VBoxLinuxAdditions-amd64.run doesn’t do a sanity check for the existence of 3 components that Ubuntu needs to compile the modules, namely dkms, build-essential and linux-headers-generic. It requires a different set of packages for other Linux distributions. To solve the problem, run sudo apt-get install dkms build-essential linux-headers-generic. Then run VBoxLinuxAdditions-amd64.run, the modules will be compiled. Do a reboot to make sure the modules are loaded.

Once reboot, when you do lsmod | grep vbox. You should have something like this:

vboxvideo               1956  2
drm                   206161  3 vboxvideo
vboxsf                 34612  0
vboxguest             176030  9 vboxsf

To mount the folder (example):

  1. Create the Shared Folder on the Guest Window toolbar. For me I created a Folder Name with the name vb.
  2. In Ubuntu create the directory /mnt/vb
  3. Then run sudo mount -t vboxsf vb /mnt/tmp

Remember the files will not have the user’s ownership, so it is a good idea to cp the files into another folder, then do a chown user * to correct the ownership. The files will belong to root and root ownership group.
For more information : This post on VirtualBox forum

Netatalk debugging and logging tips and tricks

Posted: November 26th, 2010 | Author: | Filed under: netatalk, Ubuntu | Tags: , , , , , , | No Comments »

Lately I have been having problems logging into my TimeMachine disc. My iMac works, but my macbook doesn’t, even though they run the exact same OS (10.6.5). I looked it up and here are the instructions to seperate the netatalk messages from the general message logs.

In /etc/netatalk/afpd.conf
add -setuplog “default log_info /var/log/afpd.log” to the long line of setup parameters.

If you run CNID server:
In /etc/default/netatalk
add CNID_CONFIG=”-l log_info -f /var/log/cnid.log”

You then run /etc/init.d/netatalk restart in your terminal.

Add the log files in Log File Viewer (under System -> Administration). Use File -> Open and select the log files in the appropriate place. Now whenever the logs are updated the log files will be in bold.

Now I get error messages when my macbook tries to log onto the Time Machine disc:
afpd[2081] {uams_dhx2_pam.c:350} (I:UAMSDaemon): DHX2 login: useruser
afpd[2081] {uams_dhx2_pam.c:228} (I:UAMSDaemon): PAM DHX2: PAM Success
afpd[2081] {uams_dhx2_pam.c:647} (I:UAMSDaemon): DHX2: PAM_Error: Authentication failure

However my iMac works fine:
afpd[2280] {uams_dhx2_pam.c:350} (I:UAMSDaemon): DHX2 login: useruser
afpd[2280] {uams_dhx2_pam.c:228} (I:UAMSDaemon): PAM DHX2: PAM Success
afpd[2280] {uams_dhx2_pam.c:684} (I:UAMSDaemon): DHX2: PAM Auth OK!

Netatalk fixes after Ubuntu 10.10 upgrade from Ubuntu 10.04

Posted: October 11th, 2010 | Author: | Filed under: netatalk, Ubuntu | Tags: , , , , | No Comments »

If you had followed the previous instructions and have just upgraded from 10.04 to 10.10 aka Maverick Meerkat; you might have noticed that Netatalk has ceased to function. Basically it won’t let you login and in the System Log Viewer you see error messages like below.

I got the following error messages in daemon.log.

afpd[3523]: Setting uid/gid to 1000/1000
afpd[3523]: CNID DB initialized using Berkeley DB 4.8.30: (April  9, 2010)
afpd[3523]: cnid_open: dbenv->open (rw) of /storage/dirname/.AppleDB failed: DB_VERSION_MISMATCH: Database environment version mismatch
afpd[3523]: Fatal error: cannot open CNID or invalid CNID backend for /storage/dirname: cdb

What I come to realize that Netatalk 2.1.2 (that is now default in the Meerkat software repository), doesn’t support the cdb option in the cnidscheme. It only supports last, dbd and tdb.

Steps to uninstall Netatalk (if you had followed the previous instructions)
Remember to backup your copies of your conf files in your /etc/netatalk directory first.

echo "netatalk purge" | sudo dpkg --set-selections
sudo apt-get remove netatalk
sudo apt-get autoremove

You can then follow the same instructions in the previous post and compile the latest version (2.1.2) with the proper authentication modules built in from the Maverick Meerkat repository.

Once you have started the dpkg installation of the new netatalk. You will be asked if you want the new conf files to be installed. I selected No and changed the cnidscheme manually.

Remember to change the cnidscheme setting from cdb to either dbd or tdb in your AppleVolumes.default files. For more information on selecting / changing please refer to here.

Netatalk authentication gotchas and diagnostic steps for Ubuntu 10.04

Posted: September 11th, 2010 | Author: | Filed under: netatalk, Ubuntu | Tags: , , , , , , , , , , | No Comments »

For some reason the netatalk package that is in the Ubuntu repository doesn’t come with any password authentication packages. So unless you want a fully non password appletalk setup on your Ubuntu server. DO NOT apt-get install netatalk!

I followed Mr. Kretschmann’s handy HowTo for installing Netatalk on Ubuntu. It seems to work for Ubuntu 10.04 (actually it should work with all linux distributions). However when I try login, I kept getting unknown username / password problem.

Here are my installation steps:

sudo apt-get source netatalk
sudo apt-get build-dep netatalk
sudo apt-get install cracklib2-dev
sudo apt-get install libssl-dev
cd netatalk-2*
sudo DEB_BUILD_OPTIONS=ssl dpkg-buildpackage -rfakeroot
sudo dpkg -i ../netatalk-2*.deb
echo "netatalk hold" | sudo dpkg --set-selections

Here are my diagnostic steps:

  1. Check your afpd.conf and AppleVolumes.default files for any typos, especially when you are cutting and pasting!
  2. If you want to let each user to access his/her own directory, you should put
    ~/ "$u" allow:$u cnidscheme:cdb

    in AppleVolumes.default; $u is the variable for username; instead of username1/username2 combination as listed in the HowTo. The list of variable names is in the comment section of the file or here.

  3. Open Log File Viewer under System -> Administration. What this does is whenever there is any updates in any of the log files, the updated log file on the left will appear bold.
  4. What I encountered was my installation steps above only created the uams_dhx2*.so authentication libraries. My syslog file has these entries
    afpd[17919]: ASIP started on (2.0.5)
    afpd[17919]: uam: loading (/usr/lib/netatalk/uams_randnum.so)
    afpd[17919]: uam: uam not found (status=-1)
    afpd[17919]: uam: loading (/usr/lib/netatalk/uams_dhx.so)
    afpd[17919]: uam: uam not found (status=-1)
    afpd[17919]: Finished parsing Config File
  5. Go to /usr/lib/netatalk directory and verify which authentication modules you have. Update your afpd.conf appropriately. Mine is:
    - -transall -uamlist uams_dhx2.so -savepassword -advertise_ssh

    dhx2 authentication is only supported by MacOSX machines, if you have OS9 or earlier you will have to have the others fall back to. I think it is much easier to use a normal MacOSX machine to do Appletalk though.

  6. I also noticed in with Netatalk 2.0.5 (vs 2.0.3 in the HowTo), there is a Time Machine support option in the AppleVolumes.default file. So an entry like this:
    ~/TimeMachine "$u" allow:$u cnidscheme:cdb options:usedots,upriv,tm

    would allow a per user login to have their own TimeMachine backup. or you can do it by ip via the $c variable. With that option enabled, I can run TimeMachine without having to create my own sparsebundle etc. You still have to issue the Defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1 command in a terminal of the Mac you want to start TimeMachine though.

  7. Oh after each change, remember to run:
    /etc/init.d/netatalk stop
    /etc/init.d/netatalk start

    I find 2 commands work better than one command using the restart flag.

Upgrading VirtualBox 3.1 -> 3.2 on Ubuntu 10.04

Posted: July 19th, 2010 | Author: | Filed under: Ubuntu, Virtual Box | Tags: , , , , , | No Comments »

Assume: you have VirtualBox (OSE / non OSE) 3.1 installed. You also have sudo rights.
Note: OSE version doesn’t have RDP support, non OSE has RDP support.
VirtualBox files are usually stored in: /home/username/.VirtualBox/ directory with HardDisks and Machines sub directories. (A backup is always a good idea before an upgrade!)

    Upgrade Steps:

  1. Shut down your existing VMs. I find if you are using VBoxHeadless, the process might not end after the VM has been shutdown.
  2. Quit VirtualBox GUI (if running); kill all VBoxHeadless processes.
  3. Use dpkg -remove packagename or Synaptic Package Manager to remove your exisiting installation. (Synaptic is probably easiest since you don’t need to look up the package name). Even if you remove the package your existing VMs will still be around, but it never hurt to do a backup before hand!
  4. Locate your VirtualBox 3.2 .deb package.
  5. Install via dpkg -i debfilelocation
  6. VirtualBox Guest Additions are located in /usr/share/virtualbox. You have to manually mount the Additions in the virtual machines. I find it the quickest to edit the setting via the VirtualBox GUI
  7. Restart VirtualBox, and run the Guest Addition updates.
  8. Stop the VMs and launch them via VBoxHeadless if so desired.

Easy Recipe for WYSIWYG Math Formulas in Drupal

Posted: June 15th, 2010 | Author: | Filed under: Dreamhost, Drupal | Tags: , , , , , , , , | No Comments »

Objective: An easy recipe to setup Drupal to allow users to write / edit mathematics expressions.

Check List:

    Required Drupal Modules

  1. Mathematics Filter aka Mathfilter

    Required Non Drupal Components

  1. Mathtex or Mimetex
  2. TinyMCE


  1. Install Mimetex or Mathtex and Mathematics Filter. This will allow basic LaTeX markups to be rendered as graphics. Make sure this part works first before proceeding.
  2. At this stage, create an “Input Format” for Math. Since Mimetex / Mathtex is an external binary, use a seperate input method that only authenticated users can use, it is better be safe than sorry.
  3. Install WYSIWYG API and TInyMCE. Verify they work. Assign TinyMCE as the editor for the Math Input Method under the WYSIWYG module configuration.
  4. Here is the tricky part. Install WYSIWYG ASCIIMATH module into the /modules directory also the /sites/all/modules directory. You would want to create symbolic links from of your mimetex binaries to where the respective mimtex directories! eg my mathtex lives in /cgi-bin directory, so in the /modules/wysiwyg_asciimath/mimetex directory I issue ln -s ../../../cgi-bin/mathtex mathtex command.
  5. Go back to the WYIWYG, click on Edit in the Math Input Format. Check ASCIIMath and ASCIIMathCharmap and Save

Why no ASCIIGraph? For some reason ASCIIGraph doesn’t seem to render well once I switch to View mode. So for now I am going to stick with my JSXGraph module.

Adding MimeTex or MathTex to Dreamhost

Posted: May 31st, 2010 | Author: | Filed under: Dreamhost, Drupal | Tags: , , , , , , , | No Comments »

I use Deamhost for hosting and for 99.9% of the tasks one would face it is great. The only let down is lack of full Latex support as it doesn’t support dvipng.

In the end, I had decided to use Mathtex / Mimetex.
The installation instructions between Mathtex and Mimtex are similiar and straight forward. One thing you have to watch out for is to unzip Mathtex on Dreamhost if you are using a Windows computer. As the C file uses UNIX encoding only, it will give you weird errors like:

mathtex.c:205: error: expected expression before â/â token


mathtex.c: In function âsetpathsâ:
mathtex.c:1697: error: âonvertpathâ undeclared (first use in this function)
mathtex.c:1697: error: (Each undeclared identifier is reported only once
mathtex.c:1697: error: for each function it appears in.)

If you want to fix the above while you are in Windows. Use Notepad++, make sure the encoding is for UNIX, remove the offending key etc setpath and retype it and save. If you have unzip the file on Dreamhost, you shouldnt’ have to go through that step.

In Dreamhost, you have access to latex, dvips and convert. You can use the which command to see where the commands reside.

To compile the file you issue the following (for Dreamhost and it will output PNG files):

cc mathtex.c -DLATEX="/usr/bin/latex" -DDVIPS="/usr/bin/dvips" -DCONVERT="/usr/bin/convert" -DPNG -o mathtex.cgi

Note: \” is the delimiter.

mathtex.cgi will be compiled. You then move it to your cgi-bin directory and change the correct permission. It is ready to be used!

The main difference between mathtex and mimetex is mathtex is quite a bit smaller (240kb vs 980kb) because it requires outside programs. Functionally, they are the same.

Once you have that setup, you can integrate it with Drupal via the Mathematics Filter module. You can then create Latex based math text with the [$ your math expression here $] tag. I find the tag conflicts with HTML Filter and other filters, so it is wise to create a separate Input Format with MathFilter input method and only allow authenticated user to use it.

Some notes on submitting code to Drupal.org

Posted: May 27th, 2010 | Author: | Filed under: Drupal | Tags: , , , , , , , | No Comments »

The web browsers have improved by leaps and bounds. However it is still a pain for academics to communicate and present their formulas and graphs. Good thing there are now Javascript solutions like MathJAX and JSXGraph to bridge the gap (not to mention relatively cheap bandwidth). However there aren’t that many off the shelf plugins/modules that integrates easily to CMS systems like Drupal.

Recently I helped a friend create a Drupal plugin for JSXGraph. Since all the code is GNU. I applied for CVS access at Drupal.org. Here are some notes:
The code itself:
Formatting: Tab is 2 spaces. Give the Coding Standard document a quick read through.
3rd party code: In my case, the JSXGraph core files are not created by me, so they are not allowed into the drupal.org repository.

    Apply for CVS access:

  1. Have your source code production ready and have them in a zip file.
  2. Make an account on drupal.org.
  3. Apply for CVS access here. Once approved, it is attached to your drupal.org account.
  4. Attached the zip file into the review queue, and set the status tag to “need review”
  5. Patiently wait for volunteers to review your code and suggest changes

    Configure your client for CVS:

  1. I use TortoiseCVS under //s and Windows.
  2. Install Tortoise and create a local directory for CVS files (non zipped) to reside.
  3. Once your code has been reviewed, your Drupal account will be CVS enabled.
  4. Right click on the directory in Step 2 and select Check Out, paste in the CVSROOT information. You will check out all the directories in contribution/modules directory.
  5. Alternatively, I find it easier just to do a cvs checkout -l contributions/modules
  6. Once you have checked out the modules directory, you can create your own.
  7. For more information refer to here.
  8. Move your source files via Explorer into the directory you set Tortoise to in step 2.
  9. You can then Add and Commit the files and files will be added to the CVS!.

    Project Page

  1. Create your project page.
  2. Create a new release node BEFORE you create a new release, if not it will give you some weird errors like ‘The Patch-level must be “x” for snapshot release from a branch (or HEAD)’, even when you got everything right.
  3. Click on “Add New Release” at the Project page.

    Advantages of submitting your code to Drupal.org:

  1. Users of your module will able get to get the latest plugins on their Drupal installations automatically.
  2. You can use drupal.org to handle all feature requests and bug fixes.
  3. It is good to contribute to the greater good of the world.

Configuring VirtualBox for useful Windows Guests.

Posted: May 20th, 2010 | Author: | Filed under: Virtual Box | Tags: , , , , , | No Comments »

I find VirtualBox 3.1 is quite mature and usable for everyday. Granted, I only use my Windows sessions via RDP and all of them are in 2D applications. VirtualBox has graphics acceleration, build in RDP viewer (even for pre XP computers). The only thing that is really missing is the clone functionality, but hey it is free and I am sure someone is working on it!

Here are a few tips to make things more useful (especially for people who are remote accessing the Guest OSes).

  1. Set default GUI resolution of Guest OS to any:
    This way you can RDP into the virtual machine at any resolution you like.
    Run the follow command in Terminal:

    VBoxManage setextradata global GUI/MaxGuestResolution any
  2. You only need to enable RDP on pre XP Windows or non Windows Guest:
    Remember the IP address you have to RDP into is the host machine (in my case the Ubuntu machine). Also each VM Guest has to have a unique Server Port.
  3. If you want GuestOS to be accessible on the network remember to set it to bridged mode.
  4. If you feel the Windows GuestOS network performance is too slow.
    Try the virtio drivers.
    However chances are you might need to reactivate the Windows Genuine Advantage, if you are changing it once the GuestOS has been setup. YMMV.
  5. Get to know the VBoxHeadless command.
    Typically it is

    VBoxHeadless -startvm "machinename"

    Note: VRDP is enabled by default, so for post XP machines you would want to add –vrdp off

Remote Display Settings for VirtualBox 3.1.8

Remote Display Settings for VirtualBox 3.1.8

Paravirtualised Virtio network driver settings for Virtualbox

Paravirtualised Virtio network driver settings for Virtualbox

Ubuntu 10.04 LTS Nvidia restricted driver VNC issues

Posted: May 20th, 2010 | Author: | Filed under: Ubuntu | Tags: , , , , , , | No Comments »

I run a few machines in my house. I like machines to perform one and only one task. eg I have a machine that does all my communications (email, IM etc), one runs simplicity (a Tivo indexing program) and another that runs utorrent. They are all Windows boxes because I do believe of all things Microsoft might have screwed up, they make a superior remote access protocol (RDP). Recently my email machine decide to throw a few bad sectors (it barfed while backing up a 6GB SENT file), so I decided to task a spare Core2 machine to run Ubuntu 10.4 and consolidate my machines into virtual machines managed by Virtual Box.

Everything installed smoothly until I decide to activate the Nvidia restricted drivers AND VNC into the machine. The keyboard and mouse stopped responding via VNC (it worked via local console). It works fine with the Ubuntu’s OSE drivers (jockey). (However the OSE drivers are restricted to 1024×768 on the monitor, not to mention the lack of acceleration etc). I decide to live with that solution because most of the time I remote terminal in anyways.