Monthly Archives: March 2008

Connect to MacOSX over vnc

One of the first unpleasant surprises I had when I first tried MacOSX was that I couldn't connect to it using standard vnc clients available for linux like realvnc or tinyvnc. I was actually able to connect but after the authentication the client would just hang.  I guess the protocol used by apple is a bit different then the protocol used by the rest of the vnc clients.

here are your options:

  1. use another Mac with a vnc client like  the  non free Timbuktu  or the open source Chicken of the VNC.
  2. if you have ssh access to the mac where you want to connect over vnc you can set up Vine server ( also known as OSXvnc ) . Vine is a vnc server that is compatible with realvnc client running on  linux or windows machines.

I chose the second option when possible because I don't want to fire up the macmini every time I needed to connect to a remote machine .

The vine  server comes with a nice GUI and can coexist with the standard MacOSX  vnc server listening on the next available port ( 5901 ) or you can just stop the standard server if you don't need it.

Of course if the system is really remote, you don't have another mac at hand and this is the first time you access it you wouldn't be able to use the GUI so here is how to set start vine form the command line:

  1. connect to the system where you want to install vine over ssh as root or su  root after you have connected as a normal user
  2. download  Vine3.0.dmg  in your home folder or  scp it there .
  3. attach the image:  hdiutil attach Vine3.0.dmg    -  This will make it's contents available in /Volumes/Vine3.0
  4. before you start the server you have to create a password for authentication:
    /Volumes/Vine3.0/Vine\    <yourpasswordhere> password_file
  5. start the server:  /Volumes/Vine3.0/Vine\  -rfbauth password_file
    The server will output some debuggind information and the last line should be something like:
    Started Listener Thread on port 5901
    The port can be 5900 if the standard vnc server is not already listenting on 5900
  6. leave the ssh session open and use something like realvnc vncviewer  to connect to your server on port 5901 :

The only disadvantage of this method is that it requires a bit of work in order to be able to connect but this can be avoided by setting the Vine server to start on boot and that will be explained in another post 🙂

Mount .dmg images from command line

DMG images are the way that a lot of MacOSX binary packages are distributed.  They are somehow like virtual hard disk images or .iso images that you can just mount with a simple double click if you have access to the gui.

But how do you do that from the command line?

quick answer:


and the image should now be mounted somewhere in /Volumes

The hdiutil is a tool used to manipulate such disk images. It can do a lot more then just mount the images. It can even burn  them to an optical media, convert them to an iso  and some other formats , even compress them using gzip or bzip2 .

MacOSX case sensitivity

I just got the biggest slap from MacOSX. Yes, I was punished for my ignorance.  I had not idea that the HFS filesystem defaults to case insensitive. I thought it would be case sensitive like in Unix but no.

When I first saw it I didn't believe it. The first clue was when I ran mysql_install_db an I got some warnings about about the filesystem being case insensitive. I didn't believe it because I knew I was able to create files with lower and upper cases so I just ignored it.

The confusion comes from the fact that the HFS+ filesystem is  MyFile.txt would be the same as myfile.txt .  The filesystem preserves cases so it will remember the original file name and a ls will show that but you would be able to access the file with different names. At the first glance this seems like a neat feature but it can actually create big problems when you're interacting with files from case sensitive filesystems.

The slap came from using rsync to backup files from a Linux machine to a macmini machine.   Just imagine a directory with many files split over directories from a to z and A to Z on Linux, something like files/a , files/A, files/b, files/B .

Now rsync -avz -e ssh  files/  backup@macmini:~/files/   and you'll end up with a folder named files on macmini but it will only have the upper case subfolders. The files in the lower case subfolders would be put in the upper case subfolders. This if really bad, it can really break consistency and mess up the data ( imagine different files with the same name one in A and the other in a as just one of the possibilities, there are other like this)

So now, what ? Reformat and change the filesystem to be case sensitive and journaled for easier recovery.
Be careful the next operation will remove all data on your disk:

  1. span style="color: #ff0000;">"Case-sensitive Journaled HFS+"

YourDiskId is the disk that you want to erase.It can be disk1, disk2,etc... Look for it using diskutil list

MacOSX for Unix admins

I'm going to write some posts about doing stuff on MacOSX.

I'm a beginner mac user and I come from a Unix background. I use/administrate/patch/develop on Unix like machines ( mostly just Linux and FreeBSD ) on a daily basis.

Since MacOSX has Unix at it's roots using it shouldn't be hard for me to work with it...right...well I'll see how much it has changed.

Sometimes I find it difficult to do something on MacOSX mostly because I am used to how it is done in Unix and because I don't want or can't use the GUI tools.

The fact that most of the tutorials I find are also  explaining how to do stuff in the GUI makes this an even bigger problem.

So I decided that when I actually find out how to do what I want to do I will write a post  about it so I will not have to look for it again.