glazura
Posts: 5
Joined: Thu Apr 27, 2017 2:36 pm

Protect SD against going read-only

Fri Aug 11, 2017 2:37 pm

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?

Heater
Posts: 13087
Joined: Tue Jul 17, 2012 3:02 pm

Re: Protect SD against going read-only

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

hommar
Posts: 172
Joined: Sat Mar 25, 2017 1:55 pm
Location: Russia, Yekaterinburg

Re: Protect SD against going read-only

Fri Aug 11, 2017 8:36 pm

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

Heater
Posts: 13087
Joined: Tue Jul 17, 2012 3:02 pm

Re: Protect SD against going read-only

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?

hommar
Posts: 172
Joined: Sat Mar 25, 2017 1:55 pm
Location: Russia, Yekaterinburg

Re: Protect SD against going read-only

Fri Aug 11, 2017 9:04 pm

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

User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

Re: Protect SD against going read-only

Sat Aug 12, 2017 1:06 pm

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.

User avatar
Ronaldlees
Posts: 294
Joined: Sat Apr 16, 2016 4:28 pm
Location: North Carolina, US
Contact: Website

Re: Protect SD against going read-only

Sat Aug 12, 2017 3:55 pm

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.
I am the Umbrella man

User avatar
rpdom
Posts: 14985
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Protect SD against going read-only

Sat Aug 12, 2017 4:03 pm

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

Windcheetah
Posts: 14
Joined: Mon May 11, 2015 5:48 pm

Re: Protect SD against going read-only

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
Pies are topps!!!!!

User avatar
Ronaldlees
Posts: 294
Joined: Sat Apr 16, 2016 4:28 pm
Location: North Carolina, US
Contact: Website

Re: Protect SD against going read-only

Mon Aug 14, 2017 1:28 pm

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).
I am the Umbrella man

Return to “General discussion”