s7mx1
Posts: 78
Joined: Fri Sep 30, 2011 9:28 am

Re: Wearout Prevention of SD card memory

Wed Jan 02, 2013 11:54 am

Use USB or NFS as the rootfs for your pi if your are worried about sd card wearout. I don't recommend to mount read only rootfs then use tempfs to save all the changes since pi does not have a lot memory.

Bergschreck
Posts: 11
Joined: Tue Jan 01, 2013 7:41 am

Re: Wearout Prevention of SD card memory

Wed Jan 02, 2013 6:17 pm

Today I tried to setup my system with a /home partition of type udf. That did not work. Accessing the udf partititon was extremely slow and throws lots of error messages like this:

Code: Select all

[   20.013398] UDF-fs: INFO Mounting volume 'home', timestamp 2013/01/02 14:05 (1000)
[   27.650417] mmc0: missed completion of cmd 18 DMA (512/512 [1]/[1]) - ignoring it
[   27.650473] mmc0: DMA IRQ 6 ignored - results were reset
[  105.216183] mmc0: final write to SD card still running
[  115.223636] mmc0: Timeout waiting for hardware interrupt - cmd12.
[  115.224807] mmcblk0: error -110 sending stop command, original cmd response 0x900, card status 0x900

User avatar
hojnikb
Posts: 128
Joined: Mon Jun 04, 2012 3:59 pm
Location: @Home

Re: Wearout Prevention of SD card memory

Wed Jan 02, 2013 8:09 pm

just use ext2 or ext4 without journal and you'll be good.
Using untested fs or fs not intended for flash use (udf) will cause more problems...

IF heavy write is in place, then just use hdd -- problem solved..
+°´°+,¸¸,+°´°~ Everyone should have a taste of UK Raspberry Pie =D ~°´°+,¸¸,+°´°+
Rasberry Pi, SoC @ 1225Mhz :o, 256MB Ram @ 550Mhz, 16GB SD-Card, Raspbian

hormiguero
Posts: 9
Joined: Mon Sep 17, 2012 1:31 pm

Re: Wearout Prevention of SD card memory

Fri May 03, 2013 4:59 pm

Why not use RAMLOG to keep log files in memory? I have several Pi's, all using RAMLOG to minimize writing to the SD card. RAMLOG is available from http://www.tremende.com/ramlog/‎ If the SD led is tobe believed, there is no writing going on.

wartstew
Posts: 14
Joined: Mon Jun 04, 2012 11:05 pm

Re: Wearout Prevention of SD card memory

Tue Oct 22, 2013 11:40 pm

As I've posted elsewhere, I've had 5 SD cards fail in RPI's so far. For me the data loss isn't a problem, but having the RPI stop doing what it is suppose to do every couple of months has been a problem.

I've already been tweaking things like turning off swap files, the whole rsyslog mechanism, etc. Previously I might have been writing to /var/log many times an hour and who knows what to the swap file. Also, until recently I've probably been using fairly "cheap" SD cards.

User avatar
hojnikb
Posts: 128
Joined: Mon Jun 04, 2012 3:59 pm
Location: @Home

Re: Wearout Prevention of SD card memory

Wed Oct 23, 2013 10:44 am

just move your rootfs to usb stick -- problem solved
+°´°+,¸¸,+°´°~ Everyone should have a taste of UK Raspberry Pie =D ~°´°+,¸¸,+°´°+
Rasberry Pi, SoC @ 1225Mhz :o, 256MB Ram @ 550Mhz, 16GB SD-Card, Raspbian

User avatar
DCFusor
Posts: 10
Joined: Sat Feb 01, 2014 8:20 pm

Re: Wearout Prevention of SD card memory

Sat Feb 01, 2014 8:37 pm

According to some white hat hackers, yes, even reading MLC flash can cause errors that require a rewrite.
http://www.bunniestudios.com/blog/?p=3554 -- watch the video presentation, it's worth your time.

I've simply added a big SSD to my pi, and a very robust power supply - 90% of my issues have been that the crap microusb connector has a big voltage drop - so I just hardwired mine and a lot of troubles went away. The pi doesn't care so much, but things plugged into USB that really want 5.0v do care - a lot, particularly samsung SSD drives. Which BTW, themselves draw about 1/10 the ma that the dumb sata->USB chip in the external case draws(!).

I used dd to make an image file of the SD card (while I had it plugged into my laptop). I then created a partition of 8gb on my SSD (in an external USB box) and dd's the image back to it, afterwards using gparted to expand the partition to the entire drive - dd is kind of a chainsaw, this is the best way to do it...

Then only the /boot (which is fat 32, why?) on the SD card needs to be mounted. Evidently the firmware only knows how to find that. Then a few minor changes to fstab and you're good to go with a big drive and plenty of wear leveling.

Here's my cheatsheet for doing that:
Howto image an sd card

dd if=/dev/sdx of=/path/to/image bs=1M
Where /dev/sdx is your SD card. Often it's /dev/mmcblk0
The resulting file will be 8 gb, and it will take at least 5 min to copy the card,
about double that to copy back to one.
(you use /path/to/image as the if=, your SSD (often sda1) as the of in the dd command to copy to the SSD, or simply swap if= and of= paths to backup an SD card - nice to have a backup if you're doing as much changing as I am to the pi stuff)

Then you use gparted to expand the SSD partition. You just have to do it that way or else things get hosed up around partition tables etc by dd.

Then you make fstab look like this on the pi:
proc /proc proc defaults 0 0
/dev/mmcblk0p6 /boot vfat defaults 0 2
/dev/sda1 / ext4 defaults,noatime 0 1
/dev/mmcblk0p5 /home/pi/public/SD ext4 defaults,noatime

# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that

And bingo - you now have a fairly decent server that draws next to no power. For me that was crucial - I live off the power grid, on solar, and wanted to be able to log data to a MySQL database on the pi 24/7, using a small switcher as power straight off the house batteries for high MTBF. I also plan to use it for those super-long up and downloads. Living in the boonies, I don't have a super fast internet connection but I do like putting things on my youtube channel and maintaining my website. This can just do it overnight...my full connection speed, doesn't, shall we way, stress a pi too much.
Why guess when you can know? Measure!

User avatar
Raspruss
Posts: 93
Joined: Thu Jan 23, 2014 3:50 pm
Location: Virginia, USA

Re: Wearout Prevention of SD card memory

Sun Feb 02, 2014 1:32 am

Assuming the ability to do so, simply backing up your SD card(s) regularly will allow trivial recovery from a failure. I fully intend to save an image of my main 32GB SD card every week and certainly after I've done anything major with respect to Pi software configuration.

If the SD card fails, yank it and add it to your junk drawer, image a new SD card, done.

User avatar
DCFusor
Posts: 10
Joined: Sat Feb 01, 2014 8:20 pm

Re: Wearout Prevention of SD card memory

Sun Feb 02, 2014 3:20 am

Yes, the facility I described above lets you image an SD card for backup. If you're using a 32gb card, it's gonna be slow - dd is a fairly dumb utility, and is a bit-copy, partition tables, boot records, all the bits...(do man dd at a prompt). It's roughly as cool as backing up a virtual machine (from say, Virtual Box) by just doing a file copy. Only here, you really do wind up copying the entire SD card - dd isn't smart enough to know which bits are real or in-use, doesn't understand file systems (or care). It just raw copies everything till it runs out of source to copy from (or, possibly hits an error of some kind). A chainsaw...brutal, but effective in the right hands. It is slow (because the cards usually are) and has no progress indicator - just be patient, don't use a trailing & on the command, so the return of the prompt indicates you're done. My class 4 HD card took on the order of 5-6 minutes to read, and 2-3 times that long to write to another the same size (writes are slower in flash than reads are).
Why guess when you can know? Measure!

User avatar
Raspruss
Posts: 93
Joined: Thu Jan 23, 2014 3:50 pm
Location: Virginia, USA

Re: Wearout Prevention of SD card memory

Sun Feb 02, 2014 1:12 pm

DCFusor wrote:Yes, the facility I described above lets you image an SD card for backup. If you're using a 32gb card, it's gonna be slow - dd is a fairly dumb utility
Though it certainly could be done right on the Pi, I image my SD card with Win32DiskImager on a Windows machine. That typically SHOULD be a one-way operation - image the SD card on the Windows box, then forget it only to remember it if something catastrophic happens. THEN use Win32DiskImager to copy the image to a new SD card.

But this "method of SD card protection" is certainly a whole lot easier than trying to reconfigure disk handling on the Pi to something nonstandard just to make an SD card last a little longer. Instead, save an image of the SD card and don't worry about it failing a little earlier than it would if the procedures described in the preceding posts of this thread are used.

anita2r
Posts: 226
Joined: Sun Dec 23, 2012 6:55 pm
Location: Ottawa, Canada

Re: Wearout Prevention of SD card memory

Sun Feb 02, 2014 3:46 pm

Hi,

I use dd to copy my SD card once a week, to a hard drive on another machine.

I have an 'AB' file - it just holds the letter 'A' or the letter 'B'
When the copy starts, the script reads the 'AB' file and dd saves the image as the A version
When copy is complete, the letter in the AB file is swapped to 'B', so the next week the B version is saved and the letter is changed back to 'A' again.

This way, if I have a corrupt SD card I don't find that I just copied the corrupt card image :oops: - there's always two versions available.

Regards

anita2R

AntonAV
Posts: 79
Joined: Thu Jan 12, 2017 2:00 pm
Location: Rural South India

Re: Wearout Prevention of SD card memory

Thu Feb 09, 2017 4:36 am

Any reason why setting aside some RAM (1 MB?) for log and temp file writing is not included in new Raspbian releases? Dietpi does it https://docs.google.com/spreadsheets/d/ ... edit#gid=0 ; supposed to extend the SD card's life...

User avatar
RaTTuS
Posts: 10458
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Wearout Prevention of SD card memory

Thu Feb 09, 2017 7:29 am

AntonAV wrote:Any reason why setting aside some RAM (1 MB?) for log and temp file writing is not included in new Raspbian releases? Dietpi does it https://docs.google.com/spreadsheets/d/ ... edit#gid=0 ; supposed to extend the SD card's life...
this thread is 3years old - necrophilia is bad M'kay

RAM disks are used in raspbain .. the log files are not on ram disks are you may want to look at them after a crash ....
they are easy to move
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

AntonAV
Posts: 79
Joined: Thu Jan 12, 2017 2:00 pm
Location: Rural South India

Re: Wearout Prevention of SD card memory

Fri Feb 10, 2017 5:27 am

RaTTuS wrote: this thread is 3years old - necrophilia is bad M'kay
RAM disks are used in raspbain .. the log files are not on ram disks are you may want to look at them after a crash .... they are easy to move
So Dietpi is wrong in their comparison?
Logs are for advanced users only; beginners want systems that crash less often, specially by causing those through writing logs to SD. Default, logs should be to RAM for 90% of users - if the aim of this Foundation really is schools and not nerds. ;)

paulv
Posts: 558
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: Wearout Prevention of SD card memory

Fri Feb 10, 2017 4:16 pm

I have been using busybox-syslogd for a couple of months now, and I'm happy with it. The syslogd setup replaces the logging to the filesystem, and stores the log into a RAM based ringbuffer. It is especially made for embedded systems, diskless systems, or, -tada- flash disk based systems.

Google it for more info.

Install with:

Code: Select all

sudo apt-get install busybox-syslogd
sudo dpkg --purge rsyslog
To look at the system log, use :

Code: Select all

logread
If you want to save the logs to disk to look at them after a failure, reboot or poweroff, use a script.
Enjoy!

Return to “Advanced users”