How to Create and Set Up Volumes for Use with Droplets

To create and use a new volume with a Droplet, you need to create the volume itself, and then format and mount it to prepare it for use. Formatting and mounting is automatic by default for Droplets with supported operating systems, and you can choose to format and mount manually.

To start creating a volume from the control panel, open the Create menu and select Volumes. You can also create and attach a new volume as you create a new Droplet, in the Droplet create page’s Add block storage section.

Create menu

Select Volume Size

In the Select Volume Size section, choose the size of the volume, either by selecting a preset size or entering a size in gigabytes.

The select volume size section of the volume creation window

You can increase the size of a volume after you create it.

Select Droplet to Attach To and Name Volume

In the next section, choose the Droplet that you want to attach the volume to and enter a name for the volume. Volumes are located in the same datacenter and project as their associated Droplets.

The select Droplet to attach to and name volume sections of the volume creation window

You can create a volume while creating a new Droplet, in the Add block storage section of the Droplet create page. Volumes you create this way have automatically generated names and are attached to the new Droplet, so the Select Droplet to Attach To and Name Volume sections do not display from the Droplet create page.

Choose Configuration Options

In the Choose Configuration Options section, you choose how you want to format and mount the new volume.

The choose configuration options section of the volume creation window

A newly-created volume has no filesystem, which is what lets a Droplet’s operating system read and write files to it. Formatting a volume creates a filesystem on it (and erases any existing data). You only need to format a volume once, when you first create it. Mounting a formatted volume makes its filesystem accessible to its Droplet. You need to mount the volume every time you attach it to a Droplet.

You can automatically format and mount volumes to Droplets with supported operating systems, and this option is selected by default when it is available. You can always choose to manually format and mount volumes.

Automatically Format & Mount

When you automatically format and mount a volume, you also choose a filesystem. ext4 is the default because of its stability, backwards compatibility, and mature support and tooling. XFS, which specializes in performance for large data files, is also available.

Automatic mounting uses systemd on distributions that support it. The mount unit files are /etc/systemd/system/mnt-volume_*.mount. The udev rules that control the configuration are in /etc/udev/rules.d/99-digitalocean-automount.rules.

On non-systemd distributions, automatic mounting uses fstab, following the same commands and options provided in the control panel’s instructions for manual formatting and mounting.

Volumes are auto-mounted into the /mnt directory with the options defaults,nofail,discard,noatime.

Note
When automatically creating mount points, we replace hyphens with underscores in the volume name. This is because systemd mount unit files use hyphens as separators instead of forward slashes, and for consistency, we match this behavior even on older distributions without systemd.

Manually Format & Mount

If you choose to manually format and mount your volume, you can use the Droplet-specific directions in the volume’s More menu under Config instructions.

Volume more menu

The instructions include three customized commands that you can copy and paste into a terminal from your local machine:

  1. SSH to your Droplet, which includes the SSH command with the Droplet’s IP address filled in. If you disabled root logins or use CoreOS, FreeBSD, or RancherOS, you need to substitute the appropriate user for root.

  2. Format the volume: One time only, which includes the commands to set up a filesystem with the Droplet’s IP address and the SCSI ID of the volume pre-filled. This command specifies ext4 for the filesystem. To use XFS, If you prefer, change mkfs.ext4 to mkfs.xfs.

  3. Mount the volume, which includes the commands to create a mount point, mount the volume, and set the volume to automatically mount when you reboot. The specific SCSI ID of the volume is pre-filled.

Create Volume

After you’ve chosen all necessary settings, click Create Volume to create the volume. Once the volume is formatted and mounted, it is ready to use.

If a Droplet is in a volume-supported datacenter, the Droplet’s Volumes page lets you create and manage its volumes. You can manage all the volumes associated with your account on the Volumes page:

Volumes overview page in the control panel

After creation, you can move volumes between Droplets and increase the size of volumes.