Recently, I bricked my iPhone and had to restore it in iTunes. In the process, I lost a bunch of photos from my Camera Roll that hadn't been saved to my computer yet. After an endless amount of Google searching, I finally found a way to recover, or "undelete" data from the iPhone. This guide will focus on recovering photos, since that's what I had to do, but the same process could be used to recover other lost data.
What you'll need:
- Jailbroken iPhone
- BSD Subsystem and OpenSSH installed on your iPhone
- Terminal (or MobileTerminal) installed on your iPhone
- An SSH server installed on your computer (mine is running Ubuntu 7.10 with OpenSSH)
- The 'DD' utility installed on your computer (this should be pre-installed on most Linux systems)
- Your iPhone's IP address
- Your computer's IP address
First, make sure that your iPhone and computer are on the same LAN. You can try to ping your computer from your iPhone (using Terminal) and vice versa, just to make sure they can see each other on your LAN. For example:
Next, you'll want to make sure that you can SSH into your computer from the iPhone. To do that, open Terminal on the iPhone and enter:
Code:
ssh <username>@<computer-ip>
Where:
<username> = Your user name on the computer.
<computer-ip> = Your computer's IP address on the LAN.
If that worked, you should be prompted to enter a password for <username>. If the connection times out, then you need to make sure that you have the SSH server running on your computer and make sure that port 22 (the default SSH port) isn't being blocked by your router's firewall.
Once you know that your iPhone and the computer are talking to each other, open Terminal on the iPhone and run the following command to begin transferring the iPhone's "disk" image to your computer (be sure to
run this as root using 'su'):
NOTE: Make certain that your iPhone's screen lock is disabled first. If the screen lock comes on, it will kill the SSH connection. Also, you'll want to connect your iPhone to its charger. This transfer can take a while.
Code:
dd if=/dev/disk0 | ssh <username>@<computer-ip> 'dd of=iphone-dump.img'
The above command will create a "disk" image of your iPhone (named "iphone-dump.img") on your computer. Feel free to use a different name or a different destination directory. For example: 'dd of=/home/username/iphone-dump.img'.
Also, be sure that you don't mix up the "if" (input-file) and "of" (output-file) in the command above. Doing so could wipe-out your iPhone.
After the process has completed and the iPhone's image file has been saved to your computer, you can use a program like
PhotoRec to recover your photos.
I hope this helps!