1

I plan on using the Raspbian derivative Industrial Perennial Environment or a similar solution to create a blackout-proof headless Raspberry Pi for use with various electronics. Obviously this means persistent storage is impossible and that's fine; however, I would need a reasonable amount of temporary, volatile storage. I anticipate that the Pi's RAM size is not sufficient to solve this problem with an in-memory filesystem. Instead, I'd like to use a thumb drive as volatile storage, without relying on any kind of luck – the file system must always be ready for a fresh usage session after a spontaneous power cycle.

One potential solution I thought of is re-partitioning and re-formatting the drive to a non-journaling file system (not sure which one would be best for this use case) automatically on every boot in an init script. A variant would be to keep the partition table and file system in place and run fsck -y and rm -rf * every time instead.

  • Are these viable solutions? Do better alternatives exist?
  • Any special considerations or side-effects to be aware of?
  • Is it safe to assume that the drive won't be physically damaged by the power cycles, or otherwise degraded in a way that can't be undone by re-initializing the drive?
1

If you want the volatile storage to always come up with a few files on it already, you could use DD to copy an image stored on the readonly partition to your volatile memory. This might give you a faster boot time (test it of course). You would set that up like this:

  • format the drive with your preferred filesystem.
  • Save the image like this dd if=/dev/sda1 of=/root/diskimage.img
  • At boot reimage the disk like this dd if=/root/diskiamge.img of=/dev/sda1

You can also use this same process to force a known good partition table onto your usb thumb drive: http://www.cyberciti.biz/tips/linux-how-to-backup-hard-disk-partition-table-mbr.html

You should take a look at this fs comparison and choose the one that is best for you (and then test its performance for your workload of course): http://www.howtogeek.com/howto/33552/htg-explains-which-linux-file-system-should-you-choose/

0

How large would the temporary volatile storage need to be? For an embedded system the the Pi has quite a lot of ram. With the model B you can get about 350 MB for an in-memory ram filesystem. (Can't post this as a comment.... I need more "reputation"...)

  • I am aware of the amount of available RAM. Like I mentioned in my question, I concluded that I need more than just a few hundred megabytes; one of my uses for the storage is encoding and temporarily storing video recorded with the PiCam. This storage doesn't have to be as fast as memory, and is basically what you'd normally use an SD card or a flash drive for, except it needs to be resilient against power failure. – Another Code Jul 3 '14 at 12:31
  • To my knowledge you can always reformat the thumb drive it the fs becomes corrupted. However, a separate read-write partition on the SD card might work just as well. I would set up a test rig an do some testing... – Ronny Nilsson Jul 3 '14 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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