Search code examples
linuxbashsystem-administration

redirect output to other partition linux


So, I have a scientific server with a HDD and a SSD hard drive. Where for computations involving lot's of data reading/writing a user can use the SSD but all the home directories are on the HDD.

Is there an automatic way to redirect the output of any program writing on the SSD to the home directory of the user running the program if the SSD is full?

If the best solution is to write my own script, then what is the best way to determine if the SSD runs out of space?

My OS is Ubuntu 18.04 LTS


Solution

  • In short, I do not think there is such a thing and I do believe that you should implement a bash script that checks (my tool of choice would simply be df) that there is enough space for you to run the next computation run before actually doing it. Maybe you should pre-allocate the space you intend to use, if possible, to avoid other concurrent runs to crash/run out of space? Maybe you should have an automated procedure to clean up some space?

    Obviously, you could have the ssd available on some mountpoint in /home/, and then periodically check with a cron job whether it is full. And the maybe unmount it and send a warning mail. This will sort of do what you want. Sort of. But what happens then when also the HDD gets full? Watch out- these kind of problems can easily cause a server to crash, or otherwise experience issues.

    This looks like a problem you might partially solve/mitigate by e.g., using a quota scheme (that is, limiting the amount of space that each user can allocate) or better yet by using a dedicated system for queueing jobs and allocating resources.