Ubuntu – Unable to format SD card

formatpartitioning

I'm not being able to format my Micro SD Card using Ubuntu 16.04. Whatever I do the partitions and files stay on the SD card. And yes, I've check if the card is locked or not.

fdisk -l 

Disk /dev/mmcblk0: 29,5 GiB, 31657558016 bytes, 61831168 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: 0x68818b6a

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      137216 61831167 61693952 29,4G 83 Linux

:~$ sudo mkfs.vfat -F 32 /dev/mmcblk0

mkfs.fat 3.0.28 (2015-05-16)

but still the same

sudo fdisk -l
Disk /dev/mmcblk0: 29,5 GiB, 31657558016 bytes, 61831168 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: 0x68818b6a

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      137216 61831167 61693952 29,4G 83 Linux

I've also tried shredding but still the files are there like before

sudo shred -v -z -n 0 /dev/mmcblk0

dd also didn't work

sudo dd if=/dev/zero of=/dev/mmcblk0
dd: writing to '/dev/mmcblk0': No space left on device
61831169+0 records in
61831168+0 records out
31657558016 bytes (32 GB, 29 GiB) copied, 9427,3 s, 3,4 MB/s

This is followed by an error window "Unhandled error message: Error when getting information for file '/media/philipp/boot': No such file or directory". Still evertything is the same as before.

When I use gparted this error occures

Can't open /dev/mmcblk0p1: No such file or directory
Cannot initialize '::'
mlabel: Cannot initialize drive

Can't open /dev/mmcblk0p1: No such file or directory
Cannot initialize '::'

fsck.fat 3.0.28 (2015-05-16)

open: No such file or directory

Unable to read the contents of this file system!
Because of this some operations may be unavailable.
The cause might be a missing software package.
The following list of software packages is required for fat32 file system 

support:  dosfstools, mtools.

and

e2label: No such file or directory while trying to open /dev/mmcblk0p2
Couldn't find valid filesystem superblock.

tune2fs 1.42.13 (17-May-2015)

tune2fs: No such file or directory while trying to open /dev/mmcblk0p2
Couldn't find valid filesystem superblock.

Couldn't find valid filesystem superblock.

dumpe2fs 1.42.13 (17-May-2015)
dumpe2fs: No such file or directory while trying to open /dev/mmcblk0p2

Unable to read the contents of this file system!
Because of this some operations may be unavailable.
The cause might be a missing software package.

Is there anything else to try or is my card just broken?

Best Answer

Trying to wipe the SD card

What is the output from this command, that you already tried?

sudo dd if=/dev/zero of=/dev/mmcblk0

Please edit your question to post the output. Indent four spaces to render the text as code. What happens if you unplug the card and plug it in again. Often you have to unplug + plug in again for a modfied partition table of memory cards to be recognized.

You can do the same thing but in a safer way with mkusb, wipe the card. It can also restore the card to a standard storage device. mkusb helps you identify the target device (in this case the card), 'wraps a safety belt around dd'. See these links

help.ubuntu.com/community/mkusb

mkusb/persistent

Analysis of the result

Your output from sudo dd if=/dev/zero of=/dev/mmcblk0

dd: writing to '/dev/mmcblk0': No space left on device
61831169+0 records in
61831168+0 records out
31657558016 bytes (32 GB, 29 GiB) copied, 9427,3 s, 3,4 MB/s

indicated that dd wrote to the drive, the SD card. I agreed with the comment by Elder Geek, that you should reboot the computer and check if the card is wiped: No partition table should be seen.

  • If successful, it would be possible to create a new partition table and file system.

  • Else (if there were still partitions), I think the card would be 'grid-locked' (read-only because it is failing), and in the next step it would be completely dead. See this link,

    Pendrive lifetime

  • The card reader too might be bad, so it is a good idea to test the card with another card reader in the same or in another computer.

Conclusion

After reboot and further tests the partitions and files are still there. The conclusion is that the SD card is failing, 'grid-locked', which means in a read-only stage of the failing process.