vmware, ubuntu, and shared folders

I use VMWare Fusion a lot, simply because I like to replicate the server configurations on my local development machine and it’s easier to have multiple instances of servers readily available with it. I also like to have my code available at all times with whichever VM I am using, so the code is shared. One thing I notice is that the VMTools defaults to using Mac’s UID/GID information, rather than the equivalent on the VM. So using these comments, I found a way to make the changes.

First, I double checked /etc/mtab to find out how it’s mounted.

$ vim /etc/mtab

and it looks like this in that file on my machine:

.host:/ /mnt/hgfs vmhgfs rw,ttl=1 0 0

I copied that and edited the /etc/fstab file and added the UID/GID for my user or whatever existing user or group. I also got from the comments that it fails mounting automatically, and that I should also add nobootwait to the parameters and manually perform unmount and mount. It really sucks but that’s what you got to deal with for the flexibility of multiple development OSes.

$ vim /etc/fstab

In the file, I added:

.host:/ /mnt/hgfs vmhgfs rw,ttl=1,uid=1000,gid=1000,nobootwait 0 0

When you restart the VM, you’ll get some errors (if you’re using the GUI, you probably won’t see it), but login and then do the following:

# umount /mnt/hgfs
# mount /mnt/hgfs

Create a script per the comments if you want. It saved me a lot of time.

Multiline comments in ruby

I have noticed a lot of books or sites don’t say how to do multi-line comments in ruby. Well, you can use the ruby documentation blocks –

=begin

and

=end

Anything in between the two lines will be “commented” out. The purpose of the above lines is for documentation though, but it’s really useful to “temporarily” block on multiple lines of code…

For true comments, do single line commenting…

Vim and Single Line Commenting

If you wanted to do single line commenting (i.e., adding # in front of the line) in Vim, use the regex search and replace.

Visually select the lines (using Shift-v and the arrow keys to select), then going into command mode by enter ‘:’ (colon), where you get something like this

:'<,'>

Then all you have to do is enter

:'<,'>s!^!#!g