Customizing Ephemeral Drive Mounting
Customize how the ephemeral drive is mounted on your VM using cloud-init.
Ephemeral drives provide temporary storage for active workloads during a VM's runtime. You can customize how the drive is mounted at VM creation time by passing a cloud-init configuration file. This guide covers mounting to a custom path, changing the filesystem format, and preventing the mount entirely. It also shows how to apply any of these configurations through the API. For background on ephemeral storage, see Ephemeral Storage.
The ephemeral drive provides temporary storage for the active workload during the virtual machine's runtime. Its data is lost when the virtual machine is hibernated or deleted. Before hibernating or deleting the virtual machine, back up any critical data to a Shared Storage Volume, as described in How to Save Ephemeral Data.
Mounting ephemeral drive to a custom location
By default, ephemeral drives are mounted under /ephemeral. To mount the drive at a different path, pass a cloud-init configuration at VM creation time.
-
Navigate to the Virtual Machines page in the Hyperstack console and click Deploy New Virtual Machine.
-
Configure your VM with the desired specifications, then scroll to the bottom of the page and click Configure Additional Settings.
-
In the Cloud-init Script section, select YAML syntax format, then paste the following configuration. Replace
/your/custom/pathwith the directory where you want to mount the drive, such as/var/opt:#cloud-config
mounts:
- [ephemeral0, /your/custom/path] -
Deploy the VM. The ephemeral drive mounts to your specified path during creation.
Changing filesystem format and mount location
To format the ephemeral drive with a different filesystem (such as xfs) and mount it to a custom location, follow the console steps in Mounting to a custom location, but paste the following configuration instead:
#cloud-config
disk_setup:
ephemeral0:
table_type: "gpt"
layout: true
overwrite: True
fs_setup:
- label: ephemeral0
filesystem: xfs
device: "ephemeral0"
partition: "auto"
overwrite: True
mounts:
- [ephemeral0, /data, xfs]
Choosing not to mount the ephemeral drive
To prevent the ephemeral drive from being mounted, follow the console steps in Mounting to a custom location, but paste the following configuration instead:
#cloud-config
mounts:
- [ephemeral0, null]
Using the API to manage ephemeral mounting
-
Save your cloud-init configuration in a file named
user_data.txt. The example below writes the XFS configuration using a bash heredoc:cat << EOF > user_data.txt
#cloud-config
disk_setup:
ephemeral0:
table_type: "gpt"
layout: true
overwrite: True
fs_setup:
- label: ephemeral0
filesystem: xfs
device: "ephemeral0"
partition: "auto"
overwrite: True
mounts:
- [ephemeral0, /data, xfs]
EOF -
Pass the file contents in the
user_datafield of the Create Virtual Machine API request. Replaceyour-environment,your-flavor, andyour-keypairwith your own values:# Convert the cloud-init script to a single-line JSON string user_data_content=$(jq -Rs '.' < user_data.txt) # Create the VM with the cloud-init configuration curl --location 'https://infrahub-api.Hyperstack.com/v1/core/virtual-machines' \ --header 'Content-Type: application/json' \ --header "api_key: $API_KEY" \ --data '{ "name": "ephemeral-mount-example", "environment_name": "your-environment", "image_name": "Ubuntu Server 24.04 LTS R570 CUDA 12.8 with Docker", "flavor_name": "your-flavor", "key_name": "your-keypair", "count": 1, "assign_floating_ip": true, "user_data": '"'"'$user_data_content'"'"' }' -
After the VM reaches
ACTIVEstatus, connect over SSH and verify the mount:lsblk -fThe output shows the ephemeral drive (
vdb) formatted asxfsand mounted at/data(output varies based on flavor and configuration):NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
...
vdb
└─vdb1 xfs ephemeral0 aefb82e5-f27c-4b33-9d58-b65eb32ffd35 744.4G 1% /data