Skip to content

Volumes

Create volume

  1. Log in to ScienceCloud Web Interface: https://cloud.science-it.uzh.ch.
  2. Go to Project → Volumes → Volumes.
  3. Click Create Volume.
  4. Enter: Volume Name and Size (GB).
  5. Click Create Volume.

Manage volumes on instances

Attach a volume to an instance

  1. On Volumes tab, select your volume.
  2. From drop-down Edit Volume list, select Manage Attachments.
  3. From Attach to Instance list, choose the instance you wish to attach the volume to.
  4. Press Attach Volume.

First-time use: mount and format

Once a volume is attached to an instance, it becomes visible to the operating system but may be in a blank state (without a filesystem). To use it, you need to identify the device, format it only once, and then mount it.

Danger

⚠️ Formatting will erase all data on the volume.

Perform the formatting step only the first time you attach a new or empty volume.

  1. Identify the volume device name. In the ScienceCloud Web Interface, go to Project → Volumes → Volumes and check the Attached To field for device names like /dev/vd{x} or /dev/sd{x}, where {x} is a lowercase latin letter like a, b, etc. Alternatively, use the following commands inside your instance to list all block devices attached to the instance:
    lsblk
    
    or
    sudo parted -l
    
  2. Format the volume (if new/empty). Format your new disk into ext4 (recommended file system).
    sudo mkfs.ext4 /dev/vd{x}
    
    or
    sudo mkfs.ext4 /dev/sd{x}
    
    Replace {x} with the correct device name.
  3. Mount the volume. Once the volume has a file system, mount it using:
    sudo mount /dev/vd{x} /mnt
    
  4. Verify the mount.
    df -h
    
    You should see a line starting with /dev/vd{x} or /dev/sd{x}.
  5. Set permissions for the default user (Ubuntu example: ubuntu). To get non-root access to the file system, you may need to set the ownership of mounted volume to allow ubuntu user for read/write:
    sudo chown -R ubuntu:ubuntu /mnt
    

Subsequent use: mount

Once a volume has a file system and user permissions are set, you only need to mount it again each time the instance starts:

sudo mount /dev/vd{x} /mnt

Automount volume

If you want the filesystem to be mounted automatically whenever the instance boots, edit the /etc/fstab file (or the equivalent configuration file for your operating system). This file specifies which devices are mounted, their mount points, and whether they should be mounted automatically at startup. Always back it up first, so you can restore it if something goes wrong:

sudo cp /etc/fstab /etc/fstab.old

Step-by-step guide

  1. Identify the volume and UUID. Run the following to list block devices, their UUIDs, and filesystems:
    sudo lsblk -o NAME,FSTYPE,UUID,SIZE,LABEL
    
    Note the UUID of the volume you want to mount. Using UUIDs is recommended because device names (like /dev/sdb) may change across reboots.
  2. Edit /etc/fstab. Open /etc/fstab in your preferred editor:
    sudo vim /etc/fstab
    
    Append a line for your volume using this format (each element is separated by whitespace):
    <UUID> <mount point> <type> <options> <dump> <pass>
    
    For example, to mount an ext4 volume at /mnt with on-demand mounting (it mounts the first time you access /mnt and unmounts after a period of inactivity):
    UUID=25f1305a-f6a8-4d37-a9ec-d1e391afed88 /mnt ext4 rw,noauto,user,x-systemd.automount,x-systemd.idle-timeout=300 0 0
    
    Note: replace the UUID with the unique identifier of your own volume.
  3. Reboot and verify. Reboot your instance:
    sudo reboot
    
    Access the mount point to check that the volume is mounted:
    cd /mnt
    
    Check that the volume is mounted:
    df -h
    

Common fstab fields

Field Description
<UUID> Describes the volume or remote filesystem UUID to be mounted. Obtain with lsblk for stability across reboots (device names can change).
<mount point> The directory where the filesystem will be mounted, i.e., the path to access files on the volume.
<type> The type of filesystem to be used (commonly ext4, xfs, ntfs, etc.).
<options> Additional metadata or parameters controlling how the filesystem is mounted (see “Options” table below).
<dump> If you need to dump the filesystem. Leave 0 if not needed.
<pass> Determines the order in which filesystem checks are done at boot. Leave 0 if no check is required.

Common fstab options

Option Description
auto / noauto Mount automatically at startup / don't mount automatically.
Note: For ScienceCloud instances, use noauto to avoid boot failures if the external volume is missing.
ro / rw Mount read-only / mount read-write.
user Allow non-root users to mount manually. Implies noexec, nosuid, nodev unless overridden. Default is to only allow root.
uid= / gid= Set the owner and group of files in the filesystem (default is uid=0, gid=0).
defaults Use default settings. Equivalent to rw,suid,dev,exec,auto,nouser,async. See mount documentation for details.
x-systemd.automount Mount the filesystem on first access rather than at boot. Creates a systemd automount unit.
x-systemd.idle-timeout=<s> Specifies the number of seconds of inactivity before automatically and cleanly unmounting the filesystem. See systemd.mount for more details.

Example: automount into pre-existing directory

To mount an external volume with UUID b411dc99-f0a0-4c87-9e05-184977be8539 into a pre-existing directory called /data, add this line to your /etc/fstab:

UUID=b411dc99-f0a0-4c87-9e05-184977be8539 /data ext4 rw,user,noauto,x-systemd.automount,x-systemd.idle-timeout=300 0 0
Note: replace the UUID with the unique identifier of your own volume.

The volume will be mounted automatically on demand when /data is accessed. It will be cleanly unmounted after 300 seconds of inactivity. This reduces the risk of inconsistencies after unexpected shutdowns or crashes because the filesystem is not always mounted.

Example: automount a network share with cifs

You can also use /etc/fstab to automatically mount a NAS network share. The following example shows how to mount a CIFS/SMB share from UZH that requires SMB version 3.0:

  1. Edit /etc/fstab. Add this line:
    //idnasXX.uzh.ch/g_my_department$/mydept/myname /home/ubuntu/myname cifs rw,credentials=/home/ubuntu/.credentials.smb,uid=ubuntu,vers=3.0,user,exec,noauto,x-systemd.automount,x-systemd.idle-timeout=300 0 0
    
    Replace idnasXX.uzh.ch/g_my_department$/mydept/myname with your actual network share path, and adjust /home/ubuntu/myname to the desired local mount point.
  2. Create a credentials file (/home/ubuntu/.credentials.smb) with your network share login info:
    username=share_user_name
    password=share_password
    domain=share_domain
    
    where domain: UZH.
  3. Secure permissions for the credentials file:
    chmod 500 /home/ubuntu/.credentials.smb
    
  4. Reload systemd units to apply fstab changes:
    sudo systemctl daemon-reload
    sudo systemctl restart remote-fs.target
    
    The share is not mounted at boot (noauto) but is mounted on first access due to x-systemd.automount. It will unmount automatically after 300 seconds of inactivity (x-systemd.idle-timeout=300). This setup prevents boot issues if the share is unavailable.

Safely detach a volume

Warning

Volumes must be unmounted from within the instance before being detached.

If you detach a mounted volume, the instance may freeze when it tries to access it.

To unmount a volume from the instance, run:

sudo umount /mnt
Once unmounted, you can safely detach the volume from the ScienceCloud Web Interface:
  1. On Volumes tab, select your volume.
  2. From drop-down Edit Volume list, select Manage Attachments.
  3. Select your volume
  4. Press Detach Volume.

Mismatch between Attached To and /dev/sd{x} or /dev/vd{x} inside the image

A mismatch between what is reported in the Attached To field on the ScienceCloud Web Interface and how the disk is seen inside the instance may occur. This may happen if the following sequence of operations have been performed:

  • a volume has been created
  • it has been then attached to an instance followed by a file system creation and mount
  • the volume has been detached without being unmounted
  • another volume has been attached.

In order to have the consistency back between the Attached To field and the disk inside the instance a reboot has to be performed.

Volume operations

Extend or resize a volume

To resize your volume, follow these steps:

  1. Safely detach the volume. First unmount the file system from your instance, and then detach the volume from the instance using the ScienceCloud Web Interface. If the file system is exported via NFS, see below regarding disabling the NFS server.
  2. Extend the volume size. In the ScienceCloud Web Interface, select the volume and click Extend Volume, and specify the new size.
  3. Reattach volume to running instance in the ScienceCloud Web Interface.
  4. Verify that the volume is attached. In the ScienceCloud Web Interface, open the Volume tab and check the Attached To and Size fields. Alternatively, log in to your instance and use lsblk to find the device name your volume is attached to. You should see entries like /dev/vd{x} or /dev/sd{x} with the new size, where {x} is a lowercase latin letter like a, b, etc.
  5. (Optional) Scan the file system for errors.
    sudo e2fsck -f /dev/sd{x}
    
  6. Resize the file system.
    sudo resize2fs /dev/sd{x}
    
  7. Mount the new file system.
    sudo mount /dev/sd{x} /path/mount/point
    
    If the file system is exported via NFS, see below regarding enabling the NFS server.
  8. Check the size of the file system.
    df -h
    

Note

You may need to wait a few minutes for all nodes to detect the newly mounted file system.

Special considerations for file systems exported via NFS

If the file system is exported via NFS, also ensure the disable / enable the NFS server:

After 1. Safely detach the volume, check if any files have been kept open by the system and then stop the NFS server:

lsof +D /path/to/mounting/directory
sudo service nfs-kernel-server stop

After 7. Mount the new file system, restart the NFS server:

sudo service nfs-kernel-server start

Delete volumes

When deleting a volume from the ScienceCloud Web Interface, you may see an error like:

Error: You are not allowed to delete volume

This usually occurs when a volume has one or more snapshots. OpenStack does not allow you to delete a volume that has existing snapshots.

You can confirm this using the OpenStack CLI command:

openstack volume delete <volume_id_or_name>
You may see an error like:
Failed to delete volume with name or ID <volume_id_or_name>: BadRequestException: 400
Invalid volume: Volume status must be available or error or error_restoring or error_extending or error_managing and must not be migrating, attached, belong to a group, have snapshots, awaiting a transfer, or be disassociated from snapshots after volume transfer.

Solution: delete any snapshots associated with the volume first, then delete the volume.

To find all snapshots associated with a specific volume in OpenStack, you can use the CLI:

openstack volume snapshot list --volume <volume_id_or_name>
where --volume <volume_id_or_name> filters the snapshots to only those created from the specified volume.

Volume transfer

Volumes can be transferred between projects.

Important

Only detached volumes with no snapshots that show as Status: Available can be transferred.

Important

After the transfer is complete, the volume will no longer be available to the original project.

Using the web interface

  1. Initiate Transfer
    • Navigate to Project → Volumes → Volumes. Locate the snapshot you want to convert.
    • Click on the Create Transfer button.
    • Give the transfer a name and click Create Volume Transfer.
    • Download the Transfer ID and Authorization Key, or click Download transfer credentials as a text file.
  2. Accept Transfer
    • In the other project, you or another user should navigate to Project → Volumes → Volumes.
    • On the actions menu above, select Accept Transfer
    • Paste in the Transfer ID and Authorization Key from the text file and click Accept Volume Transfer

Using the command line

Using the OpenStack CLI, you can transfer a volume directly between projects with the command openstack volume transfer request.

Further instructions can be found here.

Volume backup and recovery

Create snapshot

Using the web interface

To create volume snapshot, follow these steps:

  1. Safely detach the volume from an instance.
  2. On Volumes tab, select your volume.
  3. From drop-down Edit Volume list, select Create Snapshot.
  4. Enter: Snapshot Name.
  5. Click Create Volume Snapshot.

Using the command line

Alternatively, using OpenStack CLI commands:

openstack volume snapshot create --volume <volume_id_or_name> <snapshot_name>

List volume snapshots:

openstack volume snapshot list

Create backup

Note

Information for this section will be added as the new version of ScienceCloud evolves.