How can I speed up SD card writing speed (using /dev/disk*) on a MacBook Pro?

Solution 1:

Just ran into the same problem and it seems to be that /dev/disk* is slow because it is buffered. If you use the corresponding rdisk device (ex: /dev/rdisk1s1) you should get the speed you expect. This is apparently a BSD thing.

Example:

% sudo dd if=pi.bin of=/dev/disk1 bs=1m count=4095
^C408+0 records in
407+0 records out
426770432 bytes transferred in 1393.452305 secs (306268 bytes/sec)

% sudo dd if=pi.bin of=/dev/rdisk1 bs=1m count=4095
4095+0 records in
4095+0 records out
4293918720 bytes transferred in 378.669512 secs (11339489 bytes/sec)

Ref:

  • Note on Dev Entry Access

  • Post on Apple mailing list

Solution 2:

It could well be that the SD-card is that slow.

Take a look at this benchmark (Random Write, 4 KB (QD=1) [MB/s]) and you will see that most SD-cards have a lousy write performance (below 100 kB/s) for small files - and a typical linux installation consists of a lot of small files been written to disk.

The internal card-reader should be capable of reading/writing at least 20 MB/s - it's very unlikely that another card-reader will improve your experience with this very SD-card.

Once all the files are written, i.e. the system is installed, you may actually be able to run Linux from the SD-card in an acceptable speed - as it's mostly read access.

Solution 3:

If the card is mounted with the sync option, this means every file close causes the write to be flushed to disk and thus your performance on small files will be terrible when compared with large files. If you remove the sync from the mount options, then there is no guarantee that writing a file causes it to go out to disk -- you have to manually call sync from the command line, or unmount the device before removing it or powering down. However, without sync you should see small files write performance improve drastically.