How to Unmount Volumes

Block storage volumes are network-based block devices that provide additional data storage for Droplets. You can move them between Droplets and resize them at any time.

Unmounting a volume makes its filesystem inaccessible to its Droplet's operating system. This means the OS can't write to or read from the volume. You should unmount volumes before resizing or detaching them to protect data integrity.

There are three steps to unmounting a volume:

  1. Get the volume's mount point with df if you don't already know it:

    sudo df --human-readable --print-type
    

    The mount point will look like /mnt/volume-sfo2-01:

      
        
        Filesystem     Type      Size  Used Avail Use% Mounted on
        . . . 
        /dev/sda       ext4       99G   60M   94G   1% /mnt/volume-sfo2-01
        . . . 
        
      
    
  2. Make sure the volume isn't in use. If you try to unmount a volume while it's in use, you'll get a target is busy error, so check if any processes are using the mounted filesystem with lsof:

    sudo lsof +f -- /mnt/use_your_mount_point
    

    Stop any listed processes.

  3. Unmount the volume with umount.

    sudo umount --verbose /mnt/use_your_mount_point
    

    Including the --verbose flag makes the command output /mnt/your_mount_point unmounted when it executes successfully. Otherwise, umount is silent on successful execution.

If you won't reattach the volume in the future, you can do some additional cleanup:

  1. Edit /etc/fstab to remove any entries referencing the volume.

  2. Delete the mount point:

    sudo rmdir /mnt/use_your_mount_point
    

Once the volume is unmounted, you can safely resize or detach it.