Skip to content

Instantly share code, notes, and snippets.

@jezdez
Created June 14, 2011 10:26
Show Gist options
  • Save jezdez/1024647 to your computer and use it in GitHub Desktop.
Save jezdez/1024647 to your computer and use it in GitHub Desktop.
A script to start a Homebrew postgres in memory (needs lunchy to automatically stop the global postgres instance, gem install lunchy)
#!/bin/bash
# get lunchy: gem install lunchy
lunchy stop postgres
# Run this script to enable the Ramdisk for Postgres
VolumeName="postgres-memory"
# Size in MB, make sure is not too low or not too high
SizeInMB=2048
NumSectors=$((2*1024*SizeInMB))
DeviceName=`hdid -nomount ram://$NumSectors`
VolumePath="/Volumes/$VolumeName"
echo $DeviceName
diskutil eraseVolume HFS+ $VolumeName $DeviceName
cp -R /usr/local/var/postgres $VolumePath/postgres
chown -R $USER:admin $VolumePath/postgres
/usr/local/bin/postgres -D $VolumePath/postgres
umount $VolumePath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment