0

I've created an encrypted volume with TrueCrypt that is currently mounted on Mac OS X (v10.6.6). I have moved both MySQL and Postgres (v8.4) data to my encrypted volume and created symlinks to them. When the MySQL daemon is running and I eject the volume, it will eject without an issue. However, when the Postgres daemon is running and I attempt to eject the volume, a notice pops up saying,

The disk wasn't ejected because one or more programs may be using it.

Are there any work arounds for this?

1 Answers1

5

Stop the daemon so it closes out the files?

I guess I'm not fully understanding...you put the database files on the volume that you're trying to eject while the database is running? That really won't work well. You'd have to stop the database first so there's no open file handles referencing the volume.

Bart Silverstrim
  • 31,172
  • 9
  • 67
  • 87
  • I have the database files on the volume. And I'm trying to eject it while it is running, yes. My goal is to have this encryption work intuitively so it disrupts my workflow as little as possible. It works with MySQL and my guess is, instead of symlinking the entire data directory like I did with Postgres, I just symlinked the databases which allows me to eject the drive with MySQL running without complaint. Perhaps I will experiment with symlinking directly to the Postgres databases instead of the entire data directory, and see if that works out. – AnomalousThought Feb 07 '11 at 16:53
  • Forcing a dismount usually works still, but it wont end well for the DB. +1 Best to stop the daemon first. – Chris S Feb 07 '11 at 16:54
  • 2
    You can't eject it while the files are open unless you want corrupted databases. It won't work properly if the volume is yanked out from under the application. – Bart Silverstrim Feb 07 '11 at 16:55
  • Ok, I don't know how to stop Postgres. So I currently run `ps -ax | grep post` and kill it. I'll just have to figure out some more convenient way to start and stop it I guess. – AnomalousThought Feb 07 '11 at 16:59
  • @AnomalousThought, what workflow do you have that would require to dismount the volume used for a database without actually stopping the database first? – Zoredache Feb 07 '11 at 17:00
  • 1
    @Zoredache - maybe he's a data-corruption-pro – Chopper3 Feb 07 '11 at 17:03
  • @Zoredache - Reason being this is a non-production environment. All of my applications that use Postgres and MySQL are on that same volume. Therefore, if I eject the volume, my applications can't run anyways. So in my sensible workflow I wouldn't ever be ejecting the volume while using Postgres or MySQL. Also, these databases are backups, not production, and are very frequently destroyed. – AnomalousThought Feb 07 '11 at 17:19
  • @AnomalousThought You *should not* unmount a volume that is in use - ***ESPECIALLY*** a volume being used by a database server. If you force-unmount Postgres *will* crash as a result. The proper workflow is to shut down the database server (a proper, controlled shutdown, not killing off postgres processes in random order), and then unmount the volume when it is no longer in use. – voretaq7 Feb 07 '11 at 17:19
  • 1
    Never before has the phrase "You're doing it wrong" been so accurate. – Tom O'Connor Feb 08 '11 at 01:28