NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.08k stars 14.07k forks source link

Can't mount iphone #152592

Open tobiasBora opened 2 years ago

tobiasBora commented 2 years ago

Describe the bug

I'm trying to mount the Iphone of a friend on NixOs, but I can't manage to do it. I tried to follow the wiki instructions, and also to install ifuse, but nothing mounts in Dolphin or nautilus, and ifuse does not find the device:

Steps To Reproduce

Steps to reproduce the behavior. First, add in your configuration:

{ config, pkgs, lib, ... }:
{
  # Read iphones (see also ifuse?) https://nixos.wiki/wiki/IOS
  services.usbmuxd.enable = true;
  environment.systemPackages = with pkgs; [
    ifuse # I tried to add that
    libimobiledevice
  ];
}

Then, dolphin shows nothing in the left pannel, and ifuse gives this error:

$ mkdir /tmp/iphone/
$ sudo ifuse /tmp/iphone/
ERROR: No device found!
Is the device properly connected?
If it is make sure that your user has permissions to access the raw USB device.
If you're still having issues try unplugging the device and reconnecting it.

The very first time I plugged the phone I needed to type a password on the Iphone to allow the computer to access it, but then nothing happened.

tobiasBora commented 2 years ago

I checked the usbmuxd service, and I can see an error:

$ systemctl status usbmuxd.service 
● usbmuxd.service - usbmuxd
     Loaded: loaded (/etc/systemd/system/usbmuxd.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-12-29 15:53:46 CET; 3h 38min ago
       Docs: man:usbmuxd(8)
    Process: 1927 ExecStartPre=/nix/store/27855idyr8dkmh0xrzg7jln7a3fa7viy-systemd-249.4/bin/udevadm trigger -s usb -a idVendor=05ac (code=exited, status=0/SUCCESS)
   Main PID: 1969 (usbmuxd)
         IP: 0B in, 0B out
         IO: 0B read, 0B written
      Tasks: 2 (limit: 18965)
     Memory: 1.4M
        CPU: 43.691s
     CGroup: /system.slice/usbmuxd.service
             └─1969 /nix/store/b1kh3dd92kc7snlylv869jbx68k91m9d-usbmuxd-unstable-2021-05-08/bin/usbmuxd -U usbmux -f

déc. 29 15:56:22 bestos usbmuxd[1969]: [15:56:22.494][3] Connected to v2.0 device 2 on location 0x10006 with serial number 7dc35016f7483ab0aa2cbf45f543c7e06278bc5c
déc. 29 15:56:27 bestos usbmuxd[1969]: [15:56:27.500][1] preflight_worker_handle_device_add: ERROR: Could not connect to lockdownd on device 7dc35016f7483ab0aa2cbf45f543c7e06278bc5c, lockdown error -8
déc. 29 16:05:36 bestos usbmuxd[1969]: [16:05:36.868][3] Removed device 2 on location 0x10006
déc. 29 16:05:56 bestos usbmuxd[1969]: [16:05:56.083][3] Connecting to new device on location 0x10009 as ID 3
déc. 29 16:05:56 bestos usbmuxd[1969]: [16:05:56.083][3] Connected to v2.0 device 3 on location 0x10009 with serial number 7dc35016f7483ab0aa2cbf45f543c7e06278bc5c
déc. 29 16:06:01 bestos usbmuxd[1969]: [16:06:01.088][1] preflight_worker_handle_device_add: ERROR: Could not connect to lockdownd on device 7dc35016f7483ab0aa2cbf45f543c7e06278bc5c, lockdown error -8
déc. 29 16:09:23 bestos usbmuxd[1969]: [16:09:23.191][3] Removed device 3 on location 0x10009
déc. 29 16:09:29 bestos usbmuxd[1969]: [16:09:29.007][3] Connecting to new device on location 0x1000a as ID 4
déc. 29 16:09:29 bestos usbmuxd[1969]: [16:09:29.007][3] Connected to v2.0 device 4 on location 0x1000a with serial number 7dc35016f7483ab0aa2cbf45f543c7e06278bc5c
déc. 29 16:09:34 bestos usbmuxd[1969]: [16:09:34.013][1] preflight_worker_handle_device_add: ERROR: Could not connect to lockdownd on device 7dc35016f7483ab0aa2cbf45f543c7e06278bc5c, lockdown error -8

@infinisil

tobiasBora commented 2 years ago

https://github.com/libimobiledevice/usbmuxd/issues/95 reported that it may be due to incompatibilities between versions of different softwares (they also mention ldconfig, not sure if it's relevant here). @fortuneteller2k any idea if your upgrade to unstable could be the reason of this issue?

moni-dz commented 2 years ago

I sometimes get the lockdownd error, but restarting usbmuxd.service fixes it:

~ ❯ sv status usbmuxd                             
● usbmuxd.service - usbmuxd
     Loaded: loaded (/etc/systemd/system/usbmuxd.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-12-30 01:59:00 PST; 11h ago
       Docs: man:usbmuxd(8)
   Main PID: 813 (usbmuxd)
         IP: 0B in, 0B out
         IO: 5.9M read, 2.6M written
      Tasks: 2 (limit: 10938)
     Memory: 6.7M
        CPU: 8.764s
     CGroup: /system.slice/usbmuxd.service
             └─813 /nix/store/aacw0lpwf859xmr9id53fmhlz2m0ywi4-usbmuxd-unstable-2021-05-08/bin/usbmuxd -U usbmux -f

Dec 30 13:43:58 superfluous usbmuxd[813]: [13:43:58.464][2] Cannot find device entry while removing USB device 0x11575a0 on location 0x40007
Dec 30 13:43:58 superfluous usbmuxd[813]: libusb: error [udev_hotplug_event] ignoring udev action unbind
Dec 30 13:44:03 superfluous usbmuxd[813]: [13:44:03.471][1] preflight_worker_handle_device_add: ERROR: Could not get ProductVersion from device 00008020-001A58582283002E, lockdown error -8
Dec 30 13:45:03 superfluous usbmuxd[813]: [13:45:03.778][3] Connecting to new device on location 0x40008 as ID 2
Dec 30 13:45:03 superfluous usbmuxd[813]: [13:45:03.778][3] Connected to v2.0 device 2 on location 0x40008 with serial number 00008020-001A58582283002E
Dec 30 13:45:06 superfluous usbmuxd[813]: [13:45:06.324][3] Removed device 2 on location 0x40008
Dec 30 13:45:08 superfluous usbmuxd[813]: [13:45:08.784][1] preflight_worker_handle_device_add: ERROR: Could not connect to lockdownd on device 00008020-001A58582283002E, lockdown error -8
Dec 30 13:45:12 superfluous usbmuxd[813]: [13:45:12.479][3] Connecting to new device on location 0x60003 as ID 3
Dec 30 13:45:12 superfluous usbmuxd[813]: [13:45:12.479][3] Connected to v2.0 device 3 on location 0x60003 with serial number 00008020-001A58582283002E
Dec 30 13:45:17 superfluous usbmuxd[813]: [13:45:17.484][1] preflight_worker_handle_device_add: ERROR: Could not connect to lockdownd on device 00008020-001A58582283002E, lockdown error -8

~ took 2s ❯ sv restart usbmuxd                                                                            
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to restart 'usbmuxd.service'.
Authenticating as: fortuneteller2k
Password: 
==== AUTHENTICATION COMPLETE ====

~ took 1m43s ❯ ideviceinfo | rg Product
ProductName: iPhone OS
ProductType: iPhone11,2
ProductVersion: 15.1
ProductionSOC: true
tobiasBora commented 2 years ago

Oh, indeed this works... but this is really strange (also the time to restart the service is quite long). Is it an upstream bug or is it NixOs specific?

Also, I'm realizing that Dolphin does not yet have a support for Iphone (people reported that kio-fuse can work on dolphin but I can't find how to install it in NixOs, and some people are working on kio_afc. However, as I understand Nautilus should be able to access to the Iphone using gvfs (gvfs-afc more precisely, but I've the feeling (to be triple checked!) that in nixpkgs gvfs includes everything?). I tried to run:

$ nix-shell -p gnome.nautilus gvfs
$ nautilus

and indeed the iphone appears, however, there is no visible folder containing pictures:

image

Any idea what's wrong?

moni-dz commented 2 years ago

Oh, indeed this works... but this is really strange (also the time to restart the service is quite long). Is it an upstream bug or is it NixOs specific?

Also, I'm realizing that Dolphin does not yet have a support for Iphone (people reported that kio-fuse can work on dolphin but I can't find how to install it in NixOs, and some people are working on kio_afc. However, as I understand Nautilus should be able to access to the Iphone using gvfs (gvfs-afc more precisely, but I've the feeling (to be triple checked!) that in nixpkgs gvfs includes everything?). I tried to run:

$ nix-shell -p gnome.nautilus gvfs
$ nautilus

and indeed the iphone appears, however, there is no visible folder containing pictures:

image

Any idea what's wrong?

Hmm, that's weird,

I'm able to see my pictures just fine with gnome.gvfs and ifuse:

image

tobiasBora commented 2 years ago

Thanks a lot for the help. So if I mount manually the device with ifuse, indeed I can access to the pictures using any file browser/console… But I thought the whole point of gvfs-afc was to access the iphone without command line (and not everybody is familiar with command line).

generic-github-user commented 9 months ago

I'm having the same issue. Sometimes I get the "No device found!" error from ifuse, other times ifuse silently fails (the process starts but the target directory is hidden and/or empty, when accessible). systemctl status usbmuxd reports the following (for example):

Jan 11 17:07:02 nixos usbmuxd[5837]: [17:07:02.714][1] failed to recv_data on client 17 with error=client 17 disconnected! code=6750218
Jan 11 17:08:02 nixos usbmuxd[5837]: [17:08:02.752][1] no connection found with snum=1
Jan 11 17:08:11 nixos usbmuxd[5837]: [17:08:11.138][1] failed to recv_data on client 19 with error=client 19 disconnected! code=6750218
Jan 11 17:08:11 nixos usbmuxd[5837]: [17:08:11.139][1] failed to recv_data on client -1 with error=graceful kill code=24313866
Jan 11 17:08:11 nixos usbmuxd[5837]: [17:08:11.142][1] failed to recv_data on client 15 with error=client 15 disconnected! code=6750218
Jan 11 17:08:11 nixos usbmuxd[5837]: [17:08:11.142][1] failed to recv_data on client 20 with error=client 20 disconnected! code=6750218
Jan 11 17:08:11 nixos usbmuxd[5837]: [17:08:11.144][1] failed to recv_data on client 18 with error=client 18 disconnected! code=6750218
Jan 11 17:08:16 nixos usbmuxd[5837]: [17:08:16.174][1] no connection found with snum=1
Jan 11 17:08:17 nixos usbmuxd[5837]: [17:08:17.877][1] failed to connect client dport=49253 error=assure failed code=20250631
Jan 11 17:08:17 nixos usbmuxd[5837]: [17:08:17.877][1] failed to recv_data on client 21 with error=assure failed code=25165834

I was able to get it working briefly last night by restarting usbmuxd, mounting to /run/media/anna/ifuse and opening the parent directory in Dolphin as an administrator, but have been unable to recreate this since. I suspect that the device stops trusting my computer for some reason, but does not renew the "Trust this computer?" modal, and all further connections fail until I restart the system.

Edit: I've also tried the kio-fuse and gvfs approaches, no luck there either.

pwaller commented 9 months ago

For me I actually wonder if the iphone's thunderbolt port or the cable doesn't work properly anymore. I don't have much I can test with and I charge wirelessly.