Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top