Page 1 of 1

Protect SD against going read-only

Posted: Fri Aug 11, 2017 2:37 pm
by glazura
Hey,

The SD that my raspbian was installed on just got read-only, and people suggested to get a new one, since this one is no longer useful.
I don't really want to buy one once every few months, so can someone suggest how can i protect it against this kind of damage?
I will admit, i was kind of careless and i would unplug the pi from the power source whenever i needed to move it, without a proper shutdown, so that might be part of the problem.

I've read that making the filesystem read-only can help me protect the sd against damage, but i want to make my pi an apache server, a HTPC and a NAS at the same time, and i don't think i could make a filesystem work with this kind of stuff.

Any suggestions?

Re: Protect SD against going read-only

Posted: Fri Aug 11, 2017 3:50 pm
by Heater
I had this issue with SD cards going read-only or just parts of them going read- only a few times back in the early Pi days. Nothing would fix them and nobody offered a suggestion as to why this happened. Apart from the mantra of "Use a good power supply, use good SD cards, always shutdown cleanly"

In recent times it has not happened to my collection of Pi 3. I'm pretty careless about yanking the power at any time. Deliberately, I'm curious to see how well they stand up.

For important things I think making the SD read only is a very good idea, almost essential. I recently made a read only SD file system using
ejolson's instructions here: viewtopic.php?t=161416. Works well.

If I needed storage on a read-only root Pi I would add another storage device, a USB stick or SSD, for that data.

Other than that, follow the mantra, "Use a good power supply, use good SD cards, always shutdown cleanly"

Re: Protect SD against going read-only

Posted: Fri Aug 11, 2017 8:36 pm
by hommar
Heater wrote:
Fri Aug 11, 2017 3:50 pm
For important things I think making the SD read only is a very good idea, almost essential. I recently made a read only SD file system using ejolson's instructions here: viewtopic.php?t=161416. Works well.
Good alternative:
1) rootfs is f2fs
2) logs, tempfiles and caches on tmpfs
3) swap in zswap

Re: Protect SD against going read-only

Posted: Fri Aug 11, 2017 8:56 pm
by Heater
What actually is the point of f2fs here?

I do understand that it is designed to be "flash friendly" in terms of wear leveling and so on but I have yet to find any statement that is more robust against random power outages than anything else.

Is there a simple way to get f2fs into use as the rootfs on the Pi? The instructions I have found so far are far to involved for me to want to get into.

Any one here with any experience of f2fs on the Pi?

Re: Protect SD against going read-only

Posted: Fri Aug 11, 2017 9:04 pm
by hommar
Heater wrote:
Fri Aug 11, 2017 8:56 pm
What actually is the point of f2fs here?

I do understand that it is designed to be "flash friendly" in terms of wear leveling and so on but I have yet to find any statement that is more robust against random power outages than anything else.

Is there a simple way to get f2fs into use as the rootfs on the Pi? The instructions I have found so far are far to involved for me to want to get into.

Any one here with any experience of f2fs on the Pi?
I use f2fs

F2FS have not wear leveling. F2FS have write buffer, and then ext4 write several times f2fs write one time
F2FS faster then ext4 several times, then need write small blocks
F2FS is "flash friendly" becouse minimized write times

F2FS and SDcard do not like random power outages.

PS I do not like f2fs on Rasbian Jessie, becouse Jessie have very old f2fs-tools

Re: Protect SD against going read-only

Posted: Sat Aug 12, 2017 1:06 pm
by allfox
Debian still recommend ext4 on SSD: https://wiki.debian.org/SSDOptimization

I don't know this btrfs thing, it looks like it's the future.

Re: Protect SD against going read-only

Posted: Sat Aug 12, 2017 3:55 pm
by Ronaldlees
Heater wrote:
Fri Aug 11, 2017 3:50 pm
I had this issue with SD cards going read-only or just parts of them going read- only a few times back in the early Pi days. Nothing would fix them and nobody offered a suggestion as to why this happened. Apart from the mantra of "Use a good power supply, use good SD cards, "always shutdown cleanly" ...

In recent times it has not happened to my collection of Pi 3 ...
This was always a bigger problem with earlier USB thumbdrives. Basically, the little (usually ARM) processor on the thumb or uSD disk maintains a meta data system for figuring out where and how to write to the underlying NAND flash of the user file-system. and the meta data table gets messed up with an unexpected power-off. The earlier/cheaper disks did not do a very good job of fscking themselves, for meta data, which was sometimes in a small separate NAND (or other memory) section.

So, with the Pi3 you are probably using newer disks, and they're better coded.

Still, all of the suggestions are good. The less frequently you write, the less chance for metadata mess-ups, sinces it's only during writes that this happens. So memory disks for logs, good shutdown practice, etc - all good ideas.

Re: Protect SD against going read-only

Posted: Sat Aug 12, 2017 4:03 pm
by rpdom
allfox wrote:
Sat Aug 12, 2017 1:06 pm
I don't know this btrfs thing, it looks like it's the future.
I use it on servers. Its ok when it works, but a real pain if you want to back it up and restore to another system. There's a really convoluted way of doing it. Ill stick to ext file systems for now.

Also for some reason btrfs doesn't play well with Dovecot if you're running a mailserver. Some files keep getting read errors and you have to delete the file and let Dovecot rebuild it (which it does without fuss).

Re: Protect SD against going read-only

Posted: Mon Aug 14, 2017 12:18 pm
by Windcheetah
Sorry, no real answer, but mine was from Kingston, and they have just sent me another one!! :D :D :D
Martin

Re: Protect SD against going read-only

Posted: Mon Aug 14, 2017 1:28 pm
by Ronaldlees
Windcheetah wrote:
Mon Aug 14, 2017 12:18 pm
Sorry, no real answer, but mine was from Kingston, and they have just sent me another one!! :D :D :D
Martin
I've had good luck with those (especially their SSDs).