Hello,
I tried to format my micro SD card but it's not working. I tried with the app "Disk" and also "Gparted" but nothing.
I also tried with windows who told me the card is broken and need to be repare but windows can't do it.
When i open it with Gparted, there is a lock next to the device.

Is Anyone have a solution ?

Thank you

    Check if the card is mounted lsblk

    Force unmount and remove read-only mode

    sudo umount /dev/sdX
    sudo hdparm -r0 /dev/sdX

    Try formatting the card to FAT32 sudo mkfs.vfat -F32 /dev/sdX

    Check the card for errors sudo fsck /dev/sdX

    If errors are found, attempt to fix them
    sudo fsck -y /dev/sdX

    (WARNING: This will erase all data!) Completely wipe the card
    sudo dd if=/dev/zero of=/dev/sdX bs=4M status=progress

    Thanks.

    It didn't work tough

    dd: erreur d'écriture dans '/dev/sdb1': Aucun espace disponible sur le périphérique
    7683+0 enregistrements lus
    7682+0 enregistrements écrits
    32223789056 octets (32 GB, 30 GiB) copiés, 1713,47 s, 18,8 MB/s

    So it say there is an error in the writing and no space available in the device.

    What about the other parameters I gave you? The dd command should not include the partition number, just the letter of your card, e.g: b

    Guyk5685 If you are also using Windows then this tool from Gibson research might let you reformat your card.

    $ sudo umount /dev/sda1
    umount: /dev/sda1: non monté.
    $ sudo hdparm -r0 /dev/sda1
    
    /dev/sda1:
     setting readonly to 0 (off)
     readonly      =  0 (off)
    $ sudo mkfs.vfat -F32 /dev/sda1
    mkfs.fat 4.2 (2021-01-31)
    $ sudo fsck /dev/sda1
    fsck de util-linux 2.40.4
    fsck.fat 4.2 (2021-01-31)
    There are differences between boot sector and its backup.
    This is mostly harmless. Differences: (offset:original/backup)
      65:01/00
    1) Copy original to backup
    2) Copy backup to original
    3) No action

    At this point, i tried different options but nothing really happen.

    $  sudo fsck -y /dev/sda1
    fsck de util-linux 2.40.4
    fsck.fat 4.2 (2021-01-31)
    There are differences between boot sector and its backup.
    This is mostly harmless. Differences: (offset:original/backup)
      65:01/00
      Not automatically fixing this.
    Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
     Automatically removing dirty bit.
    
    *** Filesystem was changed ***
    Writing changes.
    /dev/sda1: 6334 files, 922817/983136 clusters

    I tried also the dd command with the letter only but still the same result.

    I’d like you to try using the command again, but without numbers, so for example:
    sudo fsck -y /dev/sda

      pomon

      $ sudo fsck -y /dev/sda
      fsck de util-linux 2.40.4
      e2fsck 1.47.2 (1-Jan-2025)
      ext2fs_open2: Numéro magique invalide dans le super-bloc
      fsck.ext2 : Superbloc invalide, tentons d'utiliser les blocs de sauvetage...
      fsck.ext2: Numéro magique invalide dans le super-bloc lors de la tentative d'ouverture de /dev/sda
      
      Le superbloc n'a pu être lu ou ne contient pas un système de fichiers
      ext2/ext3/ext4 correct. Si le périphérique est valide et qu'il contient réellement
      un système de fichiers ext2/ext3/ext4 (et non pas de type swap, ufs ou autre),
      alors le superbloc est corrompu, et vous pourriez tenter d'exécuter
      e2fsck avec un autre superbloc :
          e2fsck -b 8193 <périphérique>
       ou
          e2fsck -b 32768 <périphérique>
      
      /dev/sda contient une donnée « DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x0,130,3), end-CHS (0x3ff,254,63), startsector 8192, 62937088 sectors, extended partition table (last) »

      I got this.

      Axios Thanks, I will try with the gibson's tool and this one too when I will see friends with windows !

        Guyk5685 If you have enough disk space you can create a virtual install of windows for the odd thing that seems harder in Linux using something like Oracle VirtualBox. The learning curve can be a little steep at the beginning but it is always handy to not need to rely on someone else's pc.