In NAND Flash, the whole block is erased.How is the data in that block that is not intended to be erased, gets recovered after it is erased? Is there some kind of Flash Memory Management Unit that helps in recovering or relocating that data?
It is the memory device's software driver who is responsible for managing physical memory where entire blocks of data are erased.
Several types of physical memory over write or erase entire blocks of data. Hard Disk Drives and Flash Memory to name two. Normally, a block of memory is only used for a single file. If a file is larger then one block of memory, several blocks can be used. So if a file is deleted, the block or all the blocks associated with that file are deleted.
It is unusual to share data from several files in a single block of memory. But if this occurs, it would be the responsibility of the storage device's software driver to copy the parts of the block to be preserved to another block before erasing the older block of memory.
If this is an embedded application there may be no storage device software driver. That is, the embedded application manages a block memory device directly. In such a case, the embedded programmer needs to be very careful in how they manage the memory device so as not to erase wanted data.