Page 1 of 1

Best practice to protect sd card (WIKI offers 2 options).

Posted: Sunday 26 June 2016 17:22
by Jan Jansen
Hi all,

I want to protect my sd card against damage.

As far I can understand wiki offers 2 options:
1. Setting up a RAM drive on a Raspberry Pi;
2. Setting up overlayFS on Raspberry pi;

What’s he best practice? Why is this best practice not installed by default (like MQTT broker, NodeJS, Node-red)?

Thanks in advance.

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Sunday 26 June 2016 20:45
by georgesattali
Hello,
here's a free opinion, purely mine :
* Setting up overlayFS should be better, but it's complicated and not well documented on Internet, whereas setting up several RAM drive for often accessed directories is very easy, so if not perfect, a good solution.

The best practice is not yet available, and you're right, I hope that someone will do it. We already have a very good basis (Thank you very much gizmocuz).

Personally, I set up 3 ram drives (by adding theses lines to /etc/fstab) :

Code: Select all

tmpfs /tmp     tmpfs  defaults,nosuid,nodev,noatime,mode=0755,size=4M 0 0
tmpfs /var/log tmpfs  defaults,nosuid,nodev,noatime,mode=0755,size=6M 0 0

tmpfs /var/gai tmpfs  defaults,nosuid,nodev,noatime,mode=0755,size=6M 0 0
The first 2 are system standard, the third is for my "own personal usage". The question of setting a ram drive for /var/log can be discussed, it is my personnal choice.

I am very interested in other opinions or other enhancements.
Have a good day,
GD

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Sunday 26 June 2016 22:19
by Egregius
Isn't 6M to small for /var/log?
You 'may' assign more, it will only be assigned when in use. I have mine set to 300M on RPI2.
Ofcourse you have to clean you're logfiles now and then.
One thing to consider is logging to specific folders. Like nginx is default set to /var/log/nginx/...log so you need to alter those configs to.

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Sunday 26 June 2016 23:30
by guus_b
There is a third option to protect the SD card: https://www.raspberrypi.org/forums/view ... 29&t=44177
I use this on all three of my rpi's (2x Domoticz, 1x OSMC).

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Monday 27 June 2016 10:45
by woody4165
guus_b wrote:There is a third option to protect the SD card: https://www.raspberrypi.org/forums/view ... 29&t=44177
I use this on all three of my rpi's (2x Domoticz, 1x OSMC).
Very well written document, it seems to be best solution.
In any case, SD or not SD, do you think that a daily/weekly reboot is needed to clean the system one in a while?

Thanks

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Monday 27 June 2016 11:07
by Egregius
Why should you reboot? A Linux system should (almost) never reboot.

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Monday 27 June 2016 11:32
by woody4165
Perfect, thanks!

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Monday 27 June 2016 13:24
by pvm
You can also move your filesystem to iscsi on a nas

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Tuesday 28 June 2016 21:07
by Jan Jansen
Thanks a lot for the ansers. "Move the filesystem to a USB stick/Drive" seems the best solution. I feel like a noob at this point. It seems difficult but I'll try.

I 'm not sure that I can start with a fresh Domoticz image. Woody4165 you know an answer to this?

Thanks in advance!!

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Wednesday 29 June 2016 9:18
by guus_b
You don't need a fresh Domoticz image. The step sudo rsync -axv / /mnt in the procedure creates a mirror of the current situation of your SD card.
I would stop the domoticz service before running that command, though.

Code: Select all

sudo service domoticz.sh stop

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Wednesday 06 July 2016 17:59
by Jan Jansen
I tried the suggestion of @ guus_b https://www.raspberrypi.org/forums/view ... 29&t=44177, without success. I got stuck very quickly (latest stable Domoticz).
Knipsel6.PNG
Knipsel6.PNG (56.94 KiB) Viewed 3063 times
After the command (df -h) the line rootfs is missing.
After ( lsusb) , for me everything seems OK
After ( tail /var/log/messages) , I can not find the USB stick.

What’s wrong?

Thanks in advance

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Wednesday 06 July 2016 20:15
by Jan Jansen
I just started with a fresh Jessie image (without Domoticz). I followed the instructions carefully https://www.raspberrypi.org/forums/view ... 29&t=44177.
Knipsel6.PNG
Knipsel6.PNG (77.25 KiB) Viewed 3044 times
Got some errors wich I don't understand. I hope that somebody cab point me in a good direction.

Thanks

Re: Best practice to protect sd card (WIKI offers 2 options).

Posted: Friday 08 July 2016 13:41
by Jan Jansen
I took a break and then I tried again. I started reformatting the USB stick. It now works as desired.