How to Create and Attach Volumes

You can create and attach new volumes in four main contexts:

  • From the Droplet creation page
  • From the Create menu
  • From a Droplet’s Volumes page.
  • From the Droplets link in the main navigation, under the Volumes tab.

No matter how you create a new volume, before it’s ready for use for the first time, you’ll need to format and mount it.

Create a New Volume

You can create a new volume at any time by using the Create menu.

Create menu

You can manage all the volumes associated with your account by following the Volumes link:

Volumes menu item in the control panel

During Droplet Creation

You can create and attach a new volume or attach an existing volume at the same time you create a Droplet in the Add block storage section. When you choose to add a volume, the selection of regions for the Droplet will be automatically limited to those regions where block storage is available.

For Existing Droplets

When you’ve already created a Droplet and it is located in a region with block storage support, you can create and manage volumes on its Volumes page:

Volumes page for a Droplet with no volumes

Format and Mount Volumes

When you first create a new volume, you will need to format it to create a file system. You generally only have to do this once because formatting a volume erases all the data on it. Every time you attach a formatted volume to a Droplet, you will need to mount it so your Droplet can access it.

Automatically

You can choose to automatically format and mount a volume for first-time use on supported distributions. When auto-mounting is available, it is selected by default. Otherwise, it will be grayed out and the manual option will be selected.

Add a volume window

By default, Ext4 is selected as the default filesystem because of its stability, backwards compatibility, and mature support and tooling. You can also choose XFS, which specializes in performance for large data files.

Regardless of which filesystem you choose, the volume will be auto-mounted into the /mnt directory with the options defaults,nofail,discard,noatime.

Automatic mounting is done via systemd on distributions that support it. You can find the mount unit files at /etc/systemd/system/mnt-volume_*.mount and the udev rules that control the configuration at /etc/udev/rules.d/99-digitalocean-automount.rules.

On non-systemd distributions, like Ubuntu 14.04, Debian 7, and CentOS 6, automatic mounting is done via fstab using the same commands and options that are provided in the control panel’s instructions for manual formatting and mounting.

Manually

You can manually format and mount all volumes. Droplet-specific directions are available in the volume’s More menu under Config instructions.

Volume more menu

These customized directions have three parts that you can copy to paste directly into a terminal from your local machine. The three parts are:

  1. SSH to your Droplet, which includes the SSH command with the Droplet’s IP address filled in.

    If you’ve disabled root logins or are working with CoreOS, FreeBSD, or RancherOS, you’ll 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. Generally, this is a one-time-only task; when you format a volume it destroys all existing data.

    By default, this command uses the Ext4 filesystem. If you prefer, you can use the same commands to format the volume with XFS by changing 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.

Once a volume is formatted and mounted, it is ready to use.