If you’re like me, you probably don’t think a lot about what you throw into the trash on your computer – you just put files and folders in there to be deleted and, eventually, you empty the trash. The other day I dropped a 40GB virtual machine into the trash and then told OS X to empty the trash. A few hours later, it was still chugging away at pretending it was deleting the trash. There were no messages in Console about files being locked and unable to be cleaned up and no warnings of any other kind.
Being the resourceful individual that I am, I dropped into the terminal and ran
sudo rm -rf .Trash/*. That process hung as well. I checked the console and all of the various logs again and there was nothing going on.
As a last resort before giving up and switching to the backup computer, I rebooted the Mac into single user mode (hold down Command-S during the boot sequence). Once I was in single user mode, OS X dropped me off at a command prompt as the root user. A few quick
cds later and I was able to once again
rm -rf .Trash/*. This time it worked like a charm.
I have no idea what happened and there were no logs to point me in the right direction. I can only assume that OS X got hung up trying to read the contents of the virtual hard disk which is, in reality, nothing more than a bundle of files, much like an OS X application. Maybe there was just too much junk…
This is a pretty simple process, but one that I thought I would document because I ran into a few gotchas along the way.
I originally installed OS X using the one click installer from EnterpriseDB. Unfortunately, the installer hung while attempting to finish the installation process and they only thing to do was to roll back the install. I attempted to build from macports, but that proved to be a huge pain in my ass and reminded me a little bit too much of using Linux, so I scrapped that idea as well. I started browsing the EnterpriseDB installation notes and came across an unattended install. Since my installation failed trying to launch the final interactive stage of the installation, I said to myself “Self, I bet we should try this.”
- Download PostgreSQL from EnterpriseDB http://www.enterprisedb.com/products/pgdownload.do#osx
- Mount the OS X disk image file
- In the Terminal, change to the directory where the image file was mounted:
cd /Volumes/PostgreSQL\ 8.4.2-1/
- Start the unattended installation
- Once the installation has finished, add the following line to your .profile:
If you’ve never created your .profile you can do the following in a terminal window:
This will create the file if it doesn’t exist and will only change the last modification date if it does.
open /Applications/TextEdit.app .profile
This opens your .profile in the TextEdit application
- Save and close your .profile
- Create a new database user.
createuser [YOUR NAME HERE] --pwprompt --username=postgres
This could be anyone...
- When you’re prompted for the “Password:”, use “postgres”. This is the default password for the postgres superuser. Because you’ve just created another superuser, you’ll never have to touch this account again, but you should probably look up some fantastic documentation and learn how to change the password.
I'm a real live boy!
There you have it: how to set up and install PostgreSQL on OS X. If you want to continue forward and install a Ruby library to interact with PostgreSQL, just type
sudo gem install postgres-pr to install the pure Ruby version PostgreSQL driver. If you want to install one of the C-based drivers, you’ll need to mess around with macports.
Note: EnterpriseDB make and distribute a binary version of PostgreSQL for a variety of platforms. In addition, they provide paid support and also offer a variety of enterprise features. They have in no way paid me for this post.
PostgreSQL Tutorial – Creating Your First Database
PostgreSQL Tutorial – Creating the Pagila Schema
PostgreSQL Tutorial – Referring to Other Tables
PostgreSQL Tutorial – Inserting Data