Sample Header Ad - 728x90

Restore deleted contents of a text file

1 vote
2 answers
3193 views
Due to this bug, the content of one of my source files was deleted. I searched a lot and found that I can read the raw data on the storage device with the dd command, and I can find the address of blocks that hold my file's data through the hdparm command, but the contents of my file were deleted, and the size of it is zero so hdparm shows nothing. So I read the entire partition with dd and filtered output with grep and I found a line of my source file, so I am sure that my source file's contents are alive on my storage device. Now I have some questions: 1. Is there is a optimized way to restore the content of file? 2. Is it a good idea to delete the file and then recover it with recovery tools? 3. Is there a way to find the address after finding a line of my source file? 4. Is there a way to find the addresses of old blocks? 5. Is there a way to force the grep command to print (for example) 1000 lines after finding the desired line? 6. I am not familiar with how files are saved in a directory, does the directory have a physical boundary? I mean, can I find the start and end addresses of a directory to read all of the directory's contents? ( I want to read the entirety of my src folder). Basically, how can I get my fiels back? Note: 1. I use the linux. 2. My partition's file system is ex4. 3. My storage device is SSD. Thanks.
Asked by ali tavakoli (19 rep)
Mar 20, 2022, 11:25 AM
Last activity: Nov 12, 2022, 09:15 PM