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

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

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

Post 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.
georgesattali
Posts: 84
Joined: Saturday 05 March 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post 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
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

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

Post 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.
guus_b
Posts: 8
Joined: Sunday 26 January 2014 15:07
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

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

Post 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).
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

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

Post 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
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

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

Post by Egregius »

Why should you reboot? A Linux system should (almost) never reboot.
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

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

Post by woody4165 »

Perfect, thanks!
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

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

Post by pvm »

You can also move your filesystem to iscsi on a nas
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

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

Post 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!!
guus_b
Posts: 8
Joined: Sunday 26 January 2014 15:07
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

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

Post 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
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

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

Post 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 3054 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
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

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

Post 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 3035 times
Got some errors wich I don't understand. I hope that somebody cab point me in a good direction.

Thanks
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

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

Post by Jan Jansen »

I took a break and then I tried again. I started reformatting the USB stick. It now works as desired.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest