Tuesday, December 5, 2017

SD Card mounts read-only in Linux

The title might be misleading since my setup is using Linux Mint 18.3 but I have seen all kinds of posting related to this problem across Linux forums.  I have tried all kinds of remedies suggested online and it seems to be a hit or miss and cant seem to narrow it down.  Windows does not have any of these symptoms and can heal even should you forget to eject properly.

I have tried all the obvious ones such as changing permission on the filesystem to 777 and removing it as root or sudo.  I had one success with this method then it went back every time I eject the SD card, use it in a speaker player then try to access it again on the computer.

Tried the fsck and did work one time but I am very careful prior to removing the card by ejecting it [umount]. 
fsck -a /dev/sdb

Gparted didn't work.  But if I've continued to try, I think one of these days it would have worked.  Rebooted so many times that I felt like I was using Windows Vista.

The dd command didn't seem to work at all
dd if=/dev/zero of=/dev/sdb bs=1M count=10

I have noticed one time where my SD card had residual trash on the card .Trash-1000; however, nothing can remove it to include root.  Then found out that you have to delete the user's Trash then umount and remount.  This worked once then failed again.
rm -rf ~/.local/share/Trash/* 

A different scenario happened to where I plug in then eject then insert again then eventually it worked.  From Nemo file manager is whether or not I had the delete option which indicated that the SD card is now in read-write mode.

I have tried umounting then remount with rw options:
sudo fdisk -l
sudo mount -t vfat -o rw /dev/sdb1 /mnt
or
sudo mount -o remount,rw /dev/sdb1 /media/username/usbname

Finally I really think that by adding myself and the root into the disk group worked.
sudo usermod -G disk --append username
sudo usermod -G disk --append root