MacOS – hdiutil: Creating case-sensitive image fs for Steam

filesystemmacossteam

I'm attempting to use Steam on my Mac, but I set up my system to have case-sensitivity.

Steam has a thread for setting up an image file with a case-sensitive file system, however, I'm finding that it doesn't work.

Regardless of whether I create the sparse image from Disk Utility or from hdiutil, I get a mount-error.

hdiutil: attach failed - no mountable file systems

However, as far as I can tell I've created the file correctly?

#!/usr/bin/env bash
set -e

MOUNTPT="/.000"
SPARSEIMG="/Users/Shared/Steam/steam.sparseimage"

if [ ! -e "${MOUNTPT}" ]; then
    echo "sudo mkdir -m0777 ${MOUNTPT}"
    sudo mkdir -m0777 "${MOUNTPT}"
fi

if [ ! -e "${SPARSEIMG}" ]; then
    hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 32g "${SPARSEIMG}"
fi

hdiutil attach -mountpoint "${MOUNTPT}" -nobrowse "${SPARSEIMG}"

Can anyone tell me what I am not doing correctly?

UPDATE:
The image that's created mounts properly in Disk Utility, but does not with hdiutil

Best Answer

It's a better practice to leave all uppercase variables for the shell and use lower and or mixed case for user variables in scripts. You need to preface the hdiutil attach ... command too with sudo if using /.000 as the mount point.

Here's my version of the script which works.


#!/bin/bash

set -e

mountpt="/.000"
sparseimg="/Users/Shared/Steam/steam.sparseimage"

[ ! -d "$mountpt" ] &&  sudo mkdir -m0777 "$mountpt"
[ ! -e "$sparseimg" ] && hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 32g "$sparseimg"

sudo hdiutil attach -mountpoint "$mountpt" -nobrowse "$sparseimg"

enter image description here