What happens when your Steam Deck MicroSD card gets stuck in read only?
A re-occurring issue I keep getting with the Steam Deck's MicroSD card.
The Steam Deck, a popular mobile gaming handheld device, lends itself to it's open-source origins and high-powered hardware for a very low price of $399 USD for a 64GB SSD edition. It has the capacity to utilize an SD card to expand it's storage (without needing to remove and replace the solid state drive yourself), so you can install a number of different MicroSD card sizes to expand your potential library.
However, I have an issue where the SD card goes into a read-only mode, and I don't know why.
For the tl;dr: use
fsck if you are mounting the SD card on a Linux desktop environment.
sudo fsck /dev/sdxx # use fdisk -l to find your MicroSD card path identifier (/dev/sdb1 for example)
I normally download some games and other such things like movies or anime onto an SD card because not everything I do or play is necessarily tied to Steam, and in most cases I end up putting things on the SD card since it has a very high storage capacity compared to my small SSD. However, it seems most times when I try putting new files onto the SD card after a while, I find the SD card to be in a read-only state, and I have no real means of working around that.
Normally if a drive you mounted doesn't have read/write privileges, you can re-mount it with the mount tool.
sudo mount --options remount,rw /dev/sdxx
But this fails because my device was not in the
/etc/fstab list, which is indeed weird. I visually checked it myself, and the UUID for the MicroSD card is indeed not there at all. I can mount it fine with a file manager like
pcmanfm fine, but it's UUID doesn't register in
/etc/fstab, meaning the
autologind service may be responsible for mounting drives (I am using EndeavourOS for reference).
When you insert an SD card into the Steam Deck, the Deck will provide software to format the card to a file system format it can understand, meaning it most likely will pick an open-source, non-licensed filesystem partition like
ext4 journaling. This has the privilege of being great, while also having the drawback of you can only really use Linux to interact with this card (Windows does not support
ext4 to my knowledge, so you can't manage these files with a Windows computer).
Filesystems typically are self-contained environments with some protocols that must be followed properly for long-term care of the physical device. This may include keeping itself aware of any mistakes on the journaling system. As such, each time you do a block write, the filesystem must have some metadata stored to verify there are no mistakes in it at all. So for each and every file you write, a filesystem database is modified, blocks are verified and calculated to be correct, and then metadata is stored on the drive.
However, if you interrupt the write process before it can finalize changes, the metadata may be incorrect, and a user may have to jump in to force a re-calculation. This is where
fsck comes into play, otherwise known as File System Consistency Check. It'll scan bytes on a device and determine if the journaling information is correct and up-to-date. And in many cases when things go awry, it'll report and show you errors.
In the instance of my Steam Deck's SD card being mounted as a read-only system, I ran
fsck on it. It has to be ran on the exact partition number, so be sure to use
fdisk -l to determine your
/dev mount path and partition number. For this blob my path is
$ sudo fsck /dev/sdxx
fsck from util-linux 2.38.1
e2fsck 1.47.0 (5-Feb-2023)
/dev/sdx1: recovering journal
/dev/sdx1 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong for group #34 (3, counted=0).
Free blocks count wrong (14355398, counted=14355395).
Block bitmap differences: Group 34 block bitmap does not match checksum.
/dev/sdx1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sdx1: 7509/7806976 files (1.9% non-contiguous), 16861245/31216640 blocks
This issue isn't unique to the Steam Deck SD card itself, and can happen when you are say writing data to an SD card, but the power goes out and the write is incomplete. When you get power back, the drive will have a flag that says it's incomplete, and you might have to
fsck the drive back in order (whereby it probably does a rollback to remove incomplete files).
For best success, if you are going to eject the Steam Deck's SD card to put new files on it, be sure to eject it from Desktop mode, or perhaps just fully turn the Steam Deck off entirely so the SD card journal is correct and won't pop any errors when mounting it to your computer.