Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I create consistent snapshots of tmpfs or any RAM disks?

share|improve this question
    
Under what operating system? At least Solaris, Linux and NetBSD have a filesystem called tmpfs. –  Gilles Feb 12 '11 at 20:59
    
@Gilles I was thinking about Linux. Thanks for helping clarify the question :) –  netvope Feb 12 '11 at 21:40
add comment

5 Answers

up vote 1 down vote accepted

Well, I haven't done this, but it may be possible to create a lvm volume in a file which resides on your tmpfs, and loopback mount it elsewhere. You'll suffer some performance penalties and have to recreate it every time you reboot.

share|improve this answer
add comment

On NetBSD we have something called "fss" which can be controlled with the "fssconfig" utility. I'm not sure if this is available on Linux, or perhaps it is but possibly under a different name? I'm sure someone in IRC would be able to answer that quickly (I've had really good success on irc.freenode.net).

The following man pages will likely be interesting to you:

man fssconfig man fss

What this tool will do is to create a snapshot of a file system at a mount point of your choosing, and then any changes will be isolated from the snapshot. I haven't tried it, but I'm assuming that it will work just fine with a RAM disk since this is a disk utility.

I hope this helps, or at least gets you headed in the right direction.

share|improve this answer
add comment

If the contents of your tmpfs is so important that it needs snapshoting and even backups, I'd rather not use tmpfs at all but write it to disk. There you can use the traditional snapshoting facilities (lvm, btrfs, ...).

If you don't do much synchronous writes (which wouldn't make sense with a tmpfs anyway) and have enough spare RAM for cache (which you'd need for a tmpfs anyway), I see little advantage in sticking to the RAM disk. Just use a traditional disk-based filesystem with warm caches.

As far as I know, there is no usable way to actually snapshot the RAM contents on x86 hardware. There are some SPARC (?) processors which support transactional memory, but I guess that doesn't apply here...

share|improve this answer
    
You're right, but it would be useful if a program (that you have no access to the source) do synchronous writes or flush the writes very often. Perhaps we can use LD_PRELOAD to hijack the library calls and force the program to do asynchronous writes? –  netvope Feb 15 '11 at 22:39
    
Normally, when a program does synchronous writes, it has a very good reason for that (like being a database). You should be very careful when trying to disable that (e.g. by writing to volatile memory or by messing with syscalls). You should really think about data safety. Most of the time, this is worth many times more than the last bit of performance. And writing stuff to RAM is GOING TO kill your data. –  Holger Just Feb 16 '11 at 15:20
add comment

on ubuntu one only has to go to /dev/shm/ to view the content of the ram itself

if using a ramdisk,then just goto the ramdisk's mountpoint..

so a cronjob running dd on that folder should do the trick..

if using windows.. use a batch file to run dd.. to use dd on windows refer to this site: http://software.intel.com/en-us/articles/dd-for-windows/

share|improve this answer
    
I think you misunderstood the question. Obviously, you can copy all the files. But this doesn't create a consistent snapshot: if another process modifies the contents of the filesystem while you're backing it up, you'll get an inconsistent view, i.e. the backup may not reflect the exact contents of the filesystem at any point in time. –  Gilles Feb 12 '11 at 20:59
add comment

create a image file on tmpfs, loop ip, pvcreate it. create a lv and then you can create a snapshot.

not tested

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.