3

I plugged an Android (HarmonyOS 2.0.0) phone into a Linux laptop using USB connection. I want to mount the storage of the phone in Linux, so that I can transfer files between the phone and the laptop. But I can't find the phone in

$ sudo fdisk -l
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST1000LM014-1EJ1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: ...

Device         Start        End    Sectors   Size Type
/dev/sda1    1048576   69206015   68157440  32.5G Linux swap
/dev/sda2   69206016  195035135  125829120    60G Linux filesystem
/dev/sda3  195035136 1953523711 1758488576 838.5G Linux filesystem
/dev/sda4       2048    1048575    1046528   511M EFI System

Partition table entries are not in disk order.

but in

$sudo lshw
...
    *-usb
         physical id: 14
         bus info: pci@0000:00:14.0
         version: 31
         width: 64 bits
         clock: 33MHz
         capabilities: pm msi bus_master cap_list
         configuration: driver=xhci_hcd latency=0
         resources: irq:129 memory:df410000-df41ffff
       *-usbhost:0
            product: xHCI Host Controller
            vendor: Linux 5.19.0 xhci-hcd
            physical id: 0
            bus info: usb@1
            logical name: usb1
            version: 5.19
            capabilities: usb-2.00
            configuration: driver=hub slots=16 speed=480Mbit/s
          *-usb:0
               description: Mass storage device
               product: BKL-AL20
               vendor: HUAWEI
               physical id: 1
               bus info: usb@1:1
               version: 2.99
               serial: 
               capabilities: usb-2.10 scsi
               configuration: driver=usb-storage maxpower=500mA speed=480Mbit/s

How shall I find the device of the phone's storage so that I can mount it in Linux?

The phone is under "File Transfer via USB". I would like to transfer any type of files, not just pictures. When I plug the phone to the laptop using USB connection, there are options to choose on the phone: transfer photos, transfer files, charge only, reverse charge, and input MIDI. I chose transfer files.

The phone has an internal memory and probably a SD card.


$lsusb -v

...


Bus 001 Device 078: ID 12d1:107e Huawei Technologies Co., Ltd. P10 smartphone
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x12d1 Huawei Technologies Co., Ltd.
  idProduct          0x107e P10 smartphone
  bcdDevice            2.99
  iManufacturer           1 HUAWEI
  iProduct                2 BKL-AL20
  iSerial                 3 ...
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x006c
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          4 
    bmAttributes         0xc0
      Self Powered
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol      0 
      iInterface              5 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x001c  1x 28 bytes
        bInterval               6
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              6 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     66 
      bInterfaceProtocol      1 
      iInterface              8 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     72 
      bInterfaceProtocol      1 
      iInterface              9 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0

and I can't mount the storage of the phone

$ aft-mtp-mount ~/media/phone/
connect failed: no MTP device found

Mode "transfer photos" allows me to do that

$ aft-mtp-mount ~/media/phone/

but it only shows me images files not files of other types.

4
  • How does lsusb.py -ui look? Also, does the phone have an microSD card slot? If so, is any card placed in the slot?
    – Tom Yan
    Commented 2 days ago
  • Is the phone set to file transfer mode?
    – muru
    Commented 2 days ago
  • My guess is the phone only allows / supports exposing the external/real SD card, while the card slot doesn't have any card inserted at the moment, so you don't see it with fdisk -l because it "has no medium".
    – Tom Yan
    Commented 2 days ago
  • I like android-file-transfer. For the Debian version see packages.debian.org/sid/android-file-transfer Commented yesterday

2 Answers 2

9

I've been using Android for over a decade now and the most reliable way to use its internal storage "directly" is to install any available Android FTP (or SSH/SCP/SFTP/WebDAV/whatever works for you) server and open your device in e.g. File Far Manager, WinSCP or FileZilla, granted you have a fast enough Wi-Fi network.

Some FTP servers support root access as well, but I won't give any recommendations as it's beyond the scope of this website.

The MTP protocol is extremely finicky and has a ton of limitations.

Android does not allow to just "export" its partitions via a USB connection. In order to do so, all the running applications must be stopped which is not quite possible (it's actually possible but I'm not aware of any Android ROMs which implement the feature - it requires quite a lot of effort).

9
  • 3
    Doesn't have to be FTP. One can install termux and run sshd for SCP/SFTP. Port would be 8022 when running as a normal user.
    – JoL
    Commented yesterday
  • @JoL No SSHd implementation I am aware of implements the Android Storage Access Framework (SAF). Without that, it is pretty much useless for file-transfer on recent Android versions. There are FTP server implementations which employ SAF. They actually work.
    – Hermann
    Commented yesterday
  • @Hermann SimpleSSHD on HarmonyOS 2.0.0 doesn't show me any directory, given permission to access the storage. Is it because it doesn't follow SAF? What FTP server implementations have you found that work?
    – Tim
    Commented yesterday
  • 1
    Software recommendations are generally frowned upon here but since you want this problem to be solved: I find github.com/wolpi/prim-ftpd works reasonably well.
    – Hermann
    Commented yesterday
  • Apart from FTP & SSH, KDEconnect also does a quite decent job in connecting phone and computer. It's not mounting the file system, but at least browsing and copying files in your graphical file browser works.
    – asdfex
    Commented yesterday
5

You will not find your phone in the list of block devices because your phone does not really support being used block device. HarmonyOS is based on Android 10. As far as I know, Android 10 only offers the Media Transfer Protocol (MTP). When the phone is configured to offer mtp, you will see it in the output of lsusb -v:

Device Descriptor:
  iManufacturer           1 manufacturer
  iProduct                2 phone
  …
  Configuration Descriptor:
    iConfiguration          4 mtp_adb
    …
    Interface Descriptor:
      iInterface              5 MTP
      …

You can access the files with any mtp client. I prefer mounting with gvfs-mtp, but any of the clients listed in https://wiki.archlinux.org/title/Media_Transfer_Protocol will do.

6
  • Well, his lshw output literally shows a mass storage device (that is bound by the usb-storage driver) with vendor: HUAWEI, although it's probably true that, if what he wants to access is the emulated SD card, mtp is the only way.
    – Tom Yan
    Commented 2 days ago
  • Thanks. The output of my lsusb -v doesn't have "mtp", see my update. When I plug the phone to the laptop using USB connection, there are options to choose: transfer photos, transfer files, charge only, reverse charge, and input MIDI. I chose transfer files. Does that configure the phone to offer MTP? If not, how shall I configure it to offer MTP?
    – Tim
    Commented 2 days ago
  • I want to transfer files not just pictures, but also any other file formats, such as pdf. So I chose "transfer files" instead of "transfer photos". Does "transfer photos" only allow transfer pictures?
    – Tim
    Commented 2 days ago
  • 2
    The "Transfer Files" should enable MTP. "USB Mass Storage Mode" was deprecated years ago, see android.stackexchange.com/questions/190138/…, though the phone may offer you a read-only device to install the HiSuite from. I did not find an authoritative source, but similar discussions like bbs.archlinux.org/viewtopic.php?id=275617 indicate that HarmonyOS does indeed offer MTP. "Transfer Pictures" is the older PTP protocol. You do not want that.
    – Hermann
    Commented 2 days ago
  • "transfer files" doesn't allow me to mount the device. see my update.
    – Tim
    Commented 2 days ago

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .