Skip to content

Named volume mounts - Volumes should mount to /media/volume/[volume-name]

Overview

Volumes were previously mounted to /media/volume/sd[x] (just matching the linux block device name). These are not consistent between reboots, and just generally not ergonomic.

#831 (closed) polled jetstream users asking how they want volumes to be mounted, and by volume name was the unanimous result.

This MR builds on !887 (merged).

The new volume attach process is:

  • A volume is attached to an instance in exosphere
    • Exosphere asks OpenStack to attach the volume
    • Exosphere adds "exoVolume::[volumeUuid]=[volume name]" to the instance metadata
  • A udev rule notices the new block device /dev/sd?
    • This starts the systemd service automount-volume@sdb.service
  • This service runs automount-volume.py mount /dev/sdb
    • This uses udev device information to get the volume uuid from the device serial number
    • Then polls the instance metadata for exoVolume::[uuid]
    • Checks if the block device has a filesystem (again, udev information helps here)
      • If not, formats using mkfs.ext4
      • If yes, if the filesystem label does not match the volume name, "fixes" that using e2label /dev/sdb [volume_name]
    • Mounts the volume to /media/volume/[volume_name], fixing permissions as it goes

When the block device is removed, the mount is cleaned up and the mountpoint removed

Notes:

  • The volume name is sanitized, all non-alphanumeric characters are replaced with -
  • exoServerVersion is bumped to 5
  • Instances with exoServerVersion < 5 will show the "old" mount instructions and mountpoints

Fixes #831 (closed)

How to Test

Create a new graphical desktop instance, changing the cloud-init to use --url "https://gitlab.com/kageurufu/exosphere" --checkout "better-volume-mount-names"
Attach a volume to this instance
Observe that it should be mounted in /media/volume/[volume_name], and should appear on the gnome desktop as "volume_name"

Screenshots

New volume mounting instructions

image

Volume mounts shown on instance details

image

Volume mount shown on volume details

image

Edited by Frank Tackitt

Merge request reports