Managing Instance Ephemeral Storage
Overview
Ephemeral disks are available on certain VM instance types. Please refer to VM overview page for details.
Lifecycle
Ephemeral disks have no redundancy. Ephemeral disks have a lifecycle that is tied to the server associated with a given virtual machine. The disks are erased when the physical server reboots, or the VM is stopped and restarted, or if there are any other hardware or software failures causing the virtual machine to move or shut down. They are only suitable for use cases where data loss is tolerable, even if they are configured in a storage cluster like MinIO, Lustre or Ceph. If your data has a need to be protected, please back it up on an external disk like persistent or shared disk.
Note: if a VM is restarted from within the VM (e.g. using sudo reboot now
) rather than by stopping and restarting the VM from the UI, CLI, or API, the disks will not be erased.
Formatting and Mounting Ephemeral Disks
Below is a script you can add to your startup scripts to automatically detect the number of ephemeral disks and create an ext4
file system mounted at the /nvme
path. If multiple ephemeral disks are found, the script will create an unprotected RAID0
array of the disks for additional performance benefits, mounted at the /raid0
path.
#!/bin/bash
apt update && apt install -y nvme-cli mdadm
num_nvme=`nvme list | grep -i /dev | wc -l`
if [[ $num_nvme -eq 1 ]]; then
dev_name=`nvme list | grep -i /dev | awk '{print $1}'`
mkfs.ext4 $dev_name
mkdir /nvme && mount -t ext4 /dev/nvme0n1 /nvme
elif [[ $num_nvme -gt 1 ]]; then
dev_name=`nvme list | grep -i /dev | awk '{print $1}'`
mdadm --create --verbose /dev/md127 --level=0 --raid-devices=$num_nvme $dev_name
mkfs.ext4 /dev/md127
mkdir /raid0 && mount -t ext4 /dev/md127 /raid0
else
echo "no ephemeral drives detected"
fi