4

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

2
  • Under what operating system? At least Solaris, Linux and NetBSD have a filesystem called tmpfs. Feb 12, 2011 at 20:59
  • @Gilles I was thinking about Linux. Thanks for helping clarify the question :)
    – netvope
    Feb 12, 2011 at 21:40

4 Answers 4

1

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.

3
+25

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.

1

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

2
  • 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, 2011 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. Feb 16, 2011 at 15:20
-1

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

not tested

You must log in to answer this question.

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