Volumes¶
Create volume¶
- Log in to ScienceCloud Web Interface: https://cloud.science-it.uzh.ch.
- Go to Project → Volumes → Volumes.
- Click Create Volume.
- Enter: Volume Name and Size (GB).
- Click Create Volume.
Manage volumes on instances¶
Attach a volume to an instance¶
- On Volumes tab, select your volume.
- From drop-down Edit Volume list, select Manage Attachments.
- From Attach to Instance list, choose the instance you wish to attach the volume to.
- 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.
- 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 likea
,b
, etc. Alternatively, use the following commands inside your instance to list all block devices attached to the instance:orlsblk
sudo parted -l
- Format the volume (if new/empty). Format your new disk into ext4 (recommended file system). or
sudo mkfs.ext4 /dev/vd{x}
Replacesudo mkfs.ext4 /dev/sd{x}
{x}
with the correct device name. - Mount the volume. Once the volume has a file system, mount it using:
sudo mount /dev/vd{x} /mnt
- Verify the mount. You should see a line starting with
df -h
/dev/vd{x}
or/dev/sd{x}
. - 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¶
- Identify the volume and UUID. Run the following to list block devices, their UUIDs, and filesystems: Note the UUID of the volume you want to mount. Using UUIDs is recommended because device names (like
sudo lsblk -o NAME,FSTYPE,UUID,SIZE,LABEL
/dev/sdb
) may change across reboots. - Edit
/etc/fstab
. Open/etc/fstab
in your preferred editor:Append a line for your volume using this format (each element is separated by whitespace):sudo vim /etc/fstab
For example, to mount an<UUID> <mount point> <type> <options> <dump> <pass>
ext4
volume at/mnt
with on-demand mounting (it mounts the first time you access/mnt
and unmounts after a period of inactivity):Note: replace the UUID with the unique identifier of your own volume.UUID=25f1305a-f6a8-4d37-a9ec-d1e391afed88 /mnt ext4 rw,noauto,user,x-systemd.automount,x-systemd.idle-timeout=300 0 0
- Reboot and verify. Reboot your instance: Access the mount point to check that the volume is mounted:
sudo reboot
Check that the volume is mounted:cd /mnt
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
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:
- Edit
/etc/fstab
. Add this line:Replace//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
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. - Create a credentials file (
/home/ubuntu/.credentials.smb
) with your network share login info:whereusername=share_user_name password=share_password domain=share_domain
domain
:UZH
. - Secure permissions for the credentials file:
chmod 500 /home/ubuntu/.credentials.smb
- Reload systemd units to apply fstab changes: The share is not mounted at boot (
sudo systemctl daemon-reload sudo systemctl restart remote-fs.target
noauto
) but is mounted on first access due tox-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
- On Volumes tab, select your volume.
- From drop-down Edit Volume list, select Manage Attachments.
- Select your volume
- 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:
- 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.
- Extend the volume size. In the ScienceCloud Web Interface, select the volume and click Extend Volume, and specify the new size.
- Reattach volume to running instance in the ScienceCloud Web Interface.
- 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 likea
,b
, etc. - (Optional) Scan the file system for errors.
sudo e2fsck -f /dev/sd{x}
- Resize the file system.
sudo resize2fs /dev/sd{x}
- Mount the new file system. If the file system is exported via NFS, see below regarding enabling the NFS server.
sudo mount /dev/sd{x} /path/mount/point
- 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>
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>
--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¶
- 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.
- 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:
- Safely detach the volume from an instance.
- On Volumes tab, select your volume.
- From drop-down Edit Volume list, select Create Snapshot.
- Enter: Snapshot Name.
- 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.