Unable to access SD Card

I changed the filesystem format of my SD card to NTFS so applications on my system to write to it. I couldn't access it anymore, so I changed it back to FAT, but I still can't access it as root, or regular user. As root, it doesn't list. As for accessing with user, I get an error pop-up, which reads "Unable to access 32 GB Volume, not authorized to perform operation."

The df command gives me the following output:

Filesystem                     1K-blocks    Used Available Use% Mounted on
/dev/mmcblk0p1                  10732080 8523064   1640800  84% /
devtmpfs                          995380       0    995380   0% /dev
shmfs                             997360   52396    944964   6% /dev/shm
tmp                               997360   19924    977436   2% /tmp
tmpfs                             199476      56    199420   1% /run
tmpfs                               5120       0      5120   0% /run/lock
run                               997360     448    996912   1% /var/host/dbus
/dev/mapper/encstateful          3164880  139276   3009220   5% /var/host/timezone
/dev/root                        1763840 1583608    180232  90% /lib/modules/3.18.0-13527-gc2f2230
media                             997360       4    997356   1% /var/host/media
/home/.shadow/dbb3045.../vault  10732080 8523064   1640800  84% /home/friskybits/Downloads
none                              997360       0    997360   0% /sys/fs/cgroup
none                              997360       4

The sudo lsblk -f command gives me the following output:

NAME                 FSTYPE   LABEL      MOUNTPOINT
loop0                                    
└─encstateful (dm-1) ext4                
loop1                squashfs            
loop2                squashfs            
loop3                squashfs            
loop4                squashfs            
loop5                squashfs            
loop6                squashfs            
zram0                                    [SWAP]
mmcblk0rpmb                              
mmcblk0boot0                             
mmcblk0boot1                             
mmcblk0                                  
├─mmcblk0p1          ext4                
├─mmcblk0p2                              
├─mmcblk0p3          ext4     ROOT-A     
│ └─vroot (dm-0)                         
├─mmcblk0p4                              
├─mmcblk0p5          ext4     ROOT-A     
├─mmcblk0p6                              
├─mmcblk0p7                              
├─mmcblk0p8          ext4     OEM        
├─mmcblk0p9                              
├─mmcblk0p10                             
├─mmcblk0p11                             
└─mmcblk0p12         vfat     EFI-SYSTEM 
mmcblk1                                  
└─mmcblk1p1          vfat

The sudo lsblk -m command gives me the following output:

NAME                   SIZE OWNER GROUP MODE
loop0                  3.1G root  disk  brw-rw----
└─encstateful (dm-1)   3.1G root  root  brw-------
loop1                397.5M root  disk  brw-rw----
loop2                 48.8M root  disk  brw-rw----
loop3                    4K root  disk  brw-rw----
loop4                    4K root  disk  brw-rw----
loop5                    4K root  disk  brw-rw----
loop6                    4K root  disk  brw-rw----
zram0                  2.8G root  disk  brw-rw----
mmcblk0rpmb              4M root  disk  brw-rw----
mmcblk0boot0             4M root  disk  brw-rw----
mmcblk0boot1             4M root  disk  brw-rw----
mmcblk0               14.7G root  disk  brw-rw----
├─mmcblk0p1           10.5G root  disk  brw-rw----
├─mmcblk0p2             16M root  disk  brw-rw----
├─mmcblk0p3              2G root  disk  brw-rw----
│ └─vroot (dm-0)       1.7G root  root  ---------
├─mmcblk0p4             16M root  disk  brw-rw----
├─mmcblk0p5              2G root  disk  brw-rw----
├─mmcblk0p6            512B root  disk  brw-rw----
├─mmcblk0p7            512B root  disk  brw-rw----
├─mmcblk0p8             16M root  disk  brw-rw----
├─mmcblk0p9            512B root  disk  brw-rw----
├─mmcblk0p10           512B root  disk  brw-rw----
├─mmcblk0p11             8M root  disk  brw-rw----
└─mmcblk0p12            16M root  disk  brw-rw----
mmcblk1               29.7G root  disk  brw-rw----
└─mmcblk1p1           29.7G root  disk  brw-rw----

And the sudo parted -ls command gives me the following output:

Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/encstateful: 3297MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system  Flags
 1      0.00B  3297MB  3297MB  ext4


Error: /dev/mmcblk0rpmb: unrecognised disk label
Warning: Error fsyncing/closing /dev/mmcblk0rpmb: Input/output error

Error: /dev/mmcblk0boot0: unrecognised disk label

Error: /dev/mmcblk0boot1: unrecognised disk label

Model: MMC 400073 (sd/mmc)
Disk /dev/mmcblk0: 15.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name        Flags
11      32.8kB  8421kB  8389kB               RWFW
 6      8421kB  8422kB  512B                 KERN-C
 7      8422kB  8422kB  512B                 ROOT-C
 9      8422kB  8423kB  512B                 reserved
10      8423kB  8423kB  512B                 reserved
 2      10.5MB  27.3MB  16.8MB               KERN-A
 4      27.3MB  44.0MB  16.8MB               KERN-B
 8      44.0MB  60.8MB  16.8MB  ext4         OEM         msftdata
12      128MB   145MB   16.8MB  fat16        EFI-SYSTEM  boot
 5      145MB   2292MB  2147MB  ext2         ROOT-B
 3      2292MB  4440MB  2147MB  ext2         ROOT-A
 1      4440MB  15.7GB  11.3GB  ext4         STATE       msftdata


Warning: /dev/mmcblk1 contains GPT signatures, indicating that it has a GPT table.  However, it does not have a valid fake msdos partition table, as it should.  Perhaps it was corrupted -- possibly by a program that doesn't understand GPT partition tables.  Or perhaps you deleted the GPT table, and are now using an msdos partition table.  Is this a GPT partition table?
Error: The backup GPT table is corrupt, but the primary appears OK, so that will be used.
Model: SD SS32G (sd/mmc)
Disk /dev/mmcblk1: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name        Flags
11      32.8kB  8421kB  8389kB               RWFW
 6      8421kB  8422kB  512B                 KERN-C
 7      8422kB  8422kB  512B                 ROOT-C
 9      8422kB  8423kB  512B                 reserved
10      8423kB  8423kB  512B                 reserved
 2      10.5MB  27.3MB  16.8MB               KERN-A
 4      27.3MB  44.0MB  16.8MB               KERN-B
 8      44.0MB  60.8MB  16.8MB               OEM         msftdata
12      128MB   145MB   16.8MB               EFI-SYSTEM  boot
 5      145MB   147MB   2097kB               ROOT-B
 3      147MB   2244MB  2097MB               ROOT-A
 1      2244MB  2263MB  18.9MB               STATE       msftdata

How can I access the SD card?


Mount a FAT32 partition in an SD card with write permissions for everybody

(assumption: the SD card is seen as /dev/mmcblk1, replace mmcblk1p1 with the actual letters for the partition, for example sdb1 if a USB pendrive or an SD card connected via USB, /dev/mmcblk1p1 ---> /dev/sdb1)

sudo mkdir -p /mnt/sd1  # only if you want a new mountpoint
sudo umount /dev/mmcblk1p1   # only if already mounted (but with bad permissions)

sudo mount -o rw,users,umask=000 /dev/mmcblk1p1 /mnt/sd1  # mount

or (if connected via USB)

sudo mkdir -p /mnt/sd1  # only if you want a new mountpoint
sudo umount /dev/sdb1   # only if already mounted (but with bad permissions)

sudo mount -o rw,users,umask=000 /dev/sdb1 /mnt/sd1  # mount

Check permissions

ls -ld /mnt/sd1

Test

sudo bash -c "echo 'Hello World' > /mnt/sd1/hello.txt"  # test writing with sudo
cat /mnt/sd1/hello.txt                   # test reading (as user)
ls -l /mnt/sd1                           # check permissions of the content
rm /mnt/sd1/hello.txt                    # test removing (as user)
echo 'I am a user' > /mnt/sd1/user.txt   # test writing (as user)

Edit: Different umask alternatives are illustrated with the following command lines, in this case assuming device /dev/sdb1

$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=077 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwx------ 2 root root 4096 jan  1  1970 /mnt/sd1  # only root has permissions
$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=033 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwxr--r-- 2 root root 4096 jan  1  1970 /mnt/sd1  # users have read permissions
$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=022 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwxr-xr-x 2 root root 4096 jan  1  1970 /mnt/sd1  # users have read and execute permissions
$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=011 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwxrw-rw- 2 root root 4096 jan  1  1970 /mnt/sd1  # users have read and write permissions
$ sudo umount /mnt/sd1; sudo mount -o rw,users,umask=000 /dev/sdb1 /mnt/sd1;ls -ld /mnt/sd1
drwxrwxrwx 2 root root 4096 jan  1  1970 /mnt/sd1  # users have full permissions

If this does not work

If this does not work, you may find a solution or at least an explanation at the following link,

Can't format my usb drive. I have already tried with mkdosfs and gparted: Analysis of the problem