Transfer files between the L5 and networked computers

Even found it:

#!/bin/sh
set -x
rmmod g_multi
rmmod g_ether
cd /sys/kernel/config/
cd usb_gadget
mkdir g1
cd g1
echo "0x316d" > idVendor
echo "0x4c05" > idProduct
echo "0xEF" > bDeviceClass
echo "0x02" > bDeviceSubClass
echo "0x01" > bDeviceProtocol
mkdir strings/0x409
echo "0123456789" > strings/0x409/serialnumber
echo "Purism, SPC" > strings/0x409/manufacturer
echo "Librem 5" > strings/0x409/product
mkdir functions/ecm.usb0
mkdir functions/acm.GS0
mkdir functions/mass_storage.0
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "CDC ACM+ECM" > configs/c.1/strings/0x409/configuration
echo "/dev/sda" > functions/mass_storage.0/lun.0/file
echo "Librem 5" > functions/mass_storage.0/lun.0/inquiry_string
ln -s functions/acm.GS0 configs/c.1
ln -s functions/ecm.usb0 configs/c.1
ln -s functions/mass_storage.0 configs/c.1
echo "38100000.usb" > UDC

This sets up a USB gadget with three functions - serial, ethernet and mass storage (with /dev/sda being exported). Make sure to unmount any SD partition before doing that though - it is a block level export (as opposed to other tech like MTP that exports things on a filesystem level), so it will be your PC that will mount these partitions on its own!

Related ticket: https://source.puri.sm/Librem5/linux-next/-/issues/182

5 Likes

Oh, yeah, MTP too.

As I said, almost too many options.

Over time, if looking to gain mainstream customers, I think MTP (or something functionally equivalent) is needed. Users of other phones have come to expect plugging in via USB as an option, and for it to work seamlessly out-of-the-box. USB has the advantage of better physical security (but watch out for “bad chargers”).

As you imply, MTP is safer than USB mass storage class because while some users will know to umount first if using mass storage class, many will not.

5 Likes

For my desktop to laptop I use Syncthing

For me it’s rsync which comes without thinking :wink: , which means I need ssh server running in the background

What would be awesome is to have an option to activate/deactivate SSH in the settings (if installed) !
Else, I will probably have 2 shortcuts, one to disable sshd, one to activate sshd (as I have on my actual pc)

2 Likes

Would be? It’s already there for ages :smiley:

3 Likes

So awesome that it already exists?: [MyL5] Received my Librem 5 (Evergreen)

Argh, beat me by 1 minute, @dos :slight_smile:

2 Likes

It doesn’t work for tinysshd though :stuck_out_tongue:
Edit: but yes it’s about sharing and tiny doesn’t give any other service but shell.

1 Like

@dos @kieran : Hey ! I missed that ! :heart: THAT’S AWESOME ! :smile:

1 Like

I’m planning on setting something up where whenever my home Wifi connects, mount my home server’s storage drive via NFS.
When Wifi disconnects, unmount.

I can browse the same drive via SMB on my Android but having this setup I think will be pretty slick.

Still need a good adaptive GUI file manager option though, but that is coming.

Edit: And only a few minutes later I happen across this: https://source.puri.sm/adrien.plazas/nautilus/-/commit/0732ac4a1dd3177c04384f1c55e05ed7fbf76e91

1 Like
1 Like

Yes! Thanks. I just checked and my USB-C to USB-A/micro-B drive now mounts automatically when inserted.

2 Likes

True story! A few years ago, Asus routers that had built-in USB/FTP/Samba were compromised because there was no password protection included. They’ve corrected that now. Still maybe not the best option, as you and others have pointed out.

2 Likes

:shushing_face: don’t ruin the surprise :wink:

2 Likes

I like the scp command.

Here’s a tutorial for those who don’t yet know how to use it:
https://linuxize(dot)com/post/how-to-use-scp-command-to-securely-transfer-files/

Edit: Reminder to set up ssh first.

1 Like

I had just assumed that connection to a network would work similar to say desktop Ubuntu, but In reality I don’t have any experience with Pure OS.

Can anybody tell me if samba share is supported in Pure OS (and by extension I assumed the L5)?

CIFS is supported by the kernel, and you can install cifs-utils to be able to mount it

I usually do sshfs to the phone:

sshfs purism@192.168.0.22 mnt/l5

And after you’re done:

fusermount -u mnt/l5

Keep in mind that this likes to hang up sometimes when the phone loses network or reset, and needs root to fix:

sudo umount -f mnt/l5
4 Likes

You probably need to clarify whether your intention is that the phone is the server and offers its files to the network, or your phone is the client and accesses files on your network.

If I had to take a guess, I would say that if Samba works at all then it will work either way, and that Samba will work, but better than guessing is testing.

Note that all those people talking about sshfs (so far) are talking about “phone as server”, and “phone as server” may be good for ad hoc transfers via the network. (That said, I don’t see any reason why the phone can’t use sshfs i.e. phone as client.)

One advantage of “phone as server”, if you don’t have an external monitor / dock available and set up, is that you can use the bigger screen GUI of the desktop/laptop to drive the transfer process. Even if using the command line, you may prefer to drive from the desktop/laptop.

At the same time, if you already have a file server then for sure I can see that you might want the “phone as client” to access content available on your network.

I have (just about) all the protocols that have been discussed in this topic in use and working with other devices on my network, so happy to test everything and report back, come the day early in the new year when I have my phone (talking it up :slight_smile:).

2 Likes

I’ve been a fan of rsync for a very long time. It really pays off for updates of large files and for syncing directories where some files are new or changed and others are unchanged.

I think that is one of the big advantages of just about all gadgets that run linux, not only phones.

1 Like