Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create and manage a case-sensitive disk-image on OSX. This is great when you have a need to work with case-sensitive repos on a mac.
#!/bin/bash
# where to store the sparse-image
WORKSPACE=~/Documents/workspace.dmg.sparseimage
create() {
hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 60g -volname workspace ${WORKSPACE}
}
detach() {
m=$(hdiutil info | grep "/Volumes/workspace" | cut -f1)
if [ ! -z "$m" ]; then
hdiutil detach $m
fi
}
attach() {
hdiutil attach ${WORKSPACE}
}
compact() {
detach
hdiutil compact ${WORKSPACE} -batteryallowed
attach
}
case "$1" in
create) create;;
attach) attach;;
detach) detach;;
compact) compact;;
*) ;;
esac
@MrApe

This comment has been minimized.

Copy link

commented Nov 11, 2015

Great man! Saved me a whole lot of time building OpenWRT on my mac.

@mhauri

This comment has been minimized.

Copy link

commented Feb 24, 2016

Thank you, this was exactly what I was looking for.

@scottsb

This comment has been minimized.

Copy link

commented Feb 24, 2016

FYI, I've worked on a further developed version of this script there:
https://gist.github.com/scottsb/479bebe8b4b86bf17e2d

@coolchevy

This comment has been minimized.

Copy link

commented May 25, 2016

Thanx!

@strogonoff

This comment has been minimized.

Copy link

commented May 19, 2018

Re https://gist.github.com/dixson3/8360571#file-workspace-sh-L7, see https://discussions.apple.com/thread/2001162 on SPARSE vs. SPARSEBUNDLE, the latter may be a better choice.

@deadlyicon

This comment has been minimized.

Copy link

commented Sep 27, 2018

I was running a setup very similar to this when I upgraded to Mojave I found that mounted disk image's disk performance was so slow as to be unusable. So I made a new image using APFS (Case-sensitive) instead of Mac OS Extended (Case-sensitive, Journaled) and it was much much faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.