'No space left on device' Issue With vserver

I was running into an issue with a vserver where the disk space usage was at 23% but I was getting a 'No space left on device' error message. I run vserver with 12 virtual servers and none of the other servers exhibited the same behavior.

As it turned out the issue was with some PHP applications that were storing their sessions in a per-domain basis rather than in the default /tmp location. For security purposes I isolate/sandbox the sessions within the application root where the www-data user cannot access. The session files were not being cleaned up and one PHP application has been running since 2003 (!).

The real problem: too many files on the ext3 filesystem.

PHP does it's own garbage collection for sessions that have terminated before session_terminate() is called (eg. when a browser is shutdown). However garbage collection is not done on non-standard session directories. As php.ini explains:

; NOTE: If you are using the subdirectory option for storing session files
; (see session.save_path above), then garbage collection does *not*
; happen automatically. You will need to do your own garbage
; collection through a shell script, cron entry, or some other method.
; For example, the following script would is the equivalent of
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
; cd /path/to/sessions; find -cmin +24 | xargs rm

I changed directory to the sessions folder and ran the following command to clean up the situation:

find -cmin +24 -name 'sess_*' | xargs rm

Links

php.net: session_save_path()
php.net: session configuration
Garbage Collection

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

great MANY thanks I had this

great MANY thanks
I had this problem at vserver with LVM filesystems and no indices why ... just that "no space left on device"
for about 2hours looking for problem with LVM but your TIP to clean php sess_* files was the right remedy. THANKyou

Post new comment

The content of this field is kept private and will not be shown publicly.
By submitting this form, you accept the Mollom privacy policy.