Accidentally deleted/removed a file using rm : please help

Hi,

I accidentally removed an important file under /root.
Is there a way I can recover the file in Linino.

Please help / point me to some commands utility

Tons of thanks -

High Regards

BRE

Which file?

If you built the image you can find the file on the Yun in the same relative place from staging_dir/target-mips_r2_uClibc-0.9.33.2/root-ar71xx/ in your build root.

Just use scp to copy it over.

Thanks for the reply,

This file is new python file placed under seperate directory under

/abc/app/abc-app.py

I accidentally removed abc-app.py

Let me know if you need further details.

Best Regards,

BRE

Hi,

Adding more information to the deleted file.

When I run the df command on this directory. It shows this is mounted under Filesystem rootfs.

I am not sure - how to recover the deleted file from there

Any help is appreciated.

Regards

BRE

If all else fails, you might try a dd from that partition and write it somewhere else (on /mnt/sda1 perhaps?) You can easily recognize that python text among all the binary gibberish and if your original filing system wasn't too fragmented, you'd be able to retrieve your file (or most of it).

kind regards,

Jos

JosAH,

Thank you very much.

File is under the partition /dev/mtdbblock3

Sorry, I am not a Linux guru.
Can you please give me some initial steps to us dd command

Thank you very much

Regards

BRE

You could try this:

dd if=/dev/mtdbblock3 of=/mnt/sda1/dumpfile

This'll create a file named 'dumpfile'. Although it'd contain a lot of binary rubbish, the vi editor can still handle it; you'll spot the readable text parts in it and you have to remove the rest of it (using vi). It's an old fashioned hacking session :wink:

kind regards,

Jos

Dear JosAH,

I got the file output and it has lot of garbage as outlined by you-
Still unable to find my code in that, Is there a way I can covert this file to Asci.

Thank you very much

High Regards

BRE

I'm sorry I can't help. It the deleted file was one of the "built-in" files (eg: the python executable) then it would have been easy, but in your case it's not

JosAH:
...
It's an old fashioned hacking session :wink:
...

I simply love it.

one comment (not important) :

"/dev/mtdbblock3" is in jffs2 format and jffs2 is compressed, then dumpfile is no longer readable text.

sonnyyu:

JosAH:
...
It's an old fashioned hacking session :wink:
...

I simply love it.

one comment (not important) :

"/dev/mtdbblock3" is in jffs2 format and jffs2 is compressed, then dumpfile is no longer readable text.

Can it be gunzipped? If so, a line as:

dd if=/dev/mtdbblock3 | zcat > /mnt/sda1/dumpfile

might do the trick. (I know next to nothing about OpenWRT's filing systems trickery)

kind regards,

Jos