How could I retrive full internal storage of an Android smartphone in order to restore data? In TWRP, I originally intended to only formating Data as F2FS but didn't know that from around Android 5, data is a subfolder under /sdcard and everything in /sdcard is gone. How could I retrive a full image of Android internal storage so that I could try to use some data recovery softwares recovering as much as possible?
Well, basically TWRP is a tiny embedded Linux so we could do Linux things in TWRP. First we need to unmount all the unneccessary ones in Mount menu, plug in a big enough flash drive formatted using exFAT (By default, Linux couldn't write NTFS, and FAT32 has file size limitation. You may also need extra power supply to get the HDD working), and mount it. Then go to Adaveced -&gt; Terminal and you get a busybox to play with, like other embedded Linux systems.
For phones using UFS, usually the block device for internal storage is /dev/block/sda, and you could confirm this by checking its size.
# --getsize64 would return size in bytes
~ # blockdev --getsize64 /dev/block/sda
123161542656

The returned number is the block device's size in bytes. That's around 123.16 gigabytes, consistent with the info available on LineageOS device specs (128 GB).
And for smartphones using EMMC, the block device for it should be /dev/block/mmcblk0, correct me if I am wrong.
Now we could dump all the content of that image into external storage device.
DO NOT WRITE BACK TO INTERNAL STORAGE. You would get your data overwritten and that's why I said unmounting all unneccessary volumes at the beginning.
dd if=/dev/block/sda bs=4096 of=/usb_otg/dump.img

Hint: You could utilize nohup to let dd running at background and continue other tasks in terminal, like:
# The &quot;&amp;&quot; symbol at the end is necessary
nohup dd if=/dev/block/sda bs=4096 of=/usb_otg/dump.img &gt; /usb_otg/dd.log 2&gt;&amp;1 &amp;

After dd finishes, unmount your external drive. Wish you a good luck recovering data.