Skip to content

Instantly share code, notes, and snippets.

@Chester-Gillon
Last active December 24, 2025 22:28
Show Gist options
  • Select an option

  • Save Chester-Gillon/62ac71abfbc7c2cb54e0a034a64a18df to your computer and use it in GitHub Desktop.

Select an option

Save Chester-Gillon/62ac71abfbc7c2cb54e0a034a64a18df to your computer and use it in GitHub Desktop.
SD card write protection

The following sequence is repeatible:

  1. Copy AlmaLinux-10.0-x86_64_v2-Live-GNOME.iso to a Micro SD card as per AlmaLinux 10 initial look. That is using a USB to Micro SD adapter which doesn't provide write protection, even when Micro SD -> Micro SD to SD adapter with the switch set to the lock position -> USB to SD adpater.
  2. Boot into Alma Linux 8 with the with the Micro SD present and writable. Verify the Micro SD contents against the source ISO file.
  3. Reboot and use the BIOS boot menu to boot from the Micro SD card and the media check passes.
  4. With a different PC booted into Windows 11 insert the Micro SD card in the USB adapter. Get some notifications from Windows about drive letters for the SD card content, but don't directly attempt to access the SD card contents.
  5. Reboot the PC and use the BIOS boot menu to boot from the Micro SD card and the media check fails at 4.8%.
  6. Comparing the Micro SD contents against the source ISO file shows a difference, the 1st at byte 529.

Downloaded https://repo.almalinux.org/almalinux/10/live/x86_64/AlmaLinux-10.1-x86_64-Live-GNOME.iso from https://almalinux.org/get-almalinux/

The downloaded ISO matches the checksum:

$ sha256sum -c CHECKSUM 
AlmaLinux-10.1-x86_64-Live-GNOME.iso: OK
sha256sum: AlmaLinux-10.1-x86_64-Live-KDE.iso: No such file or directory
AlmaLinux-10.1-x86_64-Live-KDE.iso: FAILED open or read
sha256sum: AlmaLinux-10-latest-x86_64-Live-GNOME.iso: No such file or directory
AlmaLinux-10-latest-x86_64-Live-GNOME.iso: FAILED open or read
sha256sum: AlmaLinux-10-latest-x86_64-Live-KDE.iso: No such file or directory
AlmaLinux-10-latest-x86_64-Live-KDE.iso: FAILED open or read
sha256sum: WARNING: 3 listed files could not be read

On a laptop running Ubuntu 24.04.3 LTS with a built in SD card reader copied the ISO to the Micro SD card:

$ sudo dd if=~/Downloads/AlmaLinux-10.1-x86_64-Live-GNOME.iso of=/dev/mmcblk0 status=progress
[sudo] password for mr_halfword: 
1803706880 bytes (1.8 GB, 1.7 GiB) copied, 420 s, 4.3 MB/s 
3524980+0 records in
3524980+0 records out
1804789760 bytes (1.8 GB, 1.7 GiB) copied, 420.195 s, 4.3 MB/s

Verified the contents of the Micro SD against the source ISO:

$ time sudo cmp -n `stat -c '%s' ~/Downloads/AlmaLinux-10.1-x86_64-Live-GNOME.iso` ~/Downloads/AlmaLinux-10.1-x86_64-Live-GNOME.iso  /dev/mmcblk0

real	0m31.862s
user	0m0.004s
sys	0m0.015s

Using sdtool the Micro SD card write protection status is off:

$ sudo ~/sdtool/sdtool /dev/mmcblk0 status
[+] Found RCA for /dev/mmcblk0: 0001.
[+] Card CSD: 400E002B5B590001D21F7F800A400023.
[+] Write protection state: Off.

Turned on the tempoary write protection status which was read back:

 sudo ~/sdtool/sdtool /dev/mmcblk0 lock
[+] Found RCA for /dev/mmcblk0: 0001.
[+] Writing CSD.
[+] Write protection state: Temporary.
$ sudo ~/sdtool/sdtool /dev/mmcblk0 status
[+] Found RCA for /dev/mmcblk0: 0001.
[+] Card CSD: 400E002B5B590001D21F7F800A401011.
[+] Write protection state: Temporary.

After unplugging and re-plugging rhe Micro SD card the temporary write protection remained:

$ sudo ~/sdtool/sdtool /dev/mmcblk0 status
[+] Found RCA for /dev/mmcblk0: 0001.
[+] Card CSD: 400E002B5B590001D21F7F800A401011.
[+] Write protection state: Temporary.

Move the Micro SD card into the USB adapter. Was able to mount a writable file system and apparently change the contents:

$ touch /media/mr_halfword/ANACONDA/EFI/BOOT/test.txt
$ ls /media/mr_halfword/ANACONDA/EFI/BOOT/
BOOTX64.EFI  fonts  grub.cfg  grubx64.efi  mmx64.efi  test.txt

On removing and re-inserting the Micro SD card in the USB adapter the file was no longer present:

$ ls /media/mr_halfword/ANACONDA/EFI/BOOT/
BOOTX64.EFI  fonts  grub.cfg  grubx64.efi  mmx64.efi

And the Micro SD contents still matched the source ISO file.

Inserted the Micro SD in the USB adapter into Windows 11. Then rebooted and used the BIOS boot menu to boot from the AlmaLinux 10.1 live image. The media check now passed, following the SD card being set to write protected.

Was able to turn off the write protection, and then able to write a new ISO image to the Micro SD card:

$ sudo ~/sdtool/sdtool /dev/mmcblk0 unlock
[+] Found RCA for /dev/mmcblk0: 0001.
[+] Writing CSD.
[+] Write protection state: Off.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment