Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file that's downloading (from a source that's hard to re-download from), but accidentally deleted from the filesystem namespace (/tmp/blah), and I'd like to recover this file.

Normally I could just cp /proc/$PID/fd/$FD /tmp/blah, but in this case that would only get me a partial snapshot, since the file is still downloading. Furthermore, once the download completes, the downloading process (e.g. Chrome) will close the FD.

Any way to recover by inode/create a hard link? Any other solutions? If it makes any difference, I'm mainly concerned with ext4.

share|improve this question
up vote 11 down vote accepted

Try using tail to copy the file continually:

tail -c +0 -f /proc/$pid/fd/$fd > filename

Of course, you will have to stop the tail process by hand (or some other external means) when the download has finished.

share|improve this answer
Works like a charm. I guess this was much easier than I thought, since all you need is really just another program that opens the same file to keep it around. – Yang Mar 15 '11 at 18:51

The fdlink project, consisting of a Linux kernel module and simple application, purports to create a new link to an open file descriptor. I haven't tried it.

share|improve this answer
Nice find, thanks! – Yang Mar 15 '11 at 18:50

This will get the job done, though not through by recovering the inode:

cp /proc/$PID/fd/$FD /tmp/blah
kill $PID
wget -c $URL -O /tmp/blah

Or just manually stop the download in Chrome if you don't want to kill the whole browser.

share|improve this answer
If only the problem were so simple that I could just resume-/re-download! I clarified the question to indicate that I can't assume I can re-download. – Yang Feb 16 '11 at 21:27
Sounds like trouble :-) It seems like any inode-based hacks are way too low-level and filesystem-specific. – Pavel Feb 17 '11 at 14:51
Yeah, I just also added this to my question: if it makes any difference, I'm mainly concerned with ext4. – Yang Feb 18 '11 at 4:12

If you want to do a hard link on this, you have to use the -s option (see man ln) so in the fd directory run ls -f and find out the filenumber (mostly two-digit numbers) and make a ln NUMBER destination-file -s

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.