Can't write to SDHC

Using a 32Gb SDHC


desk:/home/ion/DATA/PINE/ARCH # dd if=/dev/zero of=/dev/sdc bs=5M status=progress
dd: error writing '/dev/sdc': No space left on device
1+0 records in
0+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0045466 s, 923 MB/s
desk:/home/ion/DATA/PINE/ARCH # 

desk:/home/ion/DATA/PINE/ARCH # gdisk
GPT fdisk (gdisk) version 1.0.8

Type device filename, or press <Enter> to exit: /dev/sdc
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): d
Using 1

Command (? for help): p
Disk /dev/sdc: 8192 sectors, 4.0 MiB
Model: Flash Reader    
Sector size (logical): 512 bytes
Disk identifier (GUID): FCA0FEFE-5310-4E99-9EA3-3AE133344E0A
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 8158
Partitions will be aligned on 2048-sector boundaries
Total free space is 8125 sectors (4.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-8158, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-8158, default = 8158) or {+-}size{KMGTP}: 
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/sdc: 8192 sectors, 4.0 MiB
Model: Flash Reader    
Sector size (logical): 512 bytes
Disk identifier (GUID): FCA0FEFE-5310-4E99-9EA3-3AE133344E0A
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 8158
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            8158   3.0 MiB     8300  Linux filesystem

Command (? for help): q
desk:/home/ion/DATA/PINE/ARCH # 

Which agrees with your dd invocation.

That is in my opinion your own invention.
All tools say 4 MiB.
As you told dd to use a block size of 5M, not even one block fits on the output device. Thus nothing is written and you still see the GPT that was apparently there all the time.

Thus, when you want to have x'00' bytes written over all of the device (you did not explain what your goal is, thus this is a guess), try again without the bs=5M.
And also try to explain to yourself why you think the size of the device is 32 GB.

Sorry to disagree. It IS a 32gb SDHC as are two others that I have tried. All displayed the same results. Unfortunately SDHC’s cannot be formatted under openSUSE. There is a utility called SDCardFormatterv1.0.3_Linux_x86_64 that reports they are 32GB and formats them but it can only run under several other operating systems. Inconvenient but it is a solution.

If you know that, why are you even trying to write into the partition table area?

It’s new information after several hours of research. Obviously I would not have wasted your time if I had known. I don’t appreciate your criticism.

I believe you need to install exfat but I could be mistaken. I know I have formatted 32+GB cards. Others say to use gparted which is likely what I used. It’s been awhile so I can’t remember…

Thank you very much. You have provided me with a simple solution so I don’t have to boot another OS. All I have to do is use gparted to delete any existing partitions and create a single fat32 partition. After that dd works normally.

2 Likes

You’re welcome.

Why is neither exFat nor UFS appealing?

@ionmich I have no issues with these devices, have 16, 32 and 64GB versions for various RPI3’s and my RISCV64 device. I always use wipefs -a /some/device to clear out the cruft and then use gdisk to re-partition.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.