gkreidl
Posts: 6281
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Why running from USB better than from sd card?

Tue Dec 24, 2013 2:16 pm

obcd wrote: ...
The next step is a complete read only root fs. Not all application like this, so some files need to be copied to tempfs as well during bootup. You can even further protect the sd card against writes with a software command making it really read only.
Obvious, this approach can't be used on every system. If you are experimenting a lot, you might need the log files and persistent changes to other files....
This is nonsense. No browser cache, no file download, no kind of database, no development, no compiling, no updates and upgrades, no ... the list will be endless. Most programs won't work at all. You will end up with a secure system that can do almost nothing.

So either live with it and do backups often or check for really good SD cards (there seem to be great differences) or move the root fs to an USB HD, which may be even cheaper than buying a new SD card every few months.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Why running from USB better than from sd card?

Tue Dec 24, 2013 3:01 pm

It's not nonsense.

I use some Pi's to connect usb devices to a virtual windows computer on a linux kvm system. It works fine with a read only rootfs. There are plenty of other things where a read only rootfs can work. For those using the system, it's just an interface. I can't expect them to ssh in and reboot properly when the device needs a reset. I can ask them to pull the plug and put it back in after some seconds, but that's pretty much it.

User avatar
jojopi
Posts: 3193
Joined: Tue Oct 11, 2011 8:38 pm

Re: Why running from USB better than from sd card?

Tue Dec 24, 2013 3:36 pm

gkreidl wrote:This is nonsense. No browser cache, no file download, no kind of database, no development, no compiling, no updates and upgrades, no ... the list will be endless. Most programs won't work at all. You will end up with a secure system that can do almost nothing.
It is not a beginner's task to set up, but you can have a fully working system with a read-only root. Embedded distros generally run like this, and desktop distros have moderate support, which they use for their LiveDVD and LiveUSB configurations. Admittedly, the relative lack of RAM on a Pi is a additional complicating factor.

All programs will run perfectly happily in a tmpfs, and you can use USB or network filesystems or overlays or backups for persistent storage.

gsh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1531
Joined: Sat Sep 10, 2011 11:43 am

Re: Why running from USB better than from sd card?

Tue Dec 24, 2013 4:44 pm

obcd wrote:
Plus any shuffling it does is controlled atomically
If that's the case, than why is Swissbit selling special sd cards for embedded systems with the guarantee that either the old data or the new data will be read back from the card after an interrupted write. They just are unpayable expensive.
Um... Let me think, why is someone advertising special SD cards and making them very expensive... ;)

Basically the SD card specification says that whilst it is writing you cannot pull the power - the write will terminate and the card will be in an indeterminate state. So don't pull the power whilst it is writing... That isn't what I was referring to, I was referring to the possibility that while the card is idle it could be doing a bit of clean up stuff (although having spoken to a number of manufacturers they say nobody actually does this)

Up to now I've been able to reproduce three different causes of corruption and fix them, none of those occurred as a result of powering off the card. I can believe that if you are going to be continuously writing to the SD card and you pull the power I would expect some corruption of the file it was writing but nothing more. Some time later the ext 4 system should be able to recover without losing stuff or corrupting the filesystem.

If you believe with the default settings on the latest Raspbian build you are still seeing corruption I'd be very interested because it may be corruption bug number 4 (or number 3 may raise its head again!)

Gordon
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering

danjperron
Posts: 3488
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Why running from USB better than from sd card?

Tue Dec 24, 2013 5:24 pm

This is nonsense. No browser cache, no file download, no kind of database, no development, no compiling, no updates and upgrades, no ... the list will be endless. Most programs won't work at all. You will end up with a secure system that can do almost nothing.
Which program will not work? I'm thinking and I can't find one. I use that technic a lot and didn't find anything not working.
Don't forget we are talking about putting the SD card in read only mode. Not the full system! some temporary folder will have to be in read/write mode using other device or ram disk.

Also why I will put a development system in read/only mode. This is on final product stuff not on a unit you use to design.

B.T.W. The little script just reroute the /var/log to a ramdisk. The SD card is still in r/w mode.

On my previous setup I was transferring temperature log and image capture from mjpg_streamer and the system was crashing every day. I had to re-do the card often because fsck was not working all the times. so I decide to limit the writing on the card by rerouting the /var/log to a ramdisk. And I also transfer the temperature log and the image capture into a temp folder which was also a ramdisk. A script was then use to transfer the data into a network drive ,my cloud from western digital.
I'm using lighttpd with dynamic web page using Highcharts. So the webpage location are in a ramdisk folder. I do have the webpage skeleton into the sdcard and they are use has backbone only.

Since I did that , I never had to re-do the SD card image.

So if this a good idea? yes . If it is needed ? No for the vast majority of the times.

Well I do have some industrial system using read only root fs. It doesn't mean that everything is static. You could mount r/w stuff on it . usb memory stick , external drive and for me it is network mount.
Daniel
Last edited by danjperron on Tue Dec 24, 2013 5:32 pm, edited 1 time in total.

User avatar
jojopi
Posts: 3193
Joined: Tue Oct 11, 2011 8:38 pm

Re: Why running from USB better than from sd card?

Tue Dec 24, 2013 5:32 pm

gsh wrote:I can believe that if you are going to be continuously writing to the SD card and you pull the power I would expect some corruption of the file it was writing but nothing more. Some time later the ext 4 system should be able to recover without losing stuff or corrupting the filesystem.
But you just said that when you pull the power during a write, the card is in an indeterminate state. Are you confident that that applies only to the user-visible LBAs, and not also to the internal shuffling layers? Since both are stored in NAND flash, it is a challenge to make either atomic.

I have not had any corruption issues, but deliberately powering off during writes is the one thing I have avoided testing. It would not even surprise me if that left a card permanently confused.

1pi2much
Posts: 99
Joined: Sun Feb 24, 2013 6:58 pm

Re: Why running from USB better than from sd card?

Tue Dec 24, 2013 9:10 pm

I must be one of the few lucky ones who has never had a SD corruption (9 months).

Details:
* Class 4 card
* swap turned off (can be a problem sometimes)
* noatime in fstab
* logs in ramdisk (with logrotate adjusted)
* no overclocking
* services like samba mysql cupsd turned off when not needed.

One of the things I did was run "iotop -oa" to see what writes to the sdcard when the pi is idle
and turn them off. You can get a good picture of how many writes are happening to the sd card
when you doing *nothing* on the pi.

I am running a small personal webserver on the pi mainly plus playing around with printserver, security cam, wolfram, and xbmc once in a while. I try not to yank the power when the pi is running.
My longest continous uptime was around 6 months which ended when I did a update && upgrade which messed up my wifi so that it hung every 2 days and had to be rebooted. Not sure what fixed it, a subsequent dist-upgrade perhaps. So I am not very keen on doing upgrades anymore not to mention the rpi-update.

--

Return to “Troubleshooting”