Unable to format SD card

5,257

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.

Share:
5,257

Related videos on Youtube

Kaz Wolfe
Author by

Kaz Wolfe

Hello. You showed up in my review queue. You will be reviewed and re-tagged if necessary. Failure to comply may result in harm. Yes, I am a wolf. Awoo. IT director for a warehousing company, doing networking, systems, and support. My languages of choice are Java and Python. One of the six people who actually like MongoDB. Self-declared cybersecurity expert. If you need me, swing by the AskUbuntu General Room or contact me on Discord. If you want to talk to me over e-mail for some reason, shoot a message to the below listed address. Please don't spam me. Notable Achievements Wrote WolfBot. And abandoned it. And then went back to working on it. And then archived it to go work on Discord chatbots Played video games Managed to nuke an entire Linux install, live. And then fix it, live. Reddit. Operate DIY Tech, a partnered Discord server. Honestly not much. I'm pretty boring. Contact Information PGP Key: 2588 13F5 3A16 EBB4 (Keybase Enabled) Discord: KazWolfe#2896 E-mail: (username)@linux.com

Updated on September 18, 2022

Comments

  • Kaz Wolfe
    Kaz Wolfe almost 2 years

    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?

    • sudodus
      sudodus over 7 years
      What is the output from this command? 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.
    • Katu
      Katu over 7 years
      Have you tried sudo fdisk /dev/mmcblk0 and then using d to delete the partitions? Remeber w to write changes.
    • Admin
      Admin over 7 years
      I'm using Ubuntu 16.04 for formating the SD card. Also I've tried sudo fdisk /dev/mmcblk0 but it didn't change anything.
    • Elder Geek
      Elder Geek over 7 years
      Your dd output indicates that you have wiped the card. This fact may not be clear until you either reboot the system or re-read the partition table The card may be fine and the card reader itself faulty if after sudo dd if=/dev/zero of=/dev/mmcblk0 you still have a partition table on the card. The MBR and partition table are in the first 512 bytes and you wrote 31657558016 bytes to the card, so if the SDcard reader is successfully transmitting data to the card it should appear empty.
    • sudodus
      sudodus over 7 years
      @ihkf, It seems to me that dd worked - the output indicates that it wrote to the drive. I agree with Elder Geek: Please reboot the computer and check if the card is wiped (no partition table should be seen), and then it will be possible to create a new partition table and file system. If there are still partitions, I think the card is 'grid-locked' (read-only because it is failing), and the next step is that is is completely dead. See this link, ubuntuforums.org/… . The reader too might be bad too, so test the card with another card reader.
    • Admin
      Admin over 7 years
      Also after rebooting partitions and files persists so I guess the card is "grid-locked" as you say. But thanks anyway all of you for the suggestions and help!