6

I have faced a problem when all partition tools see my SD card as a card of 30 GB size. But when I bought the card I clearly remeber the card had 64 GB and moreover it is written on the card "ScanDisk Ultra 64 GB". The max capacity changed after I decided to reformat my SD card with ext4 filesystem (filesystem was exFAT before). Then whatever I have tried to do, nothing helped me to restore capacity back. What I tried was gparted, fdisk, and even tried to use Windows tools SDFormatterv4 and diskpart. But I use windows tools under VirtualBox because my primary OS is Ubuntu. I do not have preinstalled Windows OS on phisycal drive. I googled and found only solutions when Windows does see only first partiton on SD cards. But I think it is not my case because I do not use Windows at least. But anyway I tried those solutions what did not helped me. How to restore capacity to original size?

ADDED as ByteCommander asked

# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT    
sda      8:0    0 698.7G  0 disk    
├─sda1   8:1    0 171.2G  0 part /    
├─sda2   8:2    0   7.6G  0 part    
├─sda3   8:3    0   163G  0 part    
└─sda4   8:4    0 356.9G  0 part /home    
sdb      8:16   1  27.5G  0 disk     
sr0     11:0    1  1024M  0 rom

# parted -l

   ... /dev/sda skipped ...


Model: Generic USB SD Reader (scsi)
Disk /dev/sdb: 29.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags

I connect SD Card through SD reader. As you can see /dev/sdb has no partitions at all

ADDED as zhongfu asked

# dmesg | tail -n 20
[ 9203.022463] usb 2-5: New USB device found, idVendor=090c, idProduct=6200
[ 9203.022475] usb 2-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 9203.022482] usb 2-5: Product: Generic USB2.0 card 
[ 9203.022487] usb 2-5: Manufacturer: Silicon Motion, Inc.
[ 9203.022492] usb 2-5: SerialNumber: 12345678901234567890
[ 9203.022997] usb-storage 2-5:1.0: USB Mass Storage device detected
[ 9203.024017] scsi17 : usb-storage 2-5:1.0
[ 9204.024052] scsi 17:0:0:0: Direct-Access     Generic  USB  SD Reader   1.00 PQ: 0 ANSI: 0 CCS
[ 9204.024780] sd 17:0:0:0: Attached scsi generic sg2 type 0
[ 9204.027078] sd 17:0:0:0: [sdb] 57626624 512-byte logical blocks: (29.5 GB/27.4 GiB)
[ 9204.030200] sd 17:0:0:0: [sdb] Write Protect is off
[ 9204.030205] sd 17:0:0:0: [sdb] Mode Sense: 4b 00 00 08
[ 9204.031340] sd 17:0:0:0: [sdb] No Caching mode page found
[ 9204.031344] sd 17:0:0:0: [sdb] Assuming drive cache: write through
[ 9204.034209] sd 17:0:0:0: [sdb] No Caching mode page found
[ 9204.034212] sd 17:0:0:0: [sdb] Assuming drive cache: write through
[ 9204.049098]  sdb:
[ 9204.051865] sd 17:0:0:0: [sdb] No Caching mode page found
[ 9204.051876] sd 17:0:0:0: [sdb] Assuming drive cache: write through
[ 9204.051885] sd 17:0:0:0: [sdb] Attached SCSI removable disk

magic :-( 64 Gb disappeared. here is a photo of my SD card and its reader here is a photo of my SD card and its reader

ADDED as Rod Smith asked

# hdparm -N /dev/sdb
/dev/sdb:
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 max sectors   = 0/1, HPA is enabled

EDIT

What I tried to remember and found out with your help guys!

thanks to NGRhodes for refreshing my mind

  1. At first time I bought the card I did not check on PC if my SD card has 64 GB capacity. Only my camera shows me that I can recording video during 9 hours. If I insert 32 GB SD card then my camera shows I can record video during 4 hours. It means one of card bigger than another. Plus there is a title on cards 64 GB and 32 GB accordingly. So on those facts I made a conclusion that one card 32GB and another 64GB.

  2. But when I insert 64GB card into my PC I found out it only has 30 GB. And I started associating it to formating with ext4 filesystem mistakenly (because I formated before I check the size)! Why I think it was a mistake? Because I reformated the SD card back to exFat then checked the size on PC and it was still ~30GB. Then I inderted to my camera. My camera shows I can record video 9 hours long against 4 hours with 32GB card! It means capacity is not lost.

So the question who lies camera or PC? It seems HPA is the root cause and PC got some space of my SD card.

EDIT2

I tried to format the SD card on my android device. And finally PC shows me 64GB

# dmesg | tail -n 20
[15394.096958] usb-storage 2-5:1.0: USB Mass Storage device detected
[15394.097115] scsi22 : usb-storage 2-5:1.0
[15395.097725] scsi 22:0:0:0: Direct-Access     Generic  USB  SD Reader   1.00 PQ: 0 ANSI: 0 CCS
[15395.097962] sd 22:0:0:0: Attached scsi generic sg2 type 0
[15395.099192] sd 22:0:0:0: [sdb] 57626624 512-byte logical blocks: (29.5 GB/27.4 GiB)
[15395.099822] sd 22:0:0:0: [sdb] Write Protect is off
[15395.099824] sd 22:0:0:0: [sdb] Mode Sense: 4b 00 00 08
[15395.100449] sd 22:0:0:0: [sdb] No Caching mode page found
[15395.100452] sd 22:0:0:0: [sdb] Assuming drive cache: write through
[15395.108424] sd 22:0:0:0: [sdb] No Caching mode page found
[15395.108427] sd 22:0:0:0: [sdb] Assuming drive cache: write through
[15395.123181]  sdb: sdb1
[15395.123185] sdb: p1 size 124733440 extends beyond EOD, enabling native capacity
[15395.125048] sd 22:0:0:0: [sdb] No Caching mode page found
[15395.125056] sd 22:0:0:0: [sdb] Assuming drive cache: write through
[15395.125836]  sdb: sdb1
[15395.125847] sdb: p1 size 124733440 extends beyond EOD, truncated
[15395.129559] sd 22:0:0:0: [sdb] No Caching mode page found
[15395.129570] sd 22:0:0:0: [sdb] Assuming drive cache: write through
[15395.129578] sd 22:0:0:0: [sdb] Attached SCSI removable disk

# df -h | grep sdb
/dev/sdb1        60G   20K   60G   1% /media/alek/C8AE-0ADD

But still HPA is enabled

# hdparm -N /dev/sdb

/dev/sdb:
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 max sectors   = 0/1, HPA is enabled

EDIT3 Summary

  1. I bought card. Camera shows I can record with the new card longer (in two times) video than if I used old one with size 32GB.

  2. I formated the SD card on my PC with ext4 filesystem. I checked the capacity first time and it was about 30 GB.

  3. I formated the SD card back with exFat. I checked capacity on PC. It was still about 30GB. I inserted the SD card to my camera. Camera shows I can record video longer that using 32GB card as before.

  4. I reformated the SD card on an android device. Android device shows the card has 60 GB capacity. Then I inserted the card to PC. PC started showing correct capacity - 60GB.

ADDED as Rinzwind asked

It was added after I formated on the android device. So it shows about 64GB.

# sgdisk --print /dev/sdb

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. 
***************************************************************


Warning! Secondary partition table overlaps the last partition by
67108897 blocks!
You will need to delete this partition or resize it in another utility.
Disk /dev/sdb: 57626624 sectors, 27.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): B5FDFA69-32D4-42B0-B8A3-B14DF7A513B5
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 57626590
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048       124735487   59.5 GiB    0700  Microsoft basic data

EDIT4

  1. I created a file - 1GB size.

dd if=/dev/zero of=1gb_file bs=1024 count=1048576

  1. Copied it 60 times to the SD card

    for i in seq 1 60; do echo -n ($i) ; cp -v 1gb_file /media/alek/C8AE-0ADD/$i ; done

    (1)«1gb_file» -> «/media/alek/C8AE-0ADD/1» (2)«1gb_file» -> «/media/alek/C8AE-0ADD/2» (3)«1gb_file» -> «/media/alek/C8AE-0ADD/3»

    ...

    (57)«1gb_file» -> «/media/alek/C8AE-0ADD/57» (58)«1gb_file» -> «/media/alek/C8AE-0ADD/58» (59)«1gb_file» -> «/media/alek/C8AE-0ADD/59»

    (60)«1gb_file» -> «/media/alek/C8AE-0ADD/59»

    cp: error writing ‘/media/alek/C8AE-0ADD/60’: No space left on device

    cp: failed to extend ‘/media/alek/C8AE-0ADD/60’: No space left on device

Only latest command failed because disk was full. So I could write about 60 GB to my SD card.

  1. And I tried to copy them back. This test passed too. So I do not think the SD card is counterfeit.

EDIT5 as psusi asked. After I formated on the android device.

lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 698,7G  0 disk 
├─sda1   8:1    0 171,2G  0 part /
├─sda2   8:2    0   7,6G  0 part 
├─sda3   8:3    0   163G  0 part 
└─sda4   8:4    0 356,9G  0 part /home
sdb      8:16   1  27,5G  0 disk 
└─sdb1   8:17   1  27,5G  0 part /media/alek/C8AE-0ADD
sr0     11:0    1  1024M  0 rom  

EDIT6 as psusi asked

# dd if=/dev/sdb of=/dev/null
57626624+0 records in
57626624+0 records out
29504831488 bytes (30 GB) copied, 1518,73 s, 19,4 MB/s

Conclusion.

It is a problem of SD card reader.

enter image description here

0

2 Answers 2

4

I suppose I'll write up my conclusions as an answer now. The short answer is that your USB SD card reader is defective. It is reporting that the size of the card is smaller than it really is. When you format the card in your android device ( using its full capacity ), then mount it in your computer, you can't correctly access the full disk so you will quickly corrupt files.

Return or otherwise get rid of your current reader and get a new one that properly recognizes the full capacity of the card.

2
  • Ok. I will try other card reader and will make sure if my card is not a fake SD card. Apr 14, 2015 at 20:47
  • 1
    Yes, exactly. It is a problem of SD card reader. I have tried to use a new SD card reader and Linux detects correct size of my SD card. Thank you. Apr 16, 2015 at 10:44
1

I think your SD card reader is HC standard, so it can read up to 32 GB SD cards, for higher capacity SD cards you need XC standard readers.

You must log in to answer this question.

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