As most of my post containing tips, this one is also about how to integrate MacOS with a proper Linux developing environment without introducing a big overhead. The obvious question here would be: Why don’t you fully move to Linux and forget about having to integrate your everyday OS with your developing environment? Well, we all have our preferences and motives, which are not the goal of this post. For those who use a similar setup as mine here comes good news: Parallels 9 successfully approaches one of the biggest issues I have found when dealing with Virtual Machines (VMs) under MacOs: Sharing the file system between the host and the guest machines.
One of the main tasks I carry out in my Linux VM is compiling. However I prefer developing under Mac OS using YADR (see post) and iTerm2. The problem is that one or several directories have to be shared between the host (MacOS) and the guest (Ubuntu 12.10 in my case). This has always brought me problems: (i) some specific versions of Linux not being supported, (ii) MacOS not being case sensitive by default and colliding with git repositories (see post), or (iii) symbolic links being not allowed between the host and the guest. This post points a solution for the last problem. During the years I have tried several VM clients: VMWare, VirtualBox or Parallels; I decided to stick with the latter mainly because they all were very similar (i.e., neither of them approached the problems mentioned above for a long time), and also because I had purchased I license for Parallels. To my surprise, after a routine post to the parallels forum – this is, the kind of post you just leave there, angry for them not solving the problems you want them to solve and not really expecting anything in return – I got a big surprise: Symbolic links were going to be supported for Parallels 9. I upgraded immediately. (You can follow the post here).
Effectively, symbolic links are supported in Parallels 9. But not only that, they are supported both ways. Up until the moment, accessing MacOs file system (FS) was possible when Parallels Tools were installed, however, accessing the guest’s FS from Mac was impossible. While it is still not possible to open a terminal in the host and access the guest’s FS (it actually does not make that much sense either), it is possible to open a terminal from the guest, access a folder in the host, and within it use a symbolic link that points to a directory inside the guests FS again. Why is this so amazing? I will put an example: at this moment I am working in a project dealing with trusted environments (read post). The framework we are using needs to compile the linux kernel. We are integrating the framework with a specific board and dealing with different versions of the framework; unfortunately some parts of the code are given to us through a FTP server (not a git repo, grrrrrr). This causes that we have to deal with many versions of the framework, some of them being compatible with different kernel versions. Thus, being able to use symbolic links to only one version of each kernel is VERY convenient. (I am sure you can think of more cases where using this double symbolic link abstraction is useful). Put in a different way: with this setup it is possible to point to Linux specific libraries that reside and are compiled within the guestOS, while developing your application in the host OS, without having to copy a pre-compiled version of the library to the host FS. As I say, very convenient.
My setup is therefore complete. I can develop in my Mac and open one (or several) terminals and connect to my VM. Since I have also installed YADR in my Ubuntu machine, the process is almost transparent to me (I still need to pay attention to which terminal belongs to which machine, but that is an easy thing do when using several screens).
Just as a side comment, Parallels (other clients also support this) allows to start, stop and configure a VM from the terminal, hence starting the GUI is not necessary. This is more lightweight and as mentioned above more transparent. By typing prlctl –help or man prlctl you see the manuals. As a brief “start guide”, if you want to start a VM, connect a USB and connect to it: (Note that for the guest address you will have to start the GUI and run ifconfig to check it. This is only necessary once)
- $> prlctl start ubuntu-12.10
- $> system_profiler SPUSBDataType (copy the USB device name you want to connect)
- $> prlctl set ubuntu-12.10 –device-connect “<$USB-device-name>” (e.g., prlctl set ubuntu-12.10 –device-connect “CP2103 USB to UART Bridge Controller”)
- $> ssh <guest address>
- … <do what you have to>
- $> prlctl stop ubuntu-12.10
I hope you find this useful!