20

I have Ubuntu 18.04 LTS installed.

I inserted USB-flash to my laptop. It was automounted to /media/username/DISKLABEL and opened in Nautilus. I can read and write objects to it.

How can I access it from the application, which is installed as Snap?

I tried snaps of the following applications such as gedit, arduino-mhall119, organize-my-files. All them show me errors if I navigate to /media folder:

trying to access /media

trying to access /media

Could not read the contents of Media

Error opening the directory of '/media': permission denied

Output of active Snap interfaces is below:

$ snap interfaces  | grep -v ".*-$"
Slot                             Plug
:browser-support                 organize-my-files
:core-support                    core:core-support-plug
:cups-control                    gedit
:desktop                         gedit,organize-my-files
:desktop-legacy                  gedit,organize-my-files
:gsettings                       gedit,organize-my-files
:home                            arduino-mhall119,gedit,organize-my-files
:network                         arduino-mhall119,gedit,organize-my-files,pulsemixer
:opengl                          organize-my-files
:pulseaudio                      organize-my-files,pulsemixer
:unity7                          arduino-mhall119,gedit,organize-my-files
:wayland                         gedit
:x11                             arduino-mhall119,organize-my-files,pulsemixer
gnome-3-26-1604:gnome-3-26-1604  gedit
gtk-common-themes:gtk3-themes    gedit
gtk-common-themes:icon-themes    gedit
gtk-common-themes:sound-themes   gedit
-                                arduino-mhall119:serial-port
-                                gedit:avahi-observe
-                                gedit:mount-observe

Updates:

  • connecting mount-observe to Gedit with snap connect gedit:mount-observe does not help.
  • it seems that we need special Snap with support of removable-media interface.
22

So we need special prepared Snap with support of removable-media connector/interface/plugin.

Below is a list of Snap with removable-media plug described in YAML-manifest :

One can find other Snaps released by SnapCrafters with the following GitHub search link.


So if the application does not have auto-connect of removable-media we need to connect it manually with:

snap connect some-snap-name:removable-media

But not all applications have this plug/interface in YAML-manifest.


It is hard to find packages by supported plugs - so I created issue "Add ability for parametric Snap search with filters (plugs, such as removable-media and so on)" about snapcraft.io site.

The bug about snap command named "snap should provide functionality to find packages with needed plug or connector" was filed to launchpad as bug 1776938.

  • The correct command is: snap connect some-snap-name:removable-media – Zygmunt Krynicki May 25 '18 at 15:06
  • @ZygmuntKrynicki of course. Thank you, I fixed this silly typo. – N0rbert May 25 '18 at 15:10
  • The bug which is cited in the last two paragraphs is truly annoying, but a simple workaround for it if the snap package is already installed is snap interfaces some-snap-name – karel Jun 15 '18 at 12:55
  • @karel, right. Thank you! I have this command already in question. The main problem is to determine plugs of non-installed Snap. – N0rbert Jun 15 '18 at 12:56
  • 1
    The bug which is cited in the last two paragraphs is truly annoying, but a simple workaround for it if the snap package is already installed is snap connections some-snap-name This is an update of my previous comment. – karel Jul 30 '19 at 18:03
11

The Ubuntu Software program will now show a Permissions button on the page of each Snap program you have installed.

the Krita page of Ubuntu Software program showing the buttons under the title - Launch, Remove, and Permissions

Click on Permissions, and a pop-up window gives you the option 'Read/write files on removable storage devices', with a button to the right that you click to turn this on.

enter image description here

You need to activate each program one by one this way, but there is nothing special to remember, other than that the button exists.

  • Please add screenshot of "Click on Permissions, and a pop-up window" to the answer. – N0rbert Jul 14 '19 at 17:37
  • @N0rbert Done... – kim holder Jul 17 '19 at 21:22
3

The interface which needs to be connected is removable-media.

Can access files from removable media in /media and /run/media. This can be used to give an app access to mounted USB sticks and external hard drives on a desktop.

The mount-observe interface only lets you view what is mounted, not access mounts:

Can query system mount information. This is restricted because it gives privileged read access to mount arguments and should only be used with trusted apps.

Neither of these two interfaces will auto-connect. From https://github.com/snapcore/snapd/wiki/Interfaces#removable-media

  • I don't know. It seems obs-studio does, but I only found it due to it mentioning the interface in the description of the app for how to access external storage. I don't know how to query the store for specific interfaces in snaps. If a specific snap doesn't support the interface, it will presumably need to be rebuilt to support it. – dobey May 9 '18 at 13:58
2

To access USB storage from a snap, it needs a connection to removable-media. Some snaps are automatically connected to it. If not, you can manually connect it using the following command:

snap connect snap-name:removable-media

Sometimes, this command fails with the following message:

error: snap "snap-name" has no plug named "removable-media"

This means the publisher of the package has not indicated that the application can use removable media. In this case, you should contact the publisher and ask them to add the removable-media interface to the plugs of the Snap.

Most Snaps show how to contact the publisher; run snap info snap-name and look at the contact field for an email address or a URL.

Automatically connecting removable-media

It is possible for publishers to request that their Snap is automatically connected to the removable-media interface. This is allowed for applications that fall into the following categories.

  • Major browsers such as Brave, Firefox and Chromium.
  • Media editors such as photo editors like gimp, video editors like OpenToonz or audio editors like Audacity.
  • Media players/viewers such as video players like VLC media player or image viewing programs.
  • Media recorders such as a screencast program, a webcam program, OBS Studio or a podcast recording application.

If an application falls into one of these categories and removable-media is not automatically connected to the application, please contact the publisher and ask them to request an auto-connection to removable-media.

Not the answer you're looking for? Browse other questions tagged or ask your own question.