#!/usr/bin/env bash
set -euo pipefail
NAME="RAMDISK"
MB=4096
SECTORS=$(( MB * 2048 ))
echo "Creating ${MB}MB RAM disk..."
DEV="$(hdiutil attach -nomount ram://${SECTORS} | awk 'END{print $1}')"
if [[ -z "$DEV" ]]; then
echo "❌ Failed to allocate RAM disk"
exit 1
fi
diskutil eraseVolume APFS "$NAME" "$DEV" >/dev/null 2>&1
echo "✅ RAM disk mounted at /Volumes/$NAME"