0

I have a 8Gig SD card that I've been trying to format but for some reason nothing seems to be able to do it. I've tried checking for overlapping start and end bits but clearly there is no overlap in them.

Things I've tried:
1. fdisk to delete the partition and also to create a new partition but, the data still exists and no errors were shown.
2. Tried the same as above using GParted but gparted gives a Overlapping Partition error when there is only partition also there's a "Invalid Argument for seek while write" error generated by GParted.
3. Used dd to fill the device with 0 but still wasn't able to format the card.
4. Used shred as an alternative and no luck either.

I'd like to know what the problem really is or what other solution(s) can I try.

UPDATE
I tried sgdisk -Z on the Device and this is what I get as an error:

Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.
GPT data structures destroyed! You may now partition the disk using fdisk     or
other utilities.

Tried Resizing the start and end bits using GParted and Fdisk but they don't change anything and the start and end remain the same .

Disk /dev/sdb: 7.5 GiB, 8026849280 bytes, 15677440 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: 0x00000000

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1        8192 15677439 15669248  7.5G  b W95 FAT32

As visible, no other partitions exist.

  • About #1, if you delete a partition and then create a new, identical one in its place, the old file system will be in the expected location within the partition and thus be found by the OS. Deleting a partition does not actually delete any data (it only overwrites a few fields like offset and size in the partition table, whether MBR or GPT). – a CVn Dec 11 '16 at 12:47
  • 2
    Also, when you say "wasn't able", "no luck" and so on, please be more specific. What exact commands did you use; how did you determine that those parameters were the ones to use; and what was the exact output? – a CVn Dec 11 '16 at 12:48
  • @MichaelKjörling I found the commands online ` dd if=/dev/zero of=/dev/<sdcard partition> ` and sudo shred -v /dev/<sdcard partition> the information was found online and used after searching about the commands. – DevX136 Dec 11 '16 at 14:26
1

You can destroy the offending partition table by doing dd if=/dev/zero of=/dev/sdX bs=512 count=2 and then create a new one using fdisk or gparted. Make sure to get the X right.

  • I've tried that but that didn't work either, i guess i posted the dd part in the points above, it still doesn't allow me to format the sd card. – DevX136 Dec 11 '16 at 16:57
  • it didn't work bro, thanks for trying, the partition remains intact and still doesn't allow me to format it clean – DevX136 Dec 11 '16 at 17:01
0

SD card can have a physical write lock switch. Is this one locked ? sorry if this sounds silly.

Try the following command to completely Zap all partition info. As root (or using sudo or whatever other solution you have on your system). Warning : all data on the SD card will be lost, and if you don't enter the correct device, you may destroy all the data on your system

    sgdisk -Z /dev/XXXX

where /dev/XXXX is the device corresponding to your SD card, something such as /dev/sde or the like. Reboot the computer and try to format the SD card with your usual tool.

If things are still bad, either you don't use the correct device file, or your lunix system can't write to the SD card, maybe is it damaged. Take a look at the system messages, using dmesg | tail -100 .

UPDATE, (in answer to your update)

Your SD card has a GPT partition table as the sgdisk warning (and not error by the way) proves :

    Warning! Secondary partition table overlaps the last partition by
    33 blocks!
    You will need to delete this partition or resize it in another 
    utility.

And the result is a success :

    GPT data structures destroyed! You may now partition the disk using fdisk
    or other utilities.

GPT table (managed with gdisk) are written twice on a device, one at the start, the other at the end in reverse order. So GPT table are «stronger» than MBR partitions (managed with old fdisk) and resist such commands as : dd if=/dev/zero of=/dev/sdx count=20 bs=512 because the backup copy is written at the end and not erased.

After zapping the parititons with sgdisk -Z, did you reboot the computer ? If you don't, it is possible that the linux kernel still uses its own, in memory, idea of the partiontions on the card. The best thing to do to make sure linux knows the card has been wiped, is to reboot.

It is in some situation possible to mix MBR and GPT partition table but, the 2 tables have to agree and only very very experienced users may mix usage of MBR and GPT partition.

It's not clear whether your version of fdisk recognises GPT or not. You may be trying to edit MBR partition with fdisk, while the linux kertnel uses the GPT (backup) partition table.

So, once again :

  1. Zap the partition table, sgdisk -Z
  2. don't use other partitioning tool yet. Instead reboot
  3. use your prefered partitionnig tool.

If problem continue, dmesg may help.

  • I'll try and let you know. – DevX136 Dec 11 '16 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.