[Galaxy Grand Prime Q&A, Help & Troubleshooting] AndroidDevZ:
TLDR : I Cannot MODIFY ANYTHING IN SYSTEM or USERDATA(i.e. internal storage) partitions. Files Deleted via twrp in System/internal storage comeback after reboot and new files added from computer vanish after reboot. Also NOW, different flashes are successful through both methods via -

1. twrp recovery-(Boot/recovery/CustomROMs flashes) and

2. ODIN-(boot/recovery/Stock ROM flashes)

but again dont change anything after reboot (previously both methods worked, so no issue with twrp or odin according to me). So, Whole storage (System+Internal Storage) is intact after Reboot as it is. Now I feel it has something to do with magisk. I can see exact file names both in internal storage and /system and do delete, move, rename i.e. any operations in twrp so i guess storage is not encrypted. I can boot into system for hardly 10-15 seconds after that it bootloops again, so i cannot do anything there. Only options to me is twrp recovery or odin, both are not helping for now.

--------------------------------- DETAILED EXPLANATION : ------------------------------------

[PROBLEM 1] DELETION:

Anything deleted via TWRP recovery in system partition or "EVEN in sdcard, i.e. internal storage" deletes successfully in twrp, without any error but comes back in the same state after the reboot. When i delete error causing file or folder via TWRP file manager, it gets deleted, and if you check again it's not there wherever it was present, but just after reboot every file and folder comes back to previous state like if nothing was done. This is true for any file present in any of the partitions. Newly inserted file in internal storage vanishes after reboot, and deleted file comes back after reboot - true for any partition. Status quo maintained !!

[PROBLEM 2] FLASHING:

To solve above problem, i thought it might be an issue with Magisk or the new twrp recovery, so i tried flashing Magisk Uninstaller zip in twrp, which again flashes successfully, SECONDLY- tried zackptg-(dmverity,forceencrypt Disabler) zip file, that also flashes successfully(i thought might be an issue of dmverity or encryption), and THIRD thing i tried flashing older twrp version recovery, that also flashes successfully but after reboot same currently installed twrp boots, not the newly "successfully flashed" older version. So i cannot change twrp-(tried both recovery.img flash in (1) twrp itself and (2) also through ODIN) - both returns flash successful and pass(in Green). FOURTH, tried dirty flash both (1) other ROM and (2) SAME ROM on top of current ROM- everything returns successful but after reboot boots the current erroneous ROM that i want to change. FIFTH, tried Clean Flashing i.e. wiped everything (selected 1. dalvik cache, 2. data, 3. cache, 4. system, 5. Internal Storage in wipe section) and also tried Factory RESET and FORMAT DATA option and after all this flashed Custom ROM zip file only (no gapps or magisk flash), but every wipe operation returns successful and ROM flash also successful, but when reboot into system again that bootlooping erroneous ROM that was present before all of these "successfully done" operations.

[PROBLEM 3] ODIN FLASH:

As all above failed, i thought flashing STOCK ROM through ODIN is my last resort. I did (1) Stock recovery flash through Odin- it was green pass (successful), but when booted returned that same twrp recovery not stock recovery. Tried (2) flashing Stock BOOT.img flash through ODIN, again it was successful but actual boot resulted the same Magisk Patched Boot.img. Third (3) tried flashing whole STOCK FIRMWARE - Official latest Stock firmware that was extracted from Samsung Smart Switch, with default options turned on in Odin, flash was again green-pass(successful) but auto reboot after successful flash through ODIN resulted same old erroneous ROM booting up like a VAMPIRE (I'm not dead, I'm Alive!!)... Fourth (4) tried flashing Stock Firmwave of step 3 with NAND ERASE and RE-PARTITION options turned on by inserting pit file to do BANG BANG, nuking my phone with these options that many people on internet advise not to use, screenshot attached below( it took 42 minutes to complete ), again using these options nand erase and re-partition also resulted successful(green-pass) and resulting that same untouched state as it was before.. Boots into twrp recovery not the stock rom or stock recovery with that same old erroneous ROM present in system with data partition intact. (Tried using different ODIN versions, different USB ports on my laptop, different non-official firmwares(but these non-official firmwares of SM-G530H resulted in some errors in ODIN, i.e. it was not green pass like that of official firmware, but resulted RED FAIL.))

[PROBLEM 4] SYSTEM_ROOT Created:

This i saw for the first time i guess, in my phone, and maybe the cause of this whole problem. Now my root directory in twrp '/ ' contains /system_root along with /system, /data, /cache. One more thing /system_root contains system folder ,i.e. /system_root/system results same things as /system . When checked in twrp>wipe section> Repair system> There System Mount Point is shown as : /system_root instead of previously used to be "/system" normal directory when /system_root was not present at all.

Another thing /system_root contains files like default.prop , init files, sepolicy which are also present in root directory ' / ' . This whole /system_root should not have existed at all when /system exists. Maybe /system_root or the init files or other thing present inside /system_root are preventing all the changes - deletion , flashing changes etc. described in this post and maybe this folder was created by step(3) flashing procedure below , i.e. due to magisk. Also formatting system in twrp>wipe>system returns successful msg but nothing is deleted when checked in twrp file manager or twrp>Backup (system partition backup size shows 1456 mb even after formating)

[OTHER THINGS I TRIED] to solve this -

- Deleting twrp folder to make it to default state, again it's successfull deleted but doesn't loads default configuration after reboot due to PROBLEM 1 above as deletion reverts back after reboot

- Fixing contexts in twrp

- reboot disemmcwp

- mount -o remount,rw /system commands in twrp terminal (again to mention every command that is possible to enter runs without any error, hence successful but problem persists even after that )

- flashing stock boot.img and recovery.img (both successful no changes observed after reboot, but after stock boot or recovery.img flash, if you flash magisk uninstaller zip it still says "magisk patched image detected", and next thing written after it is " ! (Exclamation mark) Boot image backup unavailable" , then "Restoring ramdisk with internal backup" again magisk uninstaller also returns successful. after reboot again runing uninstaller detects magisk again. and boots twrp only instead of stock recovery

- repair, resize system partition in twrp>wipe section results Twrp error 1 (might be due to that /system_root folder that contains now /system which is also present in ' / ' root

- Changing "system partition" file-system with all 6 options returns successful but filesystem stays ext4 only when checked again.

WHAT IS WORKING-

Odin is working. - i once flashed my first twrp recovery on this device through the same version

TWRP is working - Although this is new twrp version 3.6.1_9-0 that i flashed just few time before all this catastrophe happened (maybe it might be the cause or it may be magisk)

Current Configuration:

Device: Samsung Galaxy Grand Prime

Model: SM-G530H (fortuna3g)

ROM: [STABLE][10] LineageOS 17.1 GO by DarkDroidDev from xda

GApps: Customised OpenGapps package (this caused erroneous bootlooping ROM) - i can boot into ROM but it is very lagging, and reboots again after some time, ranging from 10-20 seconds to max 3 minutes. Launcher is not working. And Keyboard is crashing. I can go into settings to change something but change doesn't persists after reboot

Magisk: Magisk 23.0

What was my FLASH PROCEDURES before this happened-

- Cleaned dalvikcache, data, cache, system

- After this, Data and Cache showed 0mb in Backup option in twrp, system showed 2mb containing only usr folder, boot showed 13mb

- (1) Cleaned Flashed above ROM

- (2) Customized OpenGapps flash

- (3) Magisk Patched Boot.img flash - - (not magisk.zip installer, its magisk-patched-boot.img flash through twrp only)

- (4) Dalvik Cache Wipe

- Booted into System.

I was actually testing the customised OpenGapps package,

Before this flashed customised package 10-20 times. i was editing, flashing, seeing the changes... > then again editing, flashing. So this was not the first time.

If any error occured, like launcher not working, i again booted into twrp wiped system data or deleted particular launcher file in twrp, all worked, changes were successful then i again continued my testing.. editing packages > flashing > seeing the changes by booting into actual rom.

But this whole case happened during the iteration of my testing when i introduced Gboard apk, downloaded from Play Store from fortuna3g(this device), into the Custom Gapps Package.

So, the cause of all this according to my knowledge where i doubt maybe one of the following-

(1) - That Keyboard apk installation as system app (most probably permissions problem, as apk was fine as tested before on this device and resulted in keyboard related folders created in that /system/usr folder which always contained only one folder, but only this time contained this keyboard related stuff there)

(2) - That magisk-patched-boot.img flashing procedure, step(3) above, just after openGapps flash "without booting into system first" - this was done first time in my testing iterations, so might be incorrect procedure

(3) - Due to step (3), issue might be related to magisk related stuff - dm-verity, Force encryption

(4) - Creation of /system_root folder in root directory '/ ' maybe due to step (3), there used to be only /system there before

(5) - Hardware Problem, maybe that's why all those successful twrp and ODIN flashes not doing anything

Please suggest something that i have not tried and could solve this PROBLEM of NOT BEING ABLE TO CHANGE ANYTHING ON SYSTEM or USERDATA partition.

I know people here know a lot more than me, and can help me with their valuable suggestions and solutions, if any.

Thanks.