Menu Close

Chapter 7. Managing storage volumes in GNOME

This section describes how you can manage storage volumes in GNOME with a virtual file system. GNOME Virtual File System (GVFS) is an extension of the virtual file system interface provided by the libraries the GNOME desktop is built on.

7.1. The GVFS system

This section introduces GVFS and explains how GVFS works.

GVFS provides complete virtual file system infrastructure and handles storage in the GNOME desktop. It uses addresses for full identification based on the Uniform Resource Identifier (URI) standard, syntactically similar to URL addresses in web browsers. These addresses in the form of schema://user@server/path are the key information determining the kind of service.

GVFS helps to mount the resources. These mounts are shared between multiple applications. Resources are tracked globally within the running desktop session, which means that even if you quit an application that triggered the mount, the mount continues to be available for any other application. Multiple applications can access the mount at the same time unless it is limited by a back end. Some protocols by design permit only a single channel.

GVFS mounts removable media in the /run/media/ directory.

7.2. The format of the GVFS URI string

This section explains what the GVFS URI string is and demonstrates how to form one.

You must form a URI string to use back end services. This string is a basic identifier used in GVFS, which carries all necessary information needed for unique identification, such as type of service, back end ID, absolute path, or user name if required. You can see this information in the Files address bar and GTK+ open or save file dialog.

The following example is a very basic form of the URI string, which points to a root directory (/) of the File Transfer Protocol (FTP) server running at the ftp.myserver.net domain:

Example 7.1. A URI string pointing to the root FTP directory

ftp://ftp.myserver.net/

Example 7.2. A URI string pointing to a text file on FTP

ssh://joe@ftp.myserver.net/home/joe/todo.txt

7.3. Mounting a storage volume in GNOME

In virtual file systems, particular resources are set to be mounted automatically, but the most common way is to trigger mounts manually.

Procedure

  1. Open the Files application.
  2. Click Other Locations in the side bar.
  3. Enter the URI string in the Connect to Server field.
  4. Press Connect.
  5. If the dialog asks you for login credentials, enter your name and password into the relevant entry boxes.
  6. When the mounting process finishes, you can start working with the storage volume.

7.4. Unmounting a storage volume in GNOME

You can unmount storage volumes or resources using the following procedure.

Procedure

  1. Open the Files application.
  2. In the side bar, click the Unmount (⏏) icon next to the chosen mount.
  3. Wait until the mount disappears or notification about the safe removal appears.

7.5. Access to GVFS mounts in the file system

This section introduces FUSE, the main daemon for the GVFS virtual file system.

Applications built with the GIO library can access GVFS mounts. In addition, GVFS provides a FUSE daemon which exposes active GVFS mounts. Any application can access active GVFS mounts using the standard POSIX APIs as though mounts were regular file systems.

In certain applications, additional library dependency and new virtual file system (VFS) subsystem specifics might be unsuitable or too complicated. For such reasons and to boost compatibility, GVFS provides a File System in Userspace (FUSE) daemon, which exposes active mounts through its mount for standard Portable Operating System Interface (POSIX) access. This daemon transparently translates incoming requests to imitate a local file system for applications.

Important

You might experience difficulties with certain combinations of applications and GVFS back ends.

The FUSE daemon starts automatically with the main gvfs daemon and mounts volumes either in the /run/user/UID/gvfs/ or ~/.gvfs/ directories as a fallback.

Manual browsing shows individual directories for each GVFS mount. The system passes the transformed path as an argument when you are opening documents from GVFS locations with non-native applications. Note that native GIO applications automatically translate this path back to a native URI.

7.6. Available GIO commands

GIO provides several commands that might be useful for scripting or testing.

Here is a set of POSIX commands counterparts as follows:

CommandDescription

gio cat

Displays the content of a file.

gio mkdir

Creates a new directory.

gio rename

Renames a file.

gio mount

Provides access to various aspects of the gio mounting functionality.

gio set

Sets a file attribute on a file.

gio copy

Makes a copy of a file.

gio list

Lists directory contents.

gio move

Moves a file from one location to another.

gio remove

Removes a file.

gio trash

Sends files or directories to the Trashcan. This can be a different folder depending on where the file is located, and not all file systems support this concept. In the common case that the file lives inside a user’s home directory, the trash folder is $XDG_DATA_HOME/Trash.

gio info

Displays information of the given locations.

gio save

Reads from standard input and saves the data to the given location.

gio tree

Lists the contents of the given locations recursively, in a tree-like format. If no location is given, it defaults to the current directory.

Following additional commands provide more control of GIO specifics:

CommandDescription

gio monitor

Monitors files or directories for changes, such as creation, deletion, content and attribute changes, and mount and unmount operations affecting the monitored locations.

gio mime

Lists the registered and recommended applications for the mimetype if no handler is given, else, it is set as the default handler for the mimetype.

gio open

Opens files with the default application that is registered to handle files of this type.

Note

For user convenience, bash completion is provided as a part of the package.

All these commands are native GIO clients, there is no need for the fallback FUSE daemon to be running. Their purpose is not to be drop-in replacements for POSIX commands, in fact, a very little range of switches is supported. In their basic form, these commands take an URI string as an argument instead of a local path.

Additional resources

  • The gio(1) man page.

7.7. Sample GIO commands

The following section provides a few examples of the GIO commands usage.

Example 7.3. List all files in the local /tmp directory

$ gio list file:///tmp

Example 7.4. List the content of a text file from a remote system

$ gio cat ssh://joe@ftp.myserver.net/home/joe/todo.txt

Example 7.5. Copy the previous text file to a local /tmp directory

$ gio copy ssh://joe@ftp.myserver.net/home/joe/todo.txt /tmp/

Additional resources

  • The gio man page.

7.8. Overview of GVFS metadata

This section provides information on the GVFS metadata and provides instruction on how to view and manipulate them.

The GVFS metadata storage is implemented as a set of key-and-value pairs that bind information to a particular file. Thus, there is a tool for a user or application to save small data designed for runtime information such as icon position, last-played location, position in a document, emblems, notes, and so on.

Whenever you move a file or directory, GVFS moves the metadata accordingly so that metadata stays connected to the respective file. The GVFS stores all metadata privately, so metadata is available only on the machine. However, GVFS tracks mounts and removable media as well.

Note

GVFS mounts removable media in the /run/media/ directory.

To view and manipulate with metadata, you can use:

  • the gio info command,
  • the gio set command, or
  • any other native GIO way of working with attributes.

Additional resources

  • The gio man page.

7.9. Setting custom GIO metadata attribute

This procedure describes how to set a custom metadata attribute.

Notice the differences between particular gio info calls and data persistence after a move or rename. Note the gio info command output.

Procedure

  1. Create an empty file:

    $ touch /tmp/myfile
  2. View the metadata of this file:

    $ gio info -a 'metadata::*' /tmp/myfile
    uri: file:///tmp/myfile
    attributes:
  3. Set a string to this file:

    $ gio set -t string /tmp/myfile 'metadata::mynote' 'Please remember to delete this file!'
  4. View the metadata:

    $ gio info -a 'metadata::*' /tmp/myfile
    uri: file:///tmp/myfile
    attributes:
      metadata::mynote: Please remember to delete this file!
  5. Move this file to a new location:

    $ gio move /tmp/myfile /tmp/newfile
  6. View the metadata:

    $ gio info -a 'metadata::*' /tmp/newfile
    uri: file:///tmp/newfile
    attributes:
      metadata::mynote: Please remember to delete this file!

The metadata persists when you move the file using the GIO API.

Additional resources

  • The gio man page.

7.10. Password management of GVFS mounts

This section focuses on the GVFS mount authentication.

A typical GVFS mount authenticates on its activation unless the resource allows anonymous authentication or does not require any authentication at all.

In a standard GTK+ dialog, you can choose whether to store the password.

When you select the persistent storage, the password is stored in the user keyring. GNOME Keyring is a central place for secrets storage. The password is encrypted and automatically unlocked on desktop session start using the password provided on login. For protecting it by a different password, you can set the password at the first use.

The Passwords and Keys application helps to manage the stored password and GNOME Keyring. It allows removing individual records or changing passwords.

7.11. GVFS back ends

Back ends in GVFS provide access to a specific type of resource. This section provides a list of available GVFS back ends and their specifications.

Note

Some back ends are packaged separately and not installed by default. For installing additional back ends, use the dnf package manager.

Table 7.1. Available back ends

Back endDescription

admin

Provides administrator access to the local file system.

burn

A virtual back end that burning applications use as a temporary storage for new CD, DVD, or BD medium content.

cdda

Exposes Audio CD through separate Waveform Audio File Format (WAV) files.

computer

A virtual back end consolidating active mounts and physical volumes. Acts similarly to a signpost. Previously used by Files for its Computer view.

dav, davs

A WebDAV client, including secure variant. Authentication is possible only during mount. The back end does not support later re-authentication on per-folder basis.

dns-sd

DNS Service Discovery: An Avahi client, used during network browsing, forms persistent URIs to discovered services.

ftp

A fully featured File Transfer Protocol (FTP) client. Supports passive transfers by default. Also, handles secure mode over ftps (explicit mode) and ftpis (implicit mode) schemes.

gphoto2

A Picture Transfer Protocol (PTP) client to access your camera attached by USB or FireWire.

google

Provides access to Google Drive. The Google Drive account needs to be configured in the Online Accounts settings.

http

Handles all HTTP requests. Useful for easy downloading files from web in client applications.

locatest

A simple testing back end that proxies the file:// URI. The back end supports error injection.

mtp

A Media Transfer Protocol (MTP) back end for accessing media player and smart phone memory.

network

Allows you to browse Window Network and show shares discovered over Avahi.

recent

A back end used in the file chooser dialog to list recent files used by GNOME applications.

sftp

A fully-featured SSH File Transfer Protocol (SFTP) client.

smb

Accesses Samba and Windows shares.

trash

A trash back end that allows to restore deleted files.