How to Use Block Storage with Your Linode

Updated , by Linode

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Try this guide to receive $100 at signup on a new account.

Linode’s Block Storage service allows you to attach additional storage Volumes to your Linode. A single Volume can range from 10 GiB to 10,000 GiB in size and costs $0.10/GiB per month. They can be partitioned however you like and can accommodate any filesystem type you choose.

You can attach up to eight Volumes per Linode. Both your Linode plan’s standard disks and Block Storage Volumes count towards this total, including swap devices. The volumes can be newly created or already existing, so you do not need to recreate your server to add a Block Storage Volume.

The Block Storage service is currently available in the Dallas, Fremont, Frankfurt, London, Newark, Tokyo, Toronto, Mumbai, Singapore, and Sydney data centers.

Caution
  • Linode’s backup services do not cover Block Storage Volumes. You must execute your own backups for this data.

  • Your Linode must be running in Paravirtualization mode. Block storage currently does not support Full-virtualization.

How to Add a Block Storage Volume to a Linode

This guide assumes a Linode with the root disk mounted as /dev/sda and swap space mounted as /dev/sdb. In this scenario, the Block Storage Volume will be available to the operating system as /dev/disk/by-id/scsi-0Linode_Volume_EXAMPLE, where EXAMPLE is a label you assign the Volume in the Linode Cloud Manager. Storage Volumes can be added when your Linode is already running, and will show immediately in /dev/disk/by-id/.

Note
A Linode can have multiple Block Storage Volumes attached to it. However, a Block Storage Volume can only be attached to one Linode at a time.

Add a Volume from the Linode Detail Page

Follow these steps to create a new Block Storage Volume, attach it to your Linode, create a filesystem, and mount your Volume:

  1. Click on the Linodes link in the sidebar.

  2. Select the Linode to which you want to attach a Block Storage Volume. The detail page for the Linode will appear.

  3. Click on the Volumes tab, then click Add a Volume:

  4. Assign the Block Storage Volume a label and size. The label can be up to 32 characters long and consist only of ASCII characters a-z; 0-9.-_. The maximum Volume size is 10,000 GiB. When finished, click Submit:

    Note
    There is currently a soft limit of 100 TB of Block Storage Volume per account.
  5. Once you add a Volume it will appear under Attached Volumes with the new Volume’s label, size, and file system path.

  6. You’ll need to create a filesystem in your new Volume. If your Linode is not already running, boot then SSH into your Linode and execute the following command, where FILE_SYSTEM_PATH is your Volume’s file system path:

    mkfs.ext4 FILE_SYSTEM_PATH
    
    Caution

    If a new filesystem is created on a Block Storage Volume that is already using a filesystem, the above command will result in data loss. You can safely check for the filesystem of an unmounted volume with the following command:

    blkid FILE_SYSTEM_PATH
    

    If you do not receive output, there is currently no filesystem on this volume.

  7. Once the Volume has a filesystem, you can create a mountpoint for it:

    mkdir /mnt/BlockStorage1
    
  8. You can then mount the new Volume:

    mount FILE_SYSTEM_PATH /mnt/BlockStorage1
    
  9. If you want to mount the new Volume automatically every time your Linode boots, you’ll want to add the following line to your /etc/fstab file:

    FILE_SYSTEM_PATH /mnt/BlockStorage1 ext4 defaults 0 2
    
    Note

    If you plan on detaching the volume regularly or moving it between other Linodes, you may want to consider adding the flags noatime and nofail to the /etc/fstab entry.

    • noatime - This will save space and time by preventing writes made to the filesystem for data being read on the volume.
    • nofail - If the volume is not attached, this will allow your server to boot/reboot normally without hanging at dependency failures if the volume is not attached.

    Example:

    FILE_SYSTEM_PATH /mnt/BlockStorage1 ext4 defaults,noatime,nofail 0 2
    

Attach a Volume from Your Account’s Volume List

Follow these steps to attach a Block Storage Volume that was previously created in the Cloud Manager or through the Linode API.

  1. Click on the Volumes link in the sidebar to see your account’s Volume list:

  2. Click the more options ellipsis to open the menu for the Volume you want to attach to a Linode and select Attach:

  3. Select the label of the Linode you want to attach the Volume to from the dropdown menu, then click Save:

    Note
    The Linodes available in this dropdown menu all share the same region as your Volume.
  4. You’ll need to create a filesystem in your new Volume if it does not already have one. If you have created a filesystem previously for this volume on any Linode, you should skip this step. If your Volume does not have a filesystem and it is not already running, boot then SSH into your Linode and execute the following command, where FILE_SYSTEM_PATH is your Volume’s file system path:

    mkfs.ext4 FILE_SYSTEM_PATH

    Caution

    If a new filesystem is created on a Block Storage Volume that is already using a filesystem, the above command will result in data loss. You can safely check for the filesystem of an unmounted volume with the following command:

    blkid FILE_SYSTEM_PATH
    

    If you do not receive output, there is currently no filesystem on this volume.

  5. Provided the Volume has a filesystem, you can create a mountpoint for it:

    mkdir /mnt/BlockStorage1
    
  6. You can then mount the new Volume, where FILE_SYSTEM_PATH is your Volume’s file system path:

    mount FILE_SYSTEM_PATH /mnt/BlockStorage1
    
  7. If you want to mount the new Volume automatically every time your Linode boots, you’ll want to add the following line to your /etc/fstab file:

    FILE_SYSTEM_PATH /mnt/BlockStorage1
    

How to Detach a Block Storage Volume from a Linode

Follow these steps to safely detach a Block Storage Volume from a Linode. A Volume should be detached before it is reattached to a different Linode:

  1. Go to the detail page page of the Linode which the Volume is attached to. Shut down the Linode.

  2. When the Linode is powered off, click on the Volumes tab, click the more options ellipsis next to the Volume you would like to detach, then click Detach.

  3. A confirmation screen appears and explains that the Volume will be detached from the Linode. Click Detach to confirm:

    The Linode’s dashboard does not show the Volume present anymore:

    The Volume still exists on your account and you can see it if you view the Volumes page:

Caution

If a volume is currently mounted, detaching it while the Linode is powered on could cause data loss or an unexpected reboot. You can unmount the volume for safe live-detaching using the umount command:

umount /dev/disk/by-id/scsi-0Linode_Volume_BlockStorage1

To avoid additional issues with your Linode, remove the detached volume’s line from your /etc/fstab/ configuration:

FILE_SYSTEM_PATH /mnt/BlockStorage1 ext4 defaults 0 2

How to Delete a Block Storage Volume

Follow these steps to delete a Block Storage Volume from the Cloud Manager:

Caution
The removal process is irreversible, and the data will be permanently deleted.
  1. Shut down the attached Linode.

  2. Detach the Volume.

  3. On the Volumes page, click the more options ellipsis next to the Volume you would like to delete.

  4. Click Delete.

How to Resize a Block Storage Volume

Follow these steps to increase the size of a Block Storage Volume after it has been created:

Note
Storage Volumes cannot be sized down, only up. Keep this in mind when sizing your Volumes.
  1. Shut down your Linode.

  2. Click the more options ellipsis next to the Volume you would like to resize to bring up the Volume’s menu.

  3. Click Resize.

  4. Enter the new Volume size. The minimum size is 10 GiB and maximum is 10,000 GiB. Then click Submit.

  5. You’ll be returned to the Volume list and the notification bell in the top right of the page will notify you when the resizing is complete.

  6. Reboot your Linode.

  7. Once your Linode has restarted, make sure the Volume is unmounted for safety:

    umount /dev/disk/by-id/scsi-0Linode_Volume_BlockStorage1
    
  8. Assuming you have an ext2, ext3, or ext4 partition,first run a file system check:

    e2fsck -f /dev/disk/by-id/scsi-0Linode_Volume_BlockStorage1
    
  9. Then resize it to fill the new Volume size:

    resize2fs /dev/disk/by-id/scsi-0Linode_Volume_BlockStorage1
    
  10. Mount your volume back onto the filesystem:

    mount /dev/disk/by-id/scsi-0Linode_Volume_BlockStorage1 /mnt/BlockStorage1
    

How to Transfer a Volume to a New Linode

Follow these steps to safely detach a Volume from a Linode and attach it to a different Linode in the same data center:

Note
Volumes cannot be attached to Linodes that are in a different data center. See the Transfer Block Storage Data between Data Centers how-to for help with migrating data on a Volume to a different data center.
  1. Safely detach the Volume.

  2. Click the more options ellipsis to open the menu for the Volume you want to attach to a Linode and select Attach:

![Open Volume menu](bs-cloud-attach-volume.png "Open Volume menu")
  1. Since the Volume already has a filesystem on it, create a mountpoint for the new Linode, provided it hasn’t already been created:

    mkdir /mnt/BlockStorage1

  2. Mount the new Volume, where FILE_SYSTEM_PATH is your Volume’s file system path:

    mount FILE_SYSTEM_PATH /mnt/BlockStorage1

  3. If you want to mount the new Volume automatically every time your Linode boots, you’ll want to add the following line to your /etc/fstab file:

    FILE_SYSTEM_PATH /mnt/BlockStorage1 ext4 defaults 0 2
    

How to Transfer Block Storage Data Between Data Centers

Block Storage Volumes cannot be directly migrated to a different data center. These steps will outline how to transfer a Volume’s data to a different data center via the SCP tool.

Note
Consult our Network Transfer Quota guide for information on charges related to outbound traffic when downloading Linode data outside of Linode’s private network.
  1. Attach and mount your Block Storage Volume to a Linode, if you have not already.

  2. Use the Secure Copy Protocol (SCP) to download your Volume’s data to the receiving computer or Linode.

    Note
    You will need a device that has enough storage capacity to receive the entirety of your Block Storage Volume’s data.
  3. Once your Block Storage Volume’s data has been copied, create a new Block Storage Volume in the desired data center and attach it to a Linode.

  4. Use SCP to upload the data from the receiving computer or Linode to the new Block Storage Volume. The new Block Storage Volume must be attached and mounted to a Linode.

Where to Go From Here?

Need ideas for what to do with space? We have several guides which walk you through installing software that would make a great pairing with large storage Volumes:

This page was originally published on


Your Feedback Is Important

Let us know if this guide made it easy to get the answer you needed.