How-To: Setup Symlinks for your Parallels Virtuals

share-home-profile.png

Hi all, I thought I would start a series of off-topic random blogs.  If you don’t like off-topic content sorry, but feel free to ignore :).  I also apologize for typos, grammar, etc…these are quick 5 minute blogs.

A little background…lately I do the bulk of my development on a MacBook or MacMini. It offers the best of all worlds, at least in my humble opinion. Very stable hardware, a stable operating system, a good collection of free or cheap essential software (Adium, iTerm2, FreeRDP, HomebrewGrowl, Sublime Text 2) along with useful native applications like Mail. I digress, my essential software may be a different post.

I do the majority of my work using Sublime Text 2 (even in Windows using MSBUILD in lieu of VS.NET) and iTerm2 but I also need access to Windows 7, Windows 8 and Fedora 17 for different builds. While I have different build slaves running on my Hyper-V 2012 server I also use Parallels Desktop for Mac so I can be self contained. This is great but a few tweaks can really make it a powerful yet simple development environment, and that brings me to the point of this blog post.

Using symlinks, both in Windows and Linux, you can simplify management of common config files like .gitconfig, .ssh, .bash_profile, etc. Parallels does a lot of the work for you so we’ll start with that. If you haven’t already, install “Parallels Tools” on your virtual machines. You can do that from the Virtual Machine menu.

Next up is configuring Parallels to share your Home Profile between OSX and your virtual.

Share Home Profile

Note: I don’t use Coherence, Modality, Application Sharing or Virtual Drive Mounting. I’ve tried each and found they lead to an overall less stable system.

If everything is setup properly you should see a new network location “Home on ‘psf’“. If you made these changes while the virtual machine was running you may need to restart the virtual for the changes to take affect.  

Parallels Shared Folder

Since admin rights are needed to create symlinks in Windows open an Administrator Command Prompt. The easiest way to do this on W7 and\or W8 is to hit the Command key (or Windows Logo Key if you are not using an Apple keyboard) type “cmd” and hit Control + Shift + Enter.

From Command Prompt run the below commands to 1- create a symlink for .gitconfig, .bash_profile and .vim files; 2- create a symlink for the .ssh folder. To add additional files or folders just add them to the list between the parentheses.  The command will delete any existing folders or files without prompting so please either make a backup or ensure there isn’t any information you need.

FOR %I IN (.gitconfig .bash_profile .vim) DO (DEL /A /Q "%USERPROFILE%\%I">NUL) & (MKLINK "%USERPROFILE%\%I" \\psf\Home\%I)
FOR %I IN (.ssh) DO (RMDIR /Q /S "%USERPROFILE%\%I") & (MKLINK /D "%USERPROFILE%\%I" \\psf\Home\%I)

Command Prompt Symlink

Hope this helps someone else–it makes my life easier.

For your convenience I’ve attached a batch file that will create the symlinks. You do NOT have to run it as an administrator, it will do that step for you. Btw, you’ll only see the attachment if you are logged in.