Maintaining a sane memory disk

I maintain a memory disk for nginx which is initialized at daemon start time. Right now, I've simply added logic to the init script to unmount the memory disk if its already mounted, format /dev/ram10, mount it, rsync from an archive on physical disk in to the mounted memory disk, and set new permissions on the mount point of the memory disk.

This is done, mounted with noatime, to serve images at lightning speed. It works out real well.

I guess this works, it just seems kind of trashy. I am considering autofs because, using that, I can call an external script to do all this logic and not have to worry about tainting the init script for the service. I'd need to set a very high timeout on the mount in autofs to make sure that it does not try to remount this disk too often. The disk archive contains some ~20,000 items totaling just over 400M.

Has anyone done something similar to this? Like I said, the system works now but I think it can be improved and made more stable.

Copyright 1998-2015 Ziff Davis, LLC (Toolbox.com). All rights reserved. All product names are trademarks of their respective companies. Toolbox.com is not
affiliated with or endorsed by any company listed at this site.