I am running Ubuntu 18.04.1 in a Virtual Machine (VMWare) on a Windows host. I am trying to zero out an entire SD card using dd. This is part of the process I use to release embedded Linux to the software group (SD card images compress much better when the empty FS data is all 0).
The command I am using is: sudo dd if=/dev/zero of=/dev/sdc bs=4M status=progress
and it completes successfully; I get the printout of records transferred, and a message saying no space left on device. If I then do a sudo cat /dev/sdc | hexdump
to look at the disk contents though, the disk is still full of data and isn't zeroes (and not just at the end).
Do I have to specify the number of bytes of the SD card for it to work consistently? I don't have this issue every time I zero out an SD card.
Complete console output:
gen-ccm-root@ubuntu:~$ sudo dd if=/dev/zero of=/dev/sdc bs=4M status=progress
15929966592 bytes (16 GB, 15 GiB) copied, 1274 s, 12.5 MB/s
dd: error writing '/dev/sdc': No space left on device
3799+0 records in
3798+0 records out
15931539456 bytes (16 GB, 15 GiB) copied, 1274.19 s, 12.5 MB/s
gen-ccm-root@ubuntu:~$ sudo cat /dev/sdc | hexdump
[sudo] password for gen-ccm-root:
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0101000 2004 0000 6004 0000 0000 0000 0000 0000
0101010 0000 0000 0000 0000 0000 0000 0000 0000
*
0101400 2005 0000 6005 0000 0000 0000 0000 0000
...
Best Answer
As said in the comments, the sdcard was with badblocks.
The solution I proposed was to run:
CAUTION: this is data destructive like
dd if=/dev/zero
.And the user received something like:
Showing the sdcard was damaged.
The sdcard was replaced and the problem was solved.