huanix

chown -R huanix /

huanix header image 2

Fixing USB on VirtualBox to allow iPhone Sync with an Ubuntu host running Windows XP

November 3rd, 2008 · 76 Comments · Intrepid, Linux, iphone, ubuntu

An update has been released. Please click this link to see virtualbox-iphone-r8.sh

Updated to virtualbox-iphone-r7.sh on 11/11/2008, 3:25 CST.

  • Removed check for ubuntu, since this will work on far more systems.
  • Improved the check for /etc/fstab with a grep instead of a question.
  • Started package cleanup; it’s not the best yet.
  • Still no exit points :(
  • Still only accepts simple responses (y).
  • Planning to add support for Suse & Fedora soon.

This is a script that will modify the Ubuntu (or other Debian) environment to allow you to sync your iPhone, iPod Touch, or iPod in a Windows XP Virtual machine. This fix solves two problems:

1. USB doesn’t work at all because there’s no mount point; edit /etc/fstab to fix it.
2. For the iPhone to sync, MAX_USBFS_BUFFER_SIZE needs to be modified in drivers/usb/core/devio.c

If the script works for you, please comment with your OS and details. If the script fails for you, PLEASE be very specific about what OS you are running and what did or didn’t happen. Comments without details don’t help anyone.

UPDATE: I’m not sure if i pointed out that you will need to re-run this script each time the Kernel is updated. The script now knows what to update and what to leave alone.

These instructions are based on my test environment. You do not have to follow them to the letter! Go ahead and try the script if you know what you’re doing!!!

This fix works on Ubuntu 8.10 Intrepid Ibex running VirtualBox-2.0 installed through apt-get. It also works on older versions of Ubuntu, and possibly many other distros. Be creative, but be careful.

Install virtualbox-2.0 through through apt-get:

1. edit your /etc/apt/sources.list file and add the following source:
deb http://download.virtualbox.org/virtualbox/debian intrepid non-free
(intrepid is not listed on the wiki, but the source is working!)

2. Run “wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -”

3. Run “sudo apt-get update”

4. Run “sudo apt-get install virtualbox-2.0″

Restart your computer to make sure the vboxusers group initializes properly.

Run the script:
(be sure to chmod +x and run as root!)

Change the permissions to allow execution (chmod +x virtualbox-iphone.sh) and run it as root.
The script downloads the kernel source, and will take approximately 400 mb and several minutes of processing to run properly.

Restart again to initialize the modified kernel. (not sure if these restarts are necessary, but i’m trying to be safe!)

In the settings tab for the virtual machine, check to be sure that USB is enabled.

When you run windows as a virtual machine, you will have to connect the device, then go to the “Devices” tab in VirtualBox and enable the device in “USB Devices>”

These steps should set the stage for everything to work correctly on Ubuntu 8.10. If you have difficulties, please be VERY specific!

—-

Some people are having trouble with the USB settings.. make yours look like this. Your iphone may already be here, and it may not – i deleted mine to keep people from panicking if they didn’t see theirs.

—-

11/16/2008: I am aware of an issue where version 2.6.27-7 of the kernel goes through “make” while version 2.6.27-8 goes through update-initramfs. I am working on the script to address this. The result is that running the script works fine, but USB doesn’t connect. I think this only happens to people that have updated to 2.6.27-8, which appears to have been pulled back. A possible solution is to run “sudo grub-update” and boot into the 2.6.27-8 kernel, OR (i would do try this) “sudo apt-get remove linux-image-2.6.27-8-generic && sudo apt-get remove linux-headers-2.6.27-8-generic “. I have only confirmed this once (thanks Brandon) and cannot reproduce it because 2.6.27-8 is not available. Please confirm a solution if you have one. This is the relevant output from the virtuabox script…

(i need a good code highligher!)

Building modules, stage 2.
MODPOST 1 modules
CC      /home/user/linux-source-2.6.27/drivers/usb/core/usbcore.mod.o
LD [M]  /home/user/linux-source-2.6.27/drivers/usb/core/usbcore.ko
make: Leaving directory `/usr/src/<strong>linux-headers-2.6.27-7-generic'</strong>
update-initramfs: Generating /boot/<strong>initrd.img-2.6.27-8-generic</strong>
Do you want to get rid of the source and installed files? 

—-

I’m working on virtualbox-iphone-v8.sh ; this release is intended to run on both Ubuntu and Fedora 10. I’d like to release it on November 25, 2008 – the same day Fedora 10 (Final) is released.

I’m looking for 5 testers that have a spare development machine and experience with installing operating systems (fedora & ubuntu). Experience with subversion would be a plus, but I’m not sure I want to go that fancy. Email me at huanix@gmail.com

I’m also looking for 5 donations to my paypal account, also huanix@gmail.com before we start testing. It takes a lot of time to do this and there is no substitute for monetary encouragement.

Current Tally (11/22/2008):
Testers: 3/5
Contributors: 4/5

Tags: ·····

76 Comments so far ↓

  • huanix

    on the settings tab in virtualbox under USB, there is a checkbox that says “Enable USB 2.0 (EHCI) Controller”, is that checked? it should be. Unchecking that box replicates your problem on my test machine.

  • Jekkil

    Huanix, better with that button :-)
    Check your mail for the donation and continue like this !

  • huanix

    Thanks Jekkil!

  • chris

    Dude, you are awesome. Is there another way to donate though? I’m paranoid about paypal.

  • huanix

    @chris – Why so paranoid about paypal? I don’t have other methods in mind, but you’re welcome to try – judging by the way you proposed to your girlfriend, you’re a very creative fellow. (that’s my way of saying that i enjoyed checking out your blog)

  • jan

    Hi,

    thank u very much for that script, it works perfectly for me (ubuntu 8.10).

    But i have one question: Since it changes the kernel, do i have to fear any problems with my ubuntu?

  • huanix

    No worries about kernel problems. The modification is to one specific field that only relates to USB. You’ll never notice it.

  • jan

    Thx a lot!
    Now i can finally get rid of my dual-boot system :-)
    itunes was the only reason i had to install windows

  • Mafra

    Thank you! Its work! I have Ubuntu 8.10 and an iPod Touch 2.1.

  • Chris

    Nice work! I’d love to know how you figured out that this change would get the phone working! :o )

    There are a few minor issues with the script– I could send you some patches if you want, though I’m sure you’ll want to work over any changes I’ve made to make them consistent with your work.

    The minor issues are: the script mods fstab to mount USB devices under the group ID “1000″. That group ID is the user-only group ID for the first user created on many distros (like mine– I’m on Ubuntu). But it’s not guaranteed on all distros, and even for those that do use 1000, it only works for single-user systems. It’s better to lookup the group ID for the ‘vboxusers’ group, and use it. (I have that mod for you). Then of course, you need to check to see whether the user is actually *in* the vboxusers group– that’s also in my mods.

    Let me know if you’d like me to send you some diffs…

    Cheers! and THANKS!!
    Chris

  • Chris

    By the way, I should have mentioned that the crucial thing (the buffer size change) worked like a charm for me with this configuration:

    Dell Latitude D630
    Ubuntu 8.04.1 (Hardy Heron) x86_64
    Sun VirtualBox 2.0.4
    Guest OS: Windows XP Pro, SP3
    iTunes 8.0.1.11
    iPhone w/2.1 software, not jailbroken

    I haven’t actually *synched* the phone yet, but iTunes shows the phone and all its contents. :o )

    Thanks again,
    Chris

  • huanix

    wow chris, i totally appreciate your support and I would gladly integrate any patches that work for the script. My issue right now is the pressure of a lot of other responsibilities that should be resolved soon. Do send what you’ve got!!

  • HuXu

    Ok so I ran the script and no usb devices are detected, USB drive and iPod dont show up.

    I am a part of the vboxusers group
    Intrepid Ibex (fully updated)
    VirtualBox 2.0.4
    iPod Touch 2.1

    I ran your script and it didnt result in any errors.

    This is my fstab

    # /etc/fstab: static file system information.
    #
    #
    proc /proc proc defaults 0 0
    # /dev/sda5
    UUID=ca08636a-fdc8-4e6f-bc2c-efc324be1ed0 / ext3 relatime,errors=remount-ro 0 1
    /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0

  • huanix

    It appears that the script was not executed properly. I don’t see that your /etc/fstab was modified. Did you press “y” at all of the prompts? A current limitation is that simply pressing “Enter” will cause the script to exit without errors and without making changes.

  • HuXu

    I did press y at all the prompts, i dunno if i accidently hit enter or not, but im gonna run it again and see how it goes…

  • HuXu

    And it worked when i added it manually. So i guess i would suggest check your script on the conditional for the fstab editing part, because i see its there but as you can see my fstab it didnt work on it.

    but other than that THANK YOU!!! THIS IS AWESOME!!!!

  • BLWedge09

    Just a word of advice from someone who now has experience with this… Don’t attempt to update the iphone software this way. Once the phone goes into recovery mode (itunes logo on the screen) ubuntu unmounts it (or thinks you have disconnected it) making it impossible to update the software. The phone will be stuck in recovery mode until you can connect it to another pc with itunes (not in a vm). Luckily, I was able to copy all of my itunes data, including the phone backup and library, over to my work XP laptop, set up the same shared drive I had in the VM and restore from a backup I made. Phew! I was worried there for a few minutes…

  • huanix

    @BLWedge09 – I actually had a very different experience. The phone did go into recovery mode and I right clicked on the USB icon in VirtualBox and connected the device in recovery mode. Even wrote a post about it: http://www.huanix.com/2008/11/23/you-can-upgrade-and-restore-apple-iphone-firmware-in-a-virtualbox-machine/

  • lucas

    I was having the same problem with some earlier version of VirtualBox. I just installed
    VirtualBox 2.0.6 from the repository as you instructed on Ubuntu 8.10 on a Lenovo SL300 and am running Windows XP SP3 and all worked without having to run your script at all.
    Sweet!
    And thanks!

  • boban

    hi, after rebooting I just tried to start Virtualbox and it says
    critical error:
    could not load the settings file ‘/home/boban/.VirtualBox/VirtualBox.xml’
    Cannot convert settings from version ‘1.6-linux’.
    The source version is not supported.

    Fehlercode:
    NS_ERROR_FAILURE (0×80004005)
    Komponente:
    VirtualBox
    Interface:
    IVirtualBox {557a07bc-e6ae-4520-a361-4a8493199137}

    can you help?

  • Matt

    boban: To fix this error, delete the folder .VirtualBox in your home directory and then restart VB. Worked for me.

  • Chaanakya

    I had this problem once. I just deleted that file and all was well. Did you have virtualbox installed, upgrade, and reinstall? I downgraded from Intrepid to Hardy, and I had this problem, but once I deleted that file, everything worked fine.

  • Magoraf

    Ubuntu 9.04 Jaunty
    Kernel 2.6.28
    Virtualbox 2.1.4

    I have the following problem during the script execution :

    strip: ‘usbcore.ko’: No such file

    I have already used this script several times with the previous version of Ubuntu (8.10 Intrepid), but since I updated to the new version/kernel, it doesn’t work anymore :-(
    Please HELP!

  • Faeryan

    I just stumbled upon this when reading someone’s blog.
    I’m running a VirtualBox 2.2.4 r47978 (or 2.24, not sure about that cause of the font) and on it a Windows 7 free trial version and I can sync my iPhone with it no problems.

    I was wondering whether it’s my Ubuntu kernel (2.6.26.11) or the version of my VirtualBox or even Windows 7 that did it for me.

  • Faeryan

    Oops.. The kernel I was using was of course 2.6.27.11, not 2.6.26.11 as I told earlier.

    I’ve upgraded to Jaunty and kernel 2.6.28.13 after my last iPhone connect so I’m not sure if it works with my current kernel.

  • benny

    uhm, i am really sorry, i must be really stupid, but where is the actual script now?
    i have already installed virtualbox, so i didnt copy the commands you posted 1:1.
    As far as i can read, after installing virtualbox, you simply write “and now run the script”.
    I must have missed something, could someone tell me how to get the actual script?
    thanks a lot in advance
    benny

Leave a Comment