Search code examples
phplinuxfilesystemsdiskspace

Issue with writing files into Linux using PHP


I have a problem - I have a PHP script that copies large data files one of our linux servers, which is used as intermediate storage for data files. It then pushes these data files to our various partner servers. Recently I noticed that the disk was getting filled up.

When I did a df -h on the disk, I got the following:

Filesystem      Size  Used Avail  Use% Mounted on
/dev/xvda1      29.9G  29.9G  0G  100% /
none            828M     0  828M   0%  /dev/shm
/dev/xvdb       147G  188M  140G   1%  /mnt/ephemeral

It seems like the data files are being stored in /dev/xvda1 which already has a very small space. /dev/xvdb has a lot of space but seems like the files never get saved there.

The PHP script I run is located in /var/www/html/data-transfer folder of the linux box. The file is regular ftp functions of PHP which writes to the local hard disk. There is nothing fancy in the code.

I am bit confused here, what does /dev/xvda1 and /dev/xvdb mean? How can I modify my script to write to /dev/xvdb instead?

As you can see, I am pretty newbie about linux filesystems,any help is greatly appreciated!


Solution

  • Your question actually is: how do I find out what place inside the file system a partition is mounted to?

    Consider this entry from your example:

    /dev/xvdb       147G  188M  140G   1%  /mnt/ephemeral
    

    It tells you that the device (disk/partition) /dev/xvdb (whatrever that is) has been mounted (imported) to your local file system at position /mnt/ephemeral.

    So the later is the location you are interested in, this is where the space is you want to use. So you should modify your storage code such that it saves the files inside that location.

    Oh, and a hint: don't forget about cleaning up in there, otherwise that location will fill up too pretty fast, no matter how big it actually is...