Can't access my phone memory suddenly after using SD card as internal memory A few weeks ago I integrated my SD card to use as phone memory. Everything was fine until a couple of days ago.

All of a sudden I saw the "insert SD card" notice appear on the notification bar. I open the back cover but the SD card looked like it was in place. I remove it and insert it back and the notice disappears. But then I notice that when I go to file explorer (FX) to access my files, it says "Access was denied". I can't access anything that is on my phone memory, although the apps are working. I guess system files are OK, but everything else is not.

My phone is rooted so I tried to access the files through TWRP but I can only see system folders.

Phone is a Moto C plus. Nougat.
You can recover some files from corrupted MicroSD Card. adoptable-storage is encrypted, it requires the encryption key from the source device. In your case you are lucky your device is rooted

insert MicroSD Card into PC Card Reader. figure out which one is the correct block device (/dev/sdc) with sudo blkid

mount your hard drive (/media/xubuntu/404CCE454CCE3606). check free disk space with df -h

clone 1:1 disk image of the entire MicroSD Card with gddrescue
sudo -i
apt install gddrescue
cd /media/xubuntu/404CCE454CCE3606
ddrescue -n -b512 -r3 /dev/sdc sd.img gddrescue_sd_img.log


install android platform-tools
apt install android-tools-adb android-tools-fastboot


connect your device in recovery mode (TWRP)

get the encryption key file expand_5f5e697154132edfaa6fca7ac23cde2a.key (root access required)
adb devices
adb pull /data/misc/vold


read the 16-bytes hex encryption key (ae126af293501cd130db0637372e8911)
ls vold
hexdump -v vold/expand_5f5e697154132edfaa6fca7ac23cde2a.key


map the image file to create loop devices
kpartx -av /media/xubuntu/404CCE454CCE3606/sd.img


get partition size (62299103) and decrypt the 2nd partition (/dev/mapper/loop1p2)
blockdev --getsize /dev/mapper/loop1p2
dmsetup create crypt1 --table &quot;0 62299103 crypt aes-cbc-essiv:sha256 ae126af293501cd130db0637372e8911 0 /dev/mapper/loop1p2 0&quot;


when successfull a new (decrypted) block device /dev/mapper/crypt1 (ext4) will created

mount the partition (skip this step Xubuntu will auto mount)
mkdir /media/xubuntu/fa6c4c4c-846e-4c6f-8c02-e93cf5ebf448
mount -t ext4 -o ro,noexec,noload /dev/mapper/crypt1 /media/xubuntu/fa6c4c4c-846e-4c6f-8c02-e93cf5ebf448


Open new terminal (CTRL + ALT + T) and start File Manager (root session) from command line:
sudo thunar /media/xubuntu/fa6c4c4c-846e-4c6f-8c02-e93cf5ebf448


in File Manager enable - View - Show Hidden Files
you should see some directories
app
local
lost+found
media
misc
user
user_de


you can now browse media directory for Internal Storage and copy your Pictures to your hard drive


Be aware you can't copy app directory to windows hard drive, because linux permissions and file names aren't compatible with NTFS file system type

however, you can create tarball archive to preserve the whole partition content including all metadata
 sudo -i
 cd /media/xubuntu/fa6c4c4c-846e-4c6f-8c02-e93cf5ebf448
 tar --selinux --xattrs -H posix --numeric-owner -vcp * | gzip -cn &gt; /media/xubuntu/404CCE454CCE3606/sdcard.tar.gz


sdcard.tar.gz can be unpacked with 7-zip in windows, or restored from twrp command line with GNU tar