Librem 5 USB Mount to Linux

After some googling I found out that some raspberry Pis (the Zero/A/A+ specifically as those support USB-OTG, which I’ll assume Librem 5 also supports?) has made this possible.

There seems to be some kernel module which makes the device work as a standard USB mass storage device called g_mass_storage, in the example it points directly at a image file though rather than a local filesystem, not sure how to point it to the running filesystem. I found it in this guide, see the bottom about “g_mass_storage”

Once I receive my Librem 5 I could attempt making a simple app for this.

That isn’t safe though, is it? … exposing a local disk as a USB mass storage class device while it is being used by the device itself.

It can be made safe if the device itself is capable of running without using the local disk for the entire period that it is being used by the connected computer e.g. can boot into some kind of RAM-only mode that does not touch the local disk (after booting).

However that isn’t very convenient, hence my suggestion for something like MTP or anything equivalent to that.

2 Likes

Hm, seems like you’re correct.

Was a long time since I used MTP but back then it was not very widely supported so I always avoided it.
But it seems like android has a good reason why it removed USB mass storage support after a while, so maybe it’s not a very good idea after all.

2 Likes

Interesting. When I plugged the Galaxy SIII into Mint the other day, both the phone internal storage and the SD card were exposed to Linux. Of course, the SIII is OLD.

Also interesting… I double-clicked and MP3 file and it opened xplayer, which promptly told me that it did not have an MTP plugin installed. That’s when I realized that I had double-clicked on the phone MP3’s, not the copy I had made on the Mint machine. Xplayer worked fine from the file on Mint, as it wasn’t trying to stream the MP3 across a USB cable.

It ought to be transparent to xplayer (and anything else) if you have the GVFS MTP backend installed and working. However there are a lot of moving parts e.g. whether the phone identifies itself as having, among other things, an MTP USB device class e.g. whether Mint recognized that correctly e.g. how Mint chose to handle that.

By default, you get a network device and a emulated serial port when connecting the Librem 5 to a PC via USB - so you can use tools like scp, rsync etc.

That’s however just the default; you can reconfigure the usb gadget to export the SD card directly as a mass storage device just fine. Of course it then needs to be unmounted locally for the time of being exported.

Technically there’s also nothing to stop you from implementing MTP mode, but I have no idea how easy would that be and if there’s some existing prior art already.

2 Likes

Which, in the case of the eMMC drive, is why we were ruminating about MTP (or other equivalent protocols).

1 Like

Please, how do you actually do this?

I’m plugging a Librem 5 to a Librem 13 with a USB-C cord.

How, from the Librem 13 command line, do I connect to the Librem 5? I have no idea what the IP address of the phone is (and ip addr on the phone returns nothing useful).

1 Like

How you actually do this depends less on the physical machine your connecting to and more on the OS you are running.

Out the box, the Librem 5 supports Ethernet over USB and by default it runs a DHCP client on the interface so is looking for IP configuration from a DHCP server, so the machine you are connecting to would need to support and be running connection sharing to provide the Librem 5 with an IP address.

How you setup connection sharing on your machine very much depends on your OS.

The OS I use uses NetworkManager to manage all network connections so I can use nmcli from the command line to setup connection sharing. There is a myriad of configuration setups, it really depends on your requirements, to setup a basic connection share using nmcli on single interface…

  1. Determine the device/interface to enable connection sharing on by attaching the Librem 5 to a USB port of your machine and from the command line of the machine enter…
nmcli dev

This will produce an output similar to…

DEVICE           TYPE      STATE                                   CONNECTION
enxe44b62d3acf5  ethernet  connecting (getting IP configuration)   Wired Connection N
lo               loopback  unmanaged

You are looking for the interface that is showing a state of getting IP configuration, in this case the device/interface the Librem 5 is connected to is enxe44b62d3acf5.

  1. Enable connection sharing on the device/interface from the command line of your machine by entering…
nmcli con add type ethernet ifname <devicename> ipv4.method shared con-name NetShare
  1. Bring up the new connection by entering…
nmcli con up NetShare
  1. You should now be able to ping the Librem 5 from the command line of your machine (assuming the Librem 5 has the default pureos hostname) by entering…
ping pureos.local

If you don’t get a response, check the state of the USB interface from the terminal of the Librem 5 by entering…

nmcli dev

If you see the usb0 device showing as disconnected, you can bring that up from the terminal of the phone by entering…

nmcli dev connect usb0

It should now be the case that whenever you connect the Librem 5 to the same USB port of your machine then connection share will be automatically established.

Note that this enables connection sharing with the machine you are a connected to so this provides access to the internet to your Librem 5 through your machine.

Well, I’m screwed from the get-go apparently. My Librem 13 (running pureos) does not show anything on nmcli dev except for the wifi connection and loopback. No third option trying to connect that would be my phone.

If you haven’t done so already, try other USB ports on your Librem 13 if possible.

Also, while Librem 5 and Librem 13 are connected, check the output of nmcli dev from the Librem 5 terminal, does it show a usb0 device and if so what is showing for it’s “state”?

You could also check from the terminal of Librem 5 nmcli con show, is there a usb0 in the output of that command?

Best to back it up a little.

First thing: Do lsusb on the host computer before plugging in the Librem 5 and after.

If you don’t see any USB device appear then that’s a bad sign. Stop here.

Second thing: Do lsusb -v -sM:N where M is the bus number and N is the device number (numbers taken from the previous output).

While you may not understand all the output, from that output someone can tell what kind of device(s) the Librem 5 is offering.

However there are limited reasons why you would want to network via USB anyway - since if the WiFi on the Librem 5 is working, you can just access all network services via the existing local network. That in turn depends on what network services you want to use i.e. what you mean by connecting to the Librem 5. Access files on the Librem 5? Remote log in to the Librem 5? (both of which can be achieved using SSH)

Ideally I’d be able to log in to the Librem 5 and edit files there from the 13. Failing that, I can copy the file I want back and forth. All accomplishable via ssh provided, of course, the phone has an IP address seen from the Librem 13 and I know what it is. (From that point forward, I know how to use ssh and its relatives.)

I will try your other suggestions when I have time–I’m a bit pressed right now.

Thanks!!

Do you have What IP installed on the L5?

Failing that, your router will tell you what the devices’ IP addresses are.

1 Like

No router. Just me plugging the phone directly into the Librem 13 with a USB C cable

I’ve previously seen comments from a number of Librem 5 owners say that they have connectivity issues when connecting directly to a hosts USB-C port but that there is/was no such connectivity issues when connecting via a hosts USB-A port.

1 Like

For me, there are a few reasons as to why I favour a localised network via Ethernet over USB rather than WiFi.

Firstly is performance and stability, I see a very significant increase in stability and performance with Ethernet over USB in comparison to WiFi. In terms of performance I see gains in the region of 500~1000+% depending on whether I’m working on the SD card or eMMC drive.

Secondly, there is a convenience factor for me, I have it setup as such that when the Librem 5 is attached to the desktop machines via Ethernet over USB, the Librem 5 gets auto-mounted. The Librem 5 essenially presents itself as having the convenience and functionality of simply plugging in a USB flash drive and immediately being able to drag files to/from the device.

1 Like

Did you try barrier to operator the L5 and any other Linux computer with 1 keyboard and mouse?

If nothing else, USB-C allows you to plug the cable in the wrong way round at both ends whereas a USB-A port can only be wrong at the Librem 5 end. :frowning:

Of course it shouldn’t matter but there is ample evidence that for some devices it does.