You are not logged in.

#1 2016-05-16 18:21:38

nonZero
Member
Registered: 2015-05-17
Posts: 57

Writing to SD card: "No space left on device" on the exact place

Hi!

I have a Lenovo IdeaPad Z580 - an uncommon laptop, with an internal SD card reader:

lsusb gives:

Bus 003 Device 017: ID 0bda:0139 Realtek Semiconductor Corp. RTS5139 Card Reader Controller

I am using

dd bs=1M if=./image.img of=/dev/mmcblk0

to copy an 8GB image to a 16GB card.

I need to do it for many cards.

This works great and fast, until it fails once:

6083837952 bytes (6.1 GB, 5.7 GiB) copied, 21.0578 s, 289 MB/s
dd: error writing '/dev/mmcblk0': No space left on device
5936+0 records in
5935+0 records out
6223482880 bytes (6.2 GB, 5.8 GiB) copied, 21.6288 s, 288 MB/s

Now, this is of course not true.
No other meaningful message appears anywhere in the logs.
Retrying will keep the exact same message, even with other cards!

Keeping stuff short,  restarting (!) the machine and trying again will eventually work for some more cards until it will get stuck again, on a different byte offset.

My guess is the driver or some other system writes too quickly and hits a problem writing, and reports back a bad error message, and also gets stuck in a strange mode - maybe with a corrupt buffer or something similar.

Any guess? Any help?

Thanks!

Udi

Offline

#2 2016-05-16 18:23:47

frostschutz
Member
Registered: 2013-11-15
Posts: 1,409

Re: Writing to SD card: "No space left on device" on the exact place

blockdev --getsize64 /dev/mmcblk0 should show the size in bytes as the OS believes it.

Some card readers do not register card changes, so if you had a smaller card inside before and it still shows the old size, that might be your problem. If your card reader has a click-in mechanism (push to eject) make sure to use it.

You might be able to enforce card re-detection using unbind/bind http://unix.stackexchange.com/a/208443/30851 (or alternatively when using modules - unloading and reloading the module in question)

With cheap USB card readers that suffer this problem, you can just (un)plug the cable

Last edited by frostschutz (2016-05-16 18:26:00)

Offline

#3 2016-05-16 18:56:05

nonZero
Member
Registered: 2015-05-17
Posts: 57

Re: Writing to SD card: "No space left on device" on the exact place

frostschutz wrote:

blockdev --getsize64 /dev/mmcblk0 should show the size in bytes as the OS believes it.

Before the problem occurs, I get a correct answer, afterwards I get only:

blockdev: ioctl error on BLKGETSIZE64: Inappropriate ioctl for device

Now I can also see in dmesg many of:

[  +0.000027] mmc0: error -22 whilst initialising SD card
[  +2.694426] mmc0: tuning execution failed

And have hard time restarting.

How can I kick "mmc0" back to life without restarting?

Udi

Offline

#4 2016-05-16 19:07:37

nonZero
Member
Registered: 2015-05-17
Posts: 57

Re: Writing to SD card: "No space left on device" on the exact place

hmmm... this might be relavant: https://github.com/asymingt/rts5139 !

Offline

#5 2016-05-18 19:57:49

nonZero
Member
Registered: 2015-05-17
Posts: 57

Re: Writing to SD card: "No space left on device" on the exact place

I am repeating the probem:
Basically the SD drive works OK.
Sometimes, whenever a bad card is inserted, the drive will cease to function.
The error messages are usually:

mmc0: error -22 whilst initialising SD card
mmc0: tuning execution failed

A restart solves this.
How can I reset the SD drive without a restart?
Thanks!

Offline

#6 2016-05-18 20:03:36

frostschutz
Member
Registered: 2013-11-15
Posts: 1,409

Re: Writing to SD card: "No space left on device" on the exact place

Whether such a patch might help you, only you (or someone with the same hardware) can tell us...

How can I kick "mmc0" back to life without restarting?

I suggested a method above, reload module or bind/unbind devices from the driver.

No other ideas right now, sorry...

Offline

Board footer

Powered by FluxBB