Cannot get SD Card formatted as ext2 to work on MX Linux laptop

Summary

I formatted a 64Ggb micro SD Card with an ext2 filesystem. After
mounting and copying files to it, many files were corrupted; almost 400 out of 10,500 files.

I also tried ext3 and ext4. And I see, here, a number of people have successfully formatted SD Cards with ext file systems.

Details

  • I used fdisk to delete the partition and recreate it as a Linux partition
    fdisk /dev/mmcblk0
        d, 1
        n, p, 1, 2048, max
        w

    Command (m for help): p
    Disk /dev/mmcblk0: 59.46 GiB, 63847792640 bytes, 124702720 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: 0x1fdb5227

    Device           Boot Start       End   Sectors  Size Id Type
    /dev/mmcblk0p1         2048 124702719 124700672 59.5G 83 Linux
  • Create the filesystem
    mkfs -t ext2 -m 1 -b 2048  /dev/mmcblk0p1
    tune2fs -L microsd /dev/mmcblk0p1
  • I mounted with this /etc/fstab entry:
    LABEL=microsd /mnt/data1 ext2 auto,async,rw,exec,noatime,nosuid,nodev 0 2
  • I copied about 10,500 files to /mnt/data1/

I did a diff between the source and the copied files. Almost
400 files were different

Hardware and OS

  • Dell Inspiron 11-3180 laptop

https://www.dell.com/support/home/en-us/product-support/product/inspiron-11-3180-laptop/docs

  • SD Card: SanDisk Extreme, 64GB, MicroSD, V30, XC1, [3] A2

    plugged it into the microSD slot

  • OS: MX-21.2.1_KDE_x64 Wildflower April 9, 2022

  • Kernel: 5.10.0-20-amd64 #1 SMP Debian 5.10.158-2 (2022-12-13) x86_64 GNU/Linux

Update 1

  • Tried using f2fs filesystem
mkfs -t f2fs -f /dev/mmcblk0p1

        F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)

Info: Disable heap-based policy
Info: Debug level = 0
Info: Trim is enabled
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 124733440 (60905 MB)
Info: zone aligned segment0 blkaddr: 512
Info: format version with
  "Linux version 5.10.0-20-amd64 
  (debian-kernel@lists.debian.org) 
  (gcc-10 (Debian 10.2.1-6) 10.2.1 20210110, GNU ld 
  (GNU Binutils for Debian) 2.35.2) #1 SMP Debian 5.10.158-2 (2022-12-13)"
Info: [/dev/mmcblk0p1] Discarding device
Info: This device doesn't support BLKSECDISCARD
Info: Discarded 60905 MB
Info: Overprovision ratio = 0.810%
Info: Overprovision segments = 497 (GC reserved = 254)
  • mounted with this /etc/fstab entry:
    /dev/mmcblk0p1 /mnt/mxtrance.data1 f2fs auto,async,rw,exec,noatime,nosuid,nodev 0 0
  • After copying 10,500 files, 35 files were shown to be “different”

I then recopied just those 35 files and diff reported no differences.
But 5 minutes later it showed 20 files had problems: “Input/output
error”

  • I’m giving up on this SD Card

It could be this particular SD Card just does not work with being
re-formatted. I’m going to buy another SD Card “type” and then try again.

Update 2

  • Tried a different new MicroSD card.
    SD Card: SanDisk Ultra, 64gb, MicroSD, [1], XC 1, (10) A1
             140MB/s transfer speed
  • I used fdisk to delete the partition and recreate it as a Linux partition
Before:
    /dev/mmcblk0p1      32768 124735487 124702720 59.5G  7 HPFS/NTFS/exFAT


    fdisk /dev/mmcblk0
        d
        n, p, 1, 2048, 124735487
        w

After:
    /dev/mmcblk0p1       2048 124735487 124733440 59.5G 83 Linux

Reboot
  • Create the f2fs filesystem

Along with man pages, this was useful:
https://docs.kernel.org/filesystems/f2fs.html

    mkfs -t f2fs -l microsd -f /dev/mmcblk0p1

    F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
    Info: Disable heap-based policy
    Info: Debug level = 0
    Info: Label = microsd
    Info: Trim is enabled
    Info: Segments per section = 1
    Info: Sections per zone = 1
    Info: sector size = 512
    Info: total sectors = 124733440 (60905 MB)
    Info: zone aligned segment0 blkaddr: 512
    Info: format version with
      "Linux version 5.10.0-20-amd64 (debian-kernel@lists.debian.org)
      (gcc-10 (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils
      for Debian) 2.35.2) #1 SMP Debian 5.10.158-2 (2022-12-13)"
    Info: [/dev/mmcblk0p1] Discarding device
    Info: This device doesn't support BLKSECDISCARD
    Info: Discarded 60905 MB
    Info: Overprovision ratio = 0.810%
    Info: Overprovision segments = 497 (GC reserved = 254)
    Info: format successful
  • Mount with /etc/fstab
    LABEL=microsd   /mnt/mxtrance.data1 f2fs auto,async,rw,exec,gc_merge,discard,data_flush,noatime,nosuid,nodev 0 0
  • Copied 10,519 files to /mnt/mxtrance.data1, then did a diff between the source and destination. There were no differences.

  • About an hour later, after deleting 2 files, the diff showed 50 files
    were different, i.e. damaged. I should have only seen 2
    differences. It looks like only binary files are getting damaged (but only some).

  • Result: still unusable.