Re: [OT] Recovering a deleted file that is still open



Joey Hess wrote:
Raj Kiran Grandhi wrote:
If I have accidentally deleted a file that is still being used by some
application (read or write mode), is it possible to recover such a file? Especially since the file is not really deleted until the descriptor is closed by the application?

Just wondering...

Yes, get the pid of the process that has the file open, then go to
/proc/PID/fd/

joey@kodama:/proc/19553/fd>dir
total 0
dr-x------ 2 joey joey 0 May 8 00:36 ./
dr-xr-xr-x 6 joey joey 0 May 8 00:36 ../
lrwx------ 1 joey joey 64 May 8 00:36 0 -> /dev/pts/10
lrwx------ 1 joey joey 64 May 8 00:36 1 -> /dev/pts/10
lrwx------ 1 joey joey 64 May 8 00:36 2 -> /dev/pts/10
lr-x------ 1 joey joey 64 May 8 00:36 6 -> /home/joey/foo~\ (deleted)
joey@kodama:/proc/19553/fd>cat 6 >~/foo


Cool! Thanks for that. I had noticed those links but did not think of cat'ing a broken symbolic link.

--
Raj Kiran Grandhi
--
Politics is for the moment. An equation is for eternity.
-- Albert Einstein


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: [OT] Recovering a deleted file that is still open
    ... Hash: SHA1 ... is it possible to recover such a file? ... Especially since the file is not really deleted until the descriptor is ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: [OT] Recovering a deleted file that is still open
    ... is it possible to recover such a file? ... Especially since the file is not really deleted until the descriptor is closed by the ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ... Trouble? ...
    (Debian-User)
  • Re: [OT] Recovering a deleted file that is still open
    ... Joey Hess wrote: ... is it possible to recover such a file? ... Especially since the file is not really deleted until the descriptor is closed by the application? ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ...
    (Debian-User)
  • Re: data recovery tools for debian (command line)
    ... Mount the partition, where you deleted files as read only first. ... They also have got options to recover data that is from a special time ... I still have 2 unmounted ext4 partitions since December 2011. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: data recovery tools for debian (command line)
    ... Mount the partition, where you deleted files as read only first. ... They also have got options to recover data that is from a special time ... I still have 2 unmounted ext4 partitions since December 2011. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)