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.

Pavel
  • 417
  • 1
  • 7
  • 17

3 Answers3

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).

lsd
  • 1,673
  • 10
  • 10
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.

Tometzky
  • 2,679
  • 4
  • 26
  • 32
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.

dawud
  • 15,096
  • 3
  • 42
  • 61