Skip to content

Instantly share code, notes, and snippets.

Created January 10, 2014 19:11
Show Gist options
  • Save dixson3/8360571 to your computer and use it in GitHub Desktop.
Save dixson3/8360571 to your computer and use it in GitHub Desktop.
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.
# where to store the sparse-image
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
attach() {
hdiutil attach ${WORKSPACE}
compact() {
hdiutil compact ${WORKSPACE} -batteryallowed
case "$1" in
create) create;;
attach) attach;;
detach) detach;;
compact) compact;;
*) ;;
Copy link

MrApe commented Nov 11, 2015

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

Copy link

mhauri commented Feb 24, 2016

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

Copy link

scottsb commented Feb 24, 2016

FYI, I've worked on a further developed version of this script there:

Copy link


Copy link

Re, see on SPARSE vs. SPARSEBUNDLE, the latter may be a better choice.

Copy link

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.

Copy link

Foadsf commented Dec 18, 2021

For those who end up here, a minimalistic solution here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment