Chapter 12. 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. 12.1. The GVFS system 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. 12.2. The format of the GVFS URI string 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 12.1. A URI string pointing to the root FTP directory Example 12.2. A URI string pointing to a text file on FTP 12.3. Mounting a storage volume in GNOME You can manually mount a local storage volume or a network share in the Files application. Procedure Open the Files application. Click Other Locations in the side bar. The window lists all connected storage volumes and all network shares that are publicly available on your local area network. If you can see the volume or network share in this list, mount it by clicking the item. If you want to connect to a different network share, use the following steps. Enter the GVFS URI string to the network share in the Connect to Server field. Press Connect . If the dialog asks you for login credentials, enter your name and password into the relevant fields. When the mounting process finishes, you can browse the files on the volume or network share. 12.4. Unmounting a storage volume in GNOME You can unmount a storage volume, a network share, or another resource in the Files application. Procedure Open the Files application. In the side bar, click the Unmount (⏏) icon to the chosen mount. Wait until the mount disappears from the side bar or a notification about the safe removal appears. 12.5. Access to GVFS mounts in the file system Learn more about 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. 12.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: Command Description 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 USDXDG_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: Command Description 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 gio(1) man page on your system 12.7. Sample GIO commands The following section provides a few examples of the GIO commands usage. Example 12.3. List all files in the local /tmp directory Example 12.4. List the content of a text file from a remote system Example 12.5. Copy the text file to a local /tmp directory Additional resources gio man page on your system 12.8. Overview of GVFS metadata 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 gio man page on your system 12.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 Create an empty file: View the metadata of this file: Set a string to this file: View the metadata: Move this file to a new location: View the metadata: The metadata persists when you move the file using the GIO API. Additional resources gio man page on your system 12.10. Password management of GVFS mounts Learn more about 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. 12.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 12.1. Available back ends Back end Description 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.

Commands:
ftp://ftp.myserver.net/
ssh://joe@ftp.myserver.net/home/joe/todo.txt
gio list file:///tmp
gio cat ssh://joe@ftp.myserver.net/home/joe/todo.txt
gio copy ssh://joe@ftp.myserver.net/home/joe/todo.txt /tmp/
touch /tmp/myfile
gio info -a 'metadata::*' /tmp/myfile uri: file:///tmp/myfile attributes:
gio set -t string /tmp/myfile 'metadata::mynote' 'Please remember to delete this file!'
gio info -a 'metadata::*' /tmp/myfile uri: file:///tmp/myfile attributes: metadata::mynote: Please remember to delete this file!
gio move /tmp/myfile /tmp/newfile
gio info -a 'metadata::*' /tmp/newfile uri: file:///tmp/newfile attributes: metadata::mynote: Please remember to delete this file!