1

A have a brand new 16GB class 10 SD card and produce a very strange behavior. After I attached the the card with an USB SD-Card reader, the device appeared as /dev/sdb. I tried to copy a 2GB raw image with dd into, but it's immediately returns: "No more space left on device".

The block device shows: there is only 10M space on it.

ls -lah /dev/sdb
-rw-r--r-- 1 root root 10M máj   16 23:16 /dev/sdb

fdisk shows the same size:

fdisk -l /dev/sdb
Disk /dev/sdb: 10 MiB, 10485760 bytes, 20480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x84f9d19f

I've tried the SD-card with another reader, but looks like it's not a card reader issue, the "size" of the SD card is 10M with every single reader.

cat /proc/partitions
major minor  #blocks  name
...
   8       16   15558144 sdb
...

The interesting part is: the kernel looks like actually knows the right size of SD card.

cat /sys/block/sdb/size
31116288  # numbers of 512 byte blocks => 15.93 GB

And seems like it's properly recognized.

May 16 22:58:07 DDSI-Laptop kernel: [258762.883672] usb 1-3: New USB device found, idVendor=14cd, idProduct=125c
May 16 22:58:07 DDSI-Laptop kernel: [258762.883674] usb 1-3: New USB device strings: Mfr=1, Product=3, SerialNumber=2
May 16 22:58:07 DDSI-Laptop kernel: [258762.883675] usb 1-3: Product: Mass Storage Device
May 16 22:58:07 DDSI-Laptop kernel: [258762.883676] usb 1-3: Manufacturer: Generic
May 16 22:58:07 DDSI-Laptop kernel: [258762.883677] usb 1-3: SerialNumber: 125C20100726
May 16 22:58:07 DDSI-Laptop kernel: [258762.883972] usb-storage 1-3:1.0: USB Mass Storage device detected
May 16 22:58:07 DDSI-Laptop kernel: [258762.884114] scsi host52: usb-storage 1-3:1.0
May 16 22:58:07 DDSI-Laptop mtp-probe: checking bus 1, device 30: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3"
May 16 22:58:07 DDSI-Laptop mtp-probe: bus: 1, device: 30 was not an MTP device
May 16 22:58:08 DDSI-Laptop kernel: [258763.881813] scsi 52:0:0:0: Direct-Access     Mass     Storage Device        PQ: 0 ANSI: 0 CCS
May 16 22:58:08 DDSI-Laptop kernel: [258763.882008] sd 52:0:0:0: Attached scsi generic sg1 type 0
May 16 22:58:08 DDSI-Laptop kernel: [258763.883073] sd 52:0:0:0: [sdb] 31116288 512-byte logical blocks: (15.9 GB/14.8 GiB)
May 16 22:58:08 DDSI-Laptop kernel: [258763.883195] sd 52:0:0:0: [sdb] Write Protect is off
May 16 22:58:08 DDSI-Laptop kernel: [258763.883198] sd 52:0:0:0: [sdb] Mode Sense: 03 00 00 00
May 16 22:58:08 DDSI-Laptop kernel: [258763.883312] sd 52:0:0:0: [sdb] No Caching mode page found
May 16 22:58:08 DDSI-Laptop kernel: [258763.883315] sd 52:0:0:0: [sdb] Assuming drive cache: write through

What cause the difference?

2
  • 1
    Did you try to re-create partition table on it? Commented May 16, 2016 at 22:48
  • Yes i tried, but the size remains same. As the solution points, the problem is that the file is regular and not a block device. Commented May 16, 2016 at 23:23

1 Answer 1

3
-… /dev/sdb

This is a regular file, not a device. You must have tried to write to /dev/sdb at some point when there was no device connected with this drive letter. Be careful! You were lucky not to overwrite a different device from the one you intended.

Information about block devices in /proc and /sys is provided directly by the kernel uses the kernel's name for the device. Device nodes in /dev are managed by udev; they normally follow the kernel's device names (and add other names as symbolic links) but writing to /dev manually can disrupt udev. Since the directory entry /dev/sdb already existed, it didn't create the device node when you plugged in the SD card.

Remove /dev/sdb, eject the SD card, plug it back in, and check what device name it gets. You should see a block device:

$ ls -l /dev/sdb
brw-rw-rw- 1 root disk 8, 16 … /dev/sdb    
1
  • Now i feel myself silly. Really, the file was a regular, what im doesn't noticed. Thanks for the right observation and solution. Commented May 16, 2016 at 23:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .