Fght
Posts: 319
Joined: Thu Feb 05, 2015 10:26 pm

class 10 or calss 4 card?

Wed Feb 11, 2015 12:41 am

i've bought a class 10 32gb card. will it work with raspberry pi? i'm asking because i've seen that in some guide from lifehacker they say you need a class 4 card.

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: class 10 or calss 4 card?

Wed Feb 11, 2015 12:58 am

It should work fine. I use class 10 cards because they are the only ones I can find in the stores. Class 4 or 6 have faster write speeds and cost less.
There are 10 types of people: those who understand binary and those who don't.

Sleep Mode zZ
Posts: 319
Joined: Sun Aug 19, 2012 5:56 am
Location: Finland

Re: class 10 or calss 4 card?

Wed Feb 11, 2015 2:26 am

kusti8 wrote:It should work fine. I use class 10 cards because they are the only ones I can find in the stores. Class 4 or 6 have faster write speeds and cost less.
No, the class designation is based on write speeds, so a lower class card won't give you faster writing speed. Higher class means higher writing speeds.

Reading speed is more important than writing speed in a sd card to be used in a Pi. The class designation does not say anything about it. The recommendation of lower class cards is based on the assumption that class 10 cards have achieved their writing speed in some way that compromises the reading speed of the card. That is not necessary true because there are cards with high performance in both reading and writing. Best advice would be to check the actual reading speed of the card and forget the class rating because it is not relevant for reading speeds. It also is worth keeping in mind that the Pi is limited in its reading speed to a bit over 20 MB/s. My "up to 90 MB/s" Samsung card will not perform any better than cards with one half or one third of the performance. (And, yes, the "up to" some speed, might not be a good indication of real performance.)

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

Re: class 10 or calss 4 card?

Wed Feb 11, 2015 8:07 am

Some class 4 and class 6 cards have been found to perform better in the Raspberry Pi than many (not all) class 10 cards.

This is not for the reasons given above. It is because the higher rated cards are optimised for writing continuous large chunks of data - such as in photos or videos, and not the many small random writes that is typical of a computer.

java
Posts: 226
Joined: Mon Jul 21, 2014 9:41 am

Re: class 10 or calss 4 card?

Wed Feb 11, 2015 6:12 pm

I to, use class 10 cards, simply because that is what is available locally. So fst I have no issue with them, and I have no idea, nor does it matter to me if I have lost a bit of performance or not - if I want to buy locally, which I prefer, I have to take what I can get. The Sandisk, and Samsung cards both function well here.

Fght
Posts: 319
Joined: Thu Feb 05, 2015 10:26 pm

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 11:31 am

so is this card will be the best or one of the best?

it says it is for cameras on the package (attached picture)
Attachments
2015-02-12-13.26.56.jpg
2015-02-12-13.26.56.jpg (42.04 KiB) Viewed 3794 times

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 11:33 am

Fght wrote:so is this card will be the best or one of the best?
not necessary
class 4/ 6 may be better for doing lots of random read's [as what linux does in general]
writing large amounts of sequential stuff then that should be better
YMMV
it will work though
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

BenPope
Posts: 9
Joined: Sun May 20, 2012 8:33 am

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 2:22 pm

http://www.raspberrypi.org/forums/viewt ... =63&t=4076

The point is you want a card that does well with 4k random writes. Some will do 1 or two a second, others, almost a 1000. It makes a big difference. The spec on the packaging (Class 4, 6, 10, UHS, whatever, or xxMB/s (sequential read/write) won't help you to determine that at all.

LaKraven
Posts: 7
Joined: Sat Jul 14, 2012 8:01 pm

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 2:55 pm

The SanDisk Ultra UHS-1 has both a read and write speed of 30MB/s, and I've found that no other card (no matter how much higher its read and/or write speeds may be) performs better on an RPi (using the MicroSD to SD adapter) or RPi2 (obviously without the adapter).

I think this is a limitation of the BUS speeds on the RPi hardware itself, so there's no reason to buy an "up to 98MB/s**********" card for the RPi/RPi2, you simply won't get any benefit from it.

As others have said, some cards are optimized for larger allocation sizes, which means they're better for photos and videos, but not as quick with small discrete chunks such as you'll be encounting most often on the RPi.

So, yes... the SanDisk Ultra UHS-1 gets my thumbs up (I'm using both the 64GB and 128GB versions in my units respectively, dependant on their roles). Just make sure you buy from a trustworthy retailer as there are far too many counterfeit cards on the market (which are tiny but pretend to be huge).

Sleep Mode zZ
Posts: 319
Joined: Sun Aug 19, 2012 5:56 am
Location: Finland

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 3:46 pm

RaTTuS wrote:
Fght wrote:so is this card will be the best or one of the best?
not necessary
class 4/ 6 may be better for doing lots of random read's [as what linux does in general]
writing large amounts of sequential stuff then that should be better
YMMV
it will work though
Can't Linux file systems cache these small writes? They are small and would as such not take much memory even if there were a bunch of them in a queue. If small random writes is the most severe bottleneck in sd card performance, caching the writes should perform miracles.

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 3:50 pm

YMMV - also you can change the disk buffer to be deadline instead of CFQ I used to do this when I ran Linux of sdcard on PC's years back ....
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

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

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 4:12 pm

Sleep Mode zZ wrote:Can't Linux file systems cache these small writes? They are small and would as such not take much memory even if there were a bunch of them in a queue. If small random writes is the most severe bottleneck in sd card performance, caching the writes should perform miracles.
Sure, but you can't cache them forever - they will still have to be written eventually, and you really don't want stale buffers hanging around too long or you risk even greater file-system corruption or loss of data in the case of a non-clean shutdown.

Sleep Mode zZ
Posts: 319
Joined: Sun Aug 19, 2012 5:56 am
Location: Finland

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 4:42 pm

RaTTuS wrote:YMMV - also you can change the disk buffer to be deadline instead of CFQ I used to do this when I ran Linux of sdcard on PC's years back ....
I don't think that deadline scheduler would improve performance here. If I understand it correctly, it handles the wite queue differently than CFQ and noop - the difference being in how they do give precedence to different buffered writes. Deadline gives the writes a deadline, CFQ tries to be fair to all processes. I'm not sure if a choice between them they will make any real difference.

The problem is that unlike file writes, file reads can't be buffered and kept waiting, because the process can't go on without getting the io it needs. And if the process can't go on, the user can't go on but must wait until the file read is done. If small file writes is a serious performance bottleneck, then it must be because those slow small writes are blocking reads. Unlike writes, reads can't be put off to wait for a better moment but has to be done as fast as possible for the computer to stay responsive. The ideal system would not write anything unless the read-queue is empty, giving always precedence to reads. The write queue should be big enough to hold many megabytes of writes. If the writes are given a deadline, it should be at least a minute or two not a couple of seconds. And, yes, this will make the system more prone to data loss but I think that in many use cases that would be preferable to a sluggish system.

User avatar
DougieLawson
Posts: 39224
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 6:57 pm

Fght wrote:so is this card will be the best or one of the best?

it says it is for cameras on the package (attached picture)
Think again. That full size card won't fit the A+, B+ or 2B raspberry pi. It's much better for future proofing your system to use microSD cards in adapters.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Sleep Mode zZ
Posts: 319
Joined: Sun Aug 19, 2012 5:56 am
Location: Finland

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 10:38 pm

Sleep Mode zZ wrote:
RaTTuS wrote:YMMV - also you can change the disk buffer to be deadline instead of CFQ I used to do this when I ran Linux of sdcard on PC's years back ....
I don't think that deadline scheduler would improve performance here. If I understand it correctly, it handles the wite queue differently than CFQ and noop - the difference being in how they do give precedence to different buffered writes. Deadline gives the writes a deadline, CFQ tries to be fair to all processes. I'm not sure if a choice between them they will make any real difference.

The problem is that unlike file writes, file reads can't be buffered and kept waiting, because the process can't go on without getting the io it needs. And if the process can't go on, the user can't go on but must wait until the file read is done. If small file writes is a serious performance bottleneck, then it must be because those slow small writes are blocking reads. Unlike writes, reads can't be put off to wait for a better moment but has to be done as fast as possible for the computer to stay responsive. The ideal system would not write anything unless the read-queue is empty, giving always precedence to reads. The write queue should be big enough to hold many megabytes of writes. If the writes are given a deadline, it should be at least a minute or two not a couple of seconds. And, yes, this will make the system more prone to data loss but I think that in many use cases that would be preferable to a sluggish system.
I read a little about CFQ and deadline I/O schedulers. RaTTuS seems to be right - deadline should be better than CFQ if you have a card with very slow random access writes.

What I found about CFQ is that it makes a distinction between synchronous and asynchronous I/O - and serves the synchronous first. The problem with this is that it depends on the programmers to take the extra step and make an asynchronous request when they haveto write something to the disk. For small writes, I would guess, many programmers would take the synchronous request to be appropriate even when the program is not doing anything time critical after that - maybe only waiting to quit.

Deadline scheduler, on the other hand, makes a distinction between reads and writes - and serves the reads first. That is what I hoped for in my previous post. In addition I hoped that the write queue could be made as long as necessary while keeping the read queue short. The deadline scheduler has settings for 'read_expire' and 'write_expire', defined in millisecond in which a request should be served. The default settings are 500 ms for the reads and 5000 ms for the writes. That 5000 ms could be enough or it could be increased to a minute or two. There is also a setting 'writes_starved' that determines how much the reads will be preferred over the writes. I don't know what is the default value, but making it higher will make the scheduler prefer reads even more. So the deadline scheduler is exactly what I hoped for.

So, if someone has a sd card with very slow random writes, he/she should try if changing the I/O scheduler to deadline helps to keep the system responsive. It is possible to change the I/O scheduler on the fly, without rebooting or logging out. That should make it easy to find out if slow random access writes is the real problem with Linux - or is it the slow read speeds, like I still suspect. Of course, if a program writes to the disk, without making the write request in a separate thread - and freezes its whole GUI while waiting for an answer from the OS - it could behave even worse with the deadline scheduler.

Fght
Posts: 319
Joined: Thu Feb 05, 2015 10:26 pm

Re: class 10 or calss 4 card?

Thu Feb 12, 2015 11:59 pm

so 4 or 6? or it's pretty similar?

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: class 10 or calss 4 card?

Fri Feb 13, 2015 7:42 am

Fght wrote:so 4 or 6? or it's pretty similar?
whatever you cab get your hands on really - either will do
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

Fght
Posts: 319
Joined: Thu Feb 05, 2015 10:26 pm

Re: class 10 or calss 4 card?

Fri Feb 13, 2015 1:01 pm

ok so i will replace the class 10

Fght
Posts: 319
Joined: Thu Feb 05, 2015 10:26 pm

Re: class 10 or calss 4 card?

Sun Feb 15, 2015 3:59 pm

i've been at the store but they told me my only option is sdhc card. it is ok right?
considering it 4/6 calss and at least 4 gigs

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

Re: class 10 or calss 4 card?

Sun Feb 15, 2015 4:38 pm

Yes, SDHC is the right sort of card.

Return to “General discussion”