This is the strange error i came across, my php script intermittently gives error failed to open stream: No space left on device whenever i try to generate text file and write some user generated content in it. But my Disk have plenty of Space.
Code i use is below:
$fp=fopen('../user1/dataProduct.txt','w');
fwrite($fp, 'Demo Text of Products');
fclose($fp);
If i do: df -H
Error:
PHP Warning: fopen(../user1/dataProduct.txt): failed to open stream: No space left on device in /home/goashopping/public_html/sell/userprod.php on line 192
PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/goashopping/public_html/sell/userprod.php on line 195
Please help me in fixing this issue.
Check free inodes with df -i
you@yourbox:~$ df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 532480 46391 486089 9% /
Filesystems with lots of little files usually run out of inodes way before running out of space. If this is your case you'll need to rebuild the filesystem and use mkfs -i
to increase the available inodes on it.
Perhaps the disc does not have enough free inodes, check it:
df -i
And also read this No space left on device
I agree that it seems likely to be an inode problem, but I too experienced this issue intermittently. It occured in only one directory.
file_put_contents(/archive/ETG/content/original/173530/event/173530_unplanned_outage_rd_20150107_fd_20150107_152715_6.pdf): failed to open stream: No space left on device
$php --version
PHP 5.3.28 (cli) (built: Jun 27 2014 15:36:16)
$uname -ior
2.6.18-238.19.1.el5 x86_64 GNU/Linux
$df -ih /archive
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/vg03--archive-archive
669M 57M 613M 9% /archive
$df -h /archive
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg03--archive-archive
5.2T 3.9T 1.1T 79% /archive
$mount |grep archive
/dev/mapper/vg03--archive-archive on /archive type ext3 (rw)
$find /archive/ETG/content/original/173530/event -type d -prune -ls
21610738 779840 drwxrwxrwx 3 gasconcoll gasconcoll 797769728 Jan 7 10:28 /archive /ETG/content/original/173530/event
$ls -altr /archive/ETG/content/original/173530/event/ |wc -l
8000842
$du -sh /archive/ETG/content/original/173530/event
49G
I resolved the issue by doing the following:
$mkdir /archive/ETG/content/original/173530/event_new
$chmod ugo+rwX /archive/ETG/content/original/173530/event_new
$mv /archive/ETG/content/original/173530/event /archive/ETG/content/original/173530/event_old
$mv /archive/ETG/content/original/173530/event_new /archive/ETG/content/original/173530/event
$rsync -av /archive/ETG/content/original/173530/event_old/ /archive/ETG/content/original/173530/event
I no longer experience this error. I don't have enough time to dig further, but thought you might want to know what worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With