0

I am installing postgres 8.4 on an ubuntu lucid server (no, at the moment we are using the "lucid" LTS version on that server so an upgrade is not possible yet (although we are going to start testing the system on precise quite soon now))

I have set up an own partition for the /var/lib/postgresql/8.4/main directory with a ext4 file system. (Those of you who are really into postgres installs knows what is happening now...) Since ext4 puts a lost+found directory in the root of all file system, postgres will not use that directory as its data-directory since it is initially not empty...

initdb: directory "/var/lib/postgresql/8.4/main" exists but is not empty If you want to create a new database system, either remove or empty the directory "/var/lib/postgresql/8.4/main" or run initdb with an argument other than "/var/lib/postgresql/8.4/main".

The easiest way to proceed would be to remove the lost+found and recreate it after initdb has done its job. - could that cause any problems? Does the lost+found have any special attributes or anything that makes it impossible to recreate, and also, it is needed at any other time than if checkdisk finds something it needs to put there?

Another way would be to unmount the .../main/ file system, init the database, temporary mount the .../main/ filesystem somewhere else, move things over there and mount it in place. Seems to be a bit more work than the "easiest way".

Or is it some way to make initdb ignore that the directory is not empty? (couldn't see any command line switches for that)

May a lost+found directory within postgres main directory cause any problems?

At the moment I am running the system on a virtual machine for testing, so it really doesn't matter if I mess up things, but before making this an official way of installing a mission-critical system, it would be nice to have some thoughts on this.

4
  • Why not create a subdir in the root of the mounted FS, and make that the basedir for Postgres? (or make /var/lib/postgresql/8.4 the mountpoint; and make main a subdir in the mounted FS) Dec 5, 2012 at 13:42
  • BTW: since you appear to do a fresh install, why not install postgres-9.2.X instead? Dec 5, 2012 at 13:54
  • Yeah, that may be the best... Often too easy to overlook the simplest.. For the BTW, this is an app that is presently runnning on lucid / pg8.4 and it cannot be moved to 9.2 before it is tested there. Dec 5, 2012 at 14:00
  • In that case it would seen reasonable to make /var/lib/postgresql/8.4 or even /var/lib/postgresql/ the mountpoint and main resp 8.4/main the subdir. BTW2: personally, I would never put a mountpoint under /var/ (which could be mounted itself; and is rather volatile), but give it its own place nearer to the root. Dec 5, 2012 at 14:06

1 Answer 1

0

lost+found has preallocated blocks that make it easier for fsck to move data into it when the partition is short of free blocks. To create it, better use the mklost+found command rather than mkdir.

If you don't recreate it, fsck will do it anyway when it's needed.

But if it comes to the point where fsck finds corruption within PGDATA, I'd think about going for a backup rather than counting on lost+found to retrieve anything.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.