OS X – jozefmares.com
Home Tags Posts tagged with "OS X"


I needed to migrate Linux RAID partition (originating from Synology NAS) to new disk and I needed to do it under OS X.
With VMware Workstation this was not big deal, but seems like this is not possible from Fusion user interface.

Required steps

    1. Get name of device (use diskutil list or under Disk utility).screenshot_os_x_diskutil
    2. Start terminal (in Applications/Utilities).
    3. Change current working directory to WMware Fusion folder:
cd "/Applications/VMware Fusion.app/Contents/Library/"
    1. Create VMDK file which will be linking our real, raw device:
./vmware-rawdiskCreator create /your/device fullDevice ~/your-device ide
    1. Next, we need to go to folder where are virtual machines stored (usually Documents/Virtual Machines – in my case dedicated RAID drive).
    2. Find relevant virtual machine, click Show Package Contents.
    3. Move created file (your-device.vmdk) to opened folder.
    4. Open in favorite text editor machine_name.vmx and append:
ide1:1.present = "TRUE"
ide1:1.fileName = "your-device.vmdk"

You should be able to mount device under desired guest. I utilized this method to migrate data from RAID partition to USB drive during big clean-up and consolidation :).

Other small lessons learned

  • To make USB drive works as USB3 device you need at least kernel 3.2.
  • USB3 is really fast and stable, even under VMware Fusion.
  • Journaled HFS works very well under Linux, but you need to mount it with -o force,rw.

When I’m trying to create bootable Linux stick on Mac OS X (yes, I’m doing it) I usually get this error on PC (during boot attempt):

Missing operating system

This is because Unetbootin fails to set partition on USB stick as active and also somehow (I’m lazy to do code review) fails to install mbr.bin from syslinux.

This is how I fix it:

1. plug USB stick to Mac
2. list devices:

diskutil list

3. unmount usb stick (no, eject from Finder is not right thing to do):

diskutil unmountDisk /dev/disk2

4. fix problem with active partition:

sudo fdisk -e /dev/disk2
f 1
diskutil unmountDisk /dev/disk2

5. download syslinux

6. write mbr.bin to USB stick (locate mbr.bin first):

sudo dd conv=notrunc bs=440 count=1 if=mbr.bin of=/dev/disk2

7. write distribution as usual using Unetbootin.


It really sucks to keep two computers in sync. I am personally not able to keep anything in sync – that’s why I have to always find way how to automate stuff.

So, I have MacBook Air and Hack Pro. Both of computers are in active service (e.g. every day use). Hack Pro is utilised for very serious work which require at least dual-head, Air for creative (coffee shop) and external work. I want them in sync but not in full sync.

In my case there is also issue that Hack Pro have plenty of power to handle all tasks like filtering 10 000 of incoming mails from automated systems, build some of my software, play music with iTunes and even play full-hd video in the same time. On contrary, Air is just road warrior thing. Not so much of power but great portability. Thus, I do not want to do exactly same things on both but there are some essential things like keychain, some app configuration and so on which I want on both of them.


  1. two Macs;
  2. own server / VPS, NAS, whatever;
  3. spare time;
  4. you are not afraid of terminal.

Basically we are going to setup ownCloud, setup sync via Unison and enjoy simpler life.


I talked about Unison before – check it here. It is very cool tool, and if you are user of some sort of Unix OS you really should check it!

When I talked about ownCloud I did not mentioned why I’m setting it up. If there is Unison, why do I need ownCloud? Simple answer – I want web access to data and I am using ownCloud for calendar and contacts synchronisation. Other cool thing is one-click sharing with ownCloud – I’m using it extensively.

Let’s go to terminal. Open your terminal emulator:

mkdir .unison

Start your favourite text editor and go to .unison folder. We are going to create Unison configuration files. I have two profiles: dotfiles and files. These two profiles shares some common configuration.


# Common options for Unison
fastcheck               = true
sortnewfirst            = true
rsrc                    = true
auto                    = true
confirmbigdeletes       = true
silent                  = true

# What to ignore
ignore = Name *~
ignore = Name *.lock
ignore = Name .DS_Store
ignore = Name .tmp
ignore = Name *.swp
ignore = Name *._localized


# Sync roots
root = /Users/$USERNAME
root = ssh://YOUR-USER@YOUR-SERVER//home/USERNAME/TrustedPoint/dotfiles
include common

# What to synchronize
path = .bin
path = .ssh
path = .bashrc
path = .bash_profile
path = .gnupg
path = Library/Application Support/Adium 2.0
path = Library/Keychains/login.keychain
path = Library/Application Support/NetNewsWire

# Ignore these paths
ignore = Path {.gnupg/S.gpg-agent}

# Keep backup copy of every file on server
backuplocation = central
backup = Name *
backupprefix = $VERSION.
backupsuffix =

# Log actions
logfile = /Users/USERNAME/.unison/sync-dotfiles.log


Sync roots
root = /Users/USERNAME
root = ssh://YOUR-USER@YOUR-SERVER//home/USERNAME/TrustedPoint/files
include common

# What to synchronize
path = Documents
path = Downloads

# Ignore these paths
ignore = Path Documents/Virtual Machines.localized

# Keep backup copy of every file on server
backuplocation = central
backup = Name *
backupprefix = $VERSION.
backupsuffix =

# Log actions
logfile = /Users/USERNAME/.unison/sync-files.log

Login via SSH to your server, install Unison (same version as you have on your Mac), create folder structure:

mkdir -p TrustedPoint/files
mkdir -p TrustedPoint/dotfiles

Please notice, I’m using SSH access – for automation use keys and password-less login.


I recommend use your own server or NAS or something like that because I’m assuming that you can use SSH and install Unison. Consider buying VPS if you do not have your own server.

About ownCloud installation: installation is simple as uploading application to web hosting folder, visiting folder in browser and fill your desired login info and optional MySQL database login info. Just check it for yourself.

After installation keep only these modules enabled:

  • Archive support;
  • Calendar (if you want to use it);
  • Contacts (same as calendar);
  • Share files;

It is good idea to disable Versions plugin. Unison keeps own versions (and I think Unison does it better) so it is redundant. For me it is even more useless because I use owncloud only as a web front-end to my data.

You might ask why I’m not using ownCloud native clients? Simple reason –Inotify and FSEvents.
There is problem with way how ownCloud client works – it polls and scans whole synchronised file tree which is CPU heavy and thus is eating my in MacBook Air battery. Using ownCloud native client can drain my Air battery in one hour. Guys from ownCloud project are currently implementing two technologies mentioned above, so there is a hope that Unison step will be unnecessary soon. But for now – it is a must.

Your data on ownCloud server are located in folder:


Go to folder and create symlink:

ln -s /home/$USERNAME/TrustedPoint/files files

Fire it up!

Pre-flight check list:

  1. ownCloud is running;
  2. you have tested Unison;
  3. you have enough of space on your server/NAS/whatever;
  4. you backed up your files;

Go for it:

unison dotfiles
unison files

Everything working? Congratulations! Run it on second Mac.

Create script to run it in batch

Put it whenever you want, I have mine in $HOME/.bin/.

#!/usr/bin/env bash

PID=$(pgrep unison)

[ -z $PID ] && unison dotfiles -batch && [ -z $PID ] && unison files -batch

Create boot plist files

Now to automate Unison via Launchd

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">







And save it to /Users/USERNAME/Library/LaunchAgents/unison_sync.plist.

Load it with plutil:

plutil -lint ~/Library/LaunchAgents/unison_sync.plist

You can try to reboot to check if everything is working as expected.


So you are in the end and this setup is working for you? I’m glad to hear it. I’m using it over 3 months I’m pretty happy with it.

To answer few questions:

  • Yes, you can achieve same thing with DropBox – I’m not using public “cloud” services;
  • Yes, you do not need Unison if you do not care about your battery. It’s up to you;
  • Yes, I enjoy DIY;
Newer Posts