2

I have mounted tmpfs .e.g.

/tmspfs/cache

As we expect, so after restart server is ram empty and all content from mount is away. It is ok. But I have in my system some full path e.g. /tmpfs/cache/user1/file - error is /tmpfs/cache/user1/ is not exist.

I cant add some checks and rmdir to software.

So question is - Is some way here, for auto create whole path before create file?

Thanks.

2
  • Do you know the set of paths that you need to create ?
    – user9517
    Jun 27, 2014 at 12:08
  • +1 to the question, I think it should be added to the tmpfs driver. Another solution could be to use bind but it also requires to the folder to be created before binding Sep 13, 2019 at 9:44

3 Answers 3

0

Possible with LD_PRELOAD and some libraries, depending on the software. The easiest thing might be to put something in rc.local that will create the directories as a final step in the boot procedure.

If you wanted to make sure the directories are there continuously, you could have a cron job running that created the dirs (using mkdir -p possibly).

0

If you use /etc/fstab to define this mount you can just add mkdir /tmpfs/cache/user1 to /etc/rc.d/rc.local, so it will be created on boot.

0

If you need a persistent structure across reboots, the way you can implement this is by having a task in root's crontab:

*/5 * * * * /usr/bin/ionice -c3 -n7 /bin/nice -n 19 \
              /usr/bin/rsync -ah --stats --delete /path/to/persistent/backup /tmpfs/

Then in /etc/rc.local you ensure the structure is back in place at startup:

ionice -c3 -n7 nice -n 19 rsync -ahv --stats --delete /path/to/persistent/backup \
  /tmpfs/ 1>/dev/null

Of course, you need to adapt the rsync command to fit your specific needs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .