Restore and/or Jailbreak your iPhone or iPod Touch in GNU/Linux with VirtualBox

All you fans of OSen that Apple doesn’t provide iTunes for — GNU/Linux, *BSD, etc. — may find it annoying that there’s no real way to restore or jailbreak your shiny new iPhone or iPod Touch besides dual-booting or finding a compatible machine, huh?

Firstly, this is kinda what you have to expect after buying an Apple device ;-)  If it doesn’t fit into the Apple World™, you’d better believe that a whole host of problems will rise up.  If you’re a nice local IT guy like me though, you may wish to help liberate the souls of hapless iFollowers partially, and assist them in the jailbreaking of their devices.

As it turns out, virtualization software can help.  Alas, VMware Workstation does not work, and I haven’t tried QEMU.  The problem with VMware seems to be that iTunes doesn’t see the iPod at one critical step, and eventually gives up looking, handing you an error (usually 1611).  VirtualBox works great, though it requires a bit of manual work.  You will, sadly, need Sun’s Personal Use and Evalutation License (PUEL) version of VirtualBox, which is not Free Software — the Open Source Edition (OSE) does not support USB last I checked.  To clarify, VirtualBox PUEL is free in price, but not open-source free as in freedom.

This tutorial should work for all OSen capable of USB 2.0 and USB-enabled VirtualBox, and the jailbreaking section should work for the iPod Touch 1G/2G, and the iPhone 1G/2G/3G/3GS.  I don’t think the restore process will let you downgrade firmware, though, so you should have firmware 3.0.1 or lower.  We will be using redsn0w 0.8  to jailbreak.  This app works better in Windoze anyways; it often fails on GNU/Linux even though that OS is also supported.

BY USING THIS GUIDE YOU AGREE THAT I AM NOT TO BE HELD RESPONSIBLE FOR DAMANGES, LOSS OF FUNCTION, etc. etc etc…..  Basically, don’t be a douche.  I don’t think it’s even possible to screw up your iPod/iPhone with this; Apple actually did a good job at least in ensuring there’s pretty much always a way to restore if things go awry.  Losing your data will definitely happen if you restore, though — that’s part of what the restore does — so back up.  The jailbreaking shouldn’t cost you your data, but being safe can’t hurt.

 

 

Now that all that crap is over with, go ahead and grab VirtualBox PUEL, and make your virtual machine.  The OS I used is Windows XP Pro SP3, others may or may not work.  I wouldn’t advise a 64-bit Windows copy (the LibUsb-Win32 drivers are 32-bit, and this complicates matters), and XP is probably overall your best bet.  Make sure to enable USB in the settings, and install the OS.  You may also need to have the guest OS able to get to the Internet.

Once you have the VM up and running (I installed the guest additions, you may not need them), get the LibUsb-Win32 drivers and install them.  I’m not sure why exactly they are necessary, but they seem to in general make this whole process much smoother and more fail-proof.  Here they are, make sure to get the latest .exe file.  Reboot after installation.

Next, you need iTunes.  I’m not sure if later versions don’t work, but I would really recommend version 8.2.0, as I’ve had the most success with it.  You can find a downloadable copy here.

And last, you need the actual firmware you’re going to install.  I won’t link it, as the legality is somewhat questionable (as is everything with Apple), but you should be able to use Google to find a firmware that works with your model iPod/iPhone.  Remember, the .ipsw file you need is different for every model of iPod — one for the 2G iPhone, one for the 2G iPod, one for the 1G iPod, etc. etc.  I recommend firmware 3.0 for iPods, and 3.0.1 for iPhones (fixes an SMS exploit).  3.1 and later have nice features, but protect against the jailbreak hack we will use later.  If you’re too comfortable bending over for Steve Jobs, then you can go right for the latest firmware (3.1.2 at the time of writing) ;-)  There ARE exploits for 3.1+, blackra1n seems to be the one everyone goes to, but they have some shortcomings.  Google for more info, I won’t get into it here.  If you do use 3.1+, you may need a later version of iTunes; I’m not sure.

 

 

Once all this is acquired, and you’ve rebooted your VM again, don’t let iTunes start.  The first thing to do is open up a command prompt and cd to “C:\Program Files\LibUsb-Win32\bin”, or wherever else you installed that package.  Once there, run “install-filter.exe -i”.  There should be no output from the command.

Next, we get the iPod/iPhone ready.  Plug it in and turn it completely off — it’s okay if iTunes starts up in a fuss once it sees the connection.  We are now going to enter DFU mode, which is an even lower-level version of the Recovery mode, and works better sometimes.  Follow these instructions carefully.  There are lots of differing instructions online, but I find these steps to work the best — if they don’t, Google for DFU mode and try other methods.  If, after many retries, you can’t get in DFU mode, then you can try in Recovery mode, which may work.  I believe you get in Recovery mode by plugging in the device to the PC and holding down the Home button for a while until you see an image depicting a connection to iTunes.  Here are the DFU instructions, though:

0.) Ensure your iPod/iPhone is connected to the computer via your USB cable, and completely powered off.

1.) Press in and hold down the power switch for about three seconds, until a tiny bit after you see the silver Apple logo.  Once you see that, also start holding in the Home button, or whatever that button’s name is on the front of the device.  After a little while, the device should completely power off again.  If you see the image depicting connecting an iPod to iTunes, all is not lost, although this usually works better if you start holding the Home button earlier so that you never see that screen before the device shuts down.

2.) Now that the device is off again, keep holding the power switch and the Home button for about a full second, and then switch to holding just the Home button.  If you see the Apple logo again, you held down the power button too long, and you’ll have to start over.  If the screen stays  completely off, that’s good — keep holding down that Home button for a good 15-20 seconds, and then you can release; you should be in DFU mode.  You can verify this by running the ‘lsusb’ program in your chosen bare-metal OS, or whatever equivalent function it offers to show all USB devices plugged in, or by looking in the Devices -> USB Devices section of VirtualBox’s menu (that does not refresh automatically, you have to keep opening the menu every few seconds to refresh).  Then, you may stop holding down the Home button.

If anything goes wrong during this sequence, start all over.  If you want out of DFU mode, hold down the power and Home buttons for a bit and the device should be off (no real detectable difference), so then you can power it on again — don’t worry, you can’t get stuck in DFU mode!

 

 

Now you can give the virtual machine the iPod/iPhone — use Devices -> USB Devices to check your device.  The VM may immediately drop it again, just go back in and check it again.

iTunes will detect the device now.  Remember throughout this guide, usually when iTunes shows a slim progress bar that keeps going through, it’s looking for the device or waiting for it to be unchecked/rechecked in Devices -> USB Devices.  It may do this now, in which case you should check the iPod/iPhone in USB Devices if it isn’t checked, and if it is, uncheck and then recheck.

iTunes should now complain that the device is in recovery mode, and needs to be restored.  That’s what we want.  Hold down the left Shift key and click the Restore button in iTunes.  Now, choose the .ipsw firmware file you downloaded before.  This is why I specified downloading the firmware manually — if you just click the Restore button, iTunes will download and install the very latest firmware, which is likely not what you want if you’re going to jailbreak.  Even if you aren’t, I recommend the manual method.

Go ahead and feed it the .ipsw.  After extracting it, iTunes will do some preparation, and then show another floating progress bar most likely.  Uncheck the iPod in the VM menu, wait a second, and it should reappear in the menu (in Recovery mode this time, not DFU).  Check it again, and iTunes will proceed.  At this point, you should start to get feedback on the iPod/iPhone.

After some more work, iTunes will again stall at “Preparing iPod for restore…”, and the iPod should disconnect from the VM.  Go ahead and reconnect it.  It will be listed as not in Recovery mode anymore.  The floating bar will persist for a while — DON’T disconnect and reconnect the device from the VM, as I suggested before, in this case!  From here on, remember: when the iPod/iPhone has a slowly filling progress bar on its display, don’t tamper with the VM connection.  The progress bar should switch back to a normal bar shortly.

Sit back and relax, there won’t be any need for user interaction for a while.  Sooner or later, iTunes will again show a floating progress bar while it verifies the iPod software.  Still, don’t disconnect — there’s still a progress bar on the device, right?  Right.

If you got an error around the 1600s during this process, you likely failed to reconnect/disconnect/whateverconnect the device when iTunes wanted you to.  Try again.  If you get a low error number like 9 or 2, you likely disconnected or such when iTunes was busy working on the iPhone/iPod — don’t worry, just try again.

The iPod will disconnect for quite a while.  When it becomes ready again, you should have a newly restored iPod/iPhone!  Congratulations ;-)  If you want to truly make this device yours, and jailbreak it, keep reading.

 

 

Okay, jailbreak time.  Google around for a tool called redsn0w, and download it.  This guide was written for version 0.8 — if later versions come out, they may or may not work.

We need to again enter DFU mode.  This time, it’s mandatory.  Follow the above instructions to get in DFU mode, and connect the device to the virtual machine using its menu.  Close iTunes, and start redsn0w.  Feed it the same .ipsw firmware you have on your iPod/iPhone.  Click next, and it will patch the firmware.  You will be asked what to install for a package manager on the jailbroken device (I recommend Cydia only; Icy is faster and slicker but now unmaintained and is also more bug-prone in my experience).

You will be given instructions now by redsn0w on entering DFU mode.  Since we already did that, just click through them without doing anything to your device, waiting when it forces you to wait.  Make sure your iPod/iPhone is connected to the VM in the VM menu, and is in DFU mode!  Once redsn0w sees your device, it will skip through the rest of the instructions and begin.

Throughout the jailbreak process, redsn0w will every now and again stall on “Waiting for reboot…”.  This is your cue to reconnect the iPod/iPhone in VirtualBox’s menu if it got disconnected, or if it is still connected there, disconnect and reconnect.

Congratulations on your squeaky-clean jailbroken iPhone or iPod ;-)  Now go, and use it to show off the power of a world full of enterprising hackers!  The less Winblows is necessary, the better ;-)

 

 

Feel free to comment with questions, troubles, — or hey, even thank yous if I helped you out; they are much appreciated :-)

~ by Ranguvar on November 23, 2009.

One Response to “Restore and/or Jailbreak your iPhone or iPod Touch in GNU/Linux with VirtualBox”

  1. Nice post, but what about getting media onto the iPhone and managing it without Mac OS X / Windows?

Leave a Reply