How To Access Your Created Volume


After you have created and attached your Block Storage volume, you must prepare it for use on your server by partitioning the drive, formatting it, and mounting it. After you have successfully completed these steps, your volume is usable as a drive on your server.

Prerequisites

To use this guide, you should have a Cloud Server spun up already, with a block storage volume already attached.

Click here to learn how to attach your volume.

Choose the appropriate tab for Linux® or Microsoft® Windows®:

Prepare the volume for use on a Linux server

Use the following steps to prepare your Block Storage volume for use on a Linux server:

  • Connect to your server.

Use SecureShell (SSH) to log in to your server.

  • List the disks on your server.

Run fdisk -l to list the disks on your server. Your volume is typically listed as the last drive in the list. fdisk is also used to create a partition on your volume.

Note

As you can see in the following example output, /dev/xvdb has not been partitioned as it does not have /dev/xvdb1 listed.

  
      
  fdisk -l
  (out)Disk /dev/xvda: 40 GiB, 42949672960 bytes, 83886080 sectors
  (out)Units: sectors of 1 * 512 = 512 bytes
  (out)Sector size (logical/physical): 512 bytes / 512 bytes
  (out)I/O size (minimum/optimal): 512 bytes / 512 bytes
  (out)Disklabel type: dos
  (out)Disk identifier: 0x072148a1
  (out)
  (out)Device     Boot Start      End  Sectors Size Id Type
  (out)
  (out)**/dev/xvda1 *     2048 83875364 83873317  40G 83 Linux**
  (out)
  (out)Disk /dev/xvdb: 75 GiB, 80530636800 bytes, 157286400 sectors
  (out)Units: sectors of 1 * 512 = 512 bytes
  (out)Sector size (logical/physical): 512 bytes / 512 bytes
  (out)I/O size (minimum/optimal): 512 bytes / 512 bytes

  
  • Partition the disk.

Note

The Block Storage volume is referred to as a disk because this is specific for the volume on this operating system.

  • Run fdisk /dev/xvdb, substituting your drive for /dev/xvdb.
  
      
  fdisk /dev/xvdb
  (out)Changes remain in memory only until you decide to write them.
  (out)Be careful before using the write command.
  (out)
  (out)Device does not contain a recognized partition table.
  (out)Created a new DOS disklabel with disk identifier 0x6c78fd7d.
  (out)
  (out)Command (m for help):

  

Warning

Ensure that you do not partition a drive that has already been partitioned. This will cause data loss.

  • Enter n to create a new partition.

    • Enter p to indicate a primary partition.

    • To create only one partition on this disk, enter 1.

    • To accept the default start cylinder, which is 1, press Enter.

    • To accept the default end cylinder, press Enter.

This should return something similar to:

  
      
  (out)Created a new partition 1 of type 'Linux' and of size 75 GiB

  
  • To check the information for the partition you just created, enter p.
  
      
  (out)Disk /dev/xvdb: 75 GiB, 80530636800 bytes, 157286400 sectors
  (out)Units: sectors of 1 * 512 = 512 bytes
  (out)Sector size (logical/physical): 512 bytes / 512 bytes
  (out)I/O size (minimum/optimal): 512 bytes / 512 bytes
  (out)Disklabel type: dos
  (out)Disk identifier: 0x6c78fd7d
  (out)
  (out)Device     Boot Start       End   Sectors Size Id Type
  (out)/dev/xvdb1       2048 157286399 157284352  75G  0 Empty

  
  • To change the disklabel type, enter t.

  • Type L to view all the disk label types.

  • Enter 83 for the type (Linux).

  • Then enter p.

Notice that the Id and Type fields have changed.

  
      
  (out)Device     Boot Start       End   Sectors Size Id Type
  (out)/dev/xvdb1       2048 157286399 157284352  75G 83 Linux

  
  • Enter w to write the partition.

This returns:

  
      
  (out)The partition table has been altered.
  (out)Calling ioctl() to re-read partition table.
  (out)Syncing disks.

  

You have now created a partition on the drive.

  • Examine your volume.

Use fdisk -l to list the disks on your server again. Your Block Storage volume is ready to use as a disk. It was attached at /dev/xvdb and you created on partition on it, so your available disk appears at /dev/xvdb1.

  
      
  fdisk -l
  (out)Disk /dev/xvda: 40 GiB, 42949672960 bytes, 83886080 sectors
  (out)Units: sectors of 1 * 512 = 512 bytes
  (out)Sector size (logical/physical): 512 bytes / 512 bytes
  (out)I/O size (minimum/optimal): 512 bytes / 512 bytes
  (out)Disklabel type: dos
  (out)Disk identifier: 0x072148a1
  (out)
  (out)Device     Boot Start      End  Sectors Size Id Type
  (out)
  (out)/dev/xvda1 *     2048 83875364 83873317  40G 83 Linux
  (out)
  (out)Disk /dev/xvdb: 75 GiB, 80530636800 bytes, 157286400 sectors
  (out)Units: sectors of 1 * 512 = 512 bytes
  (out)Sector size (logical/physical): 512 bytes / 512 bytes
  (out)I/O size (minimum/optimal): 512 bytes / 512 bytes
  (out)Disklabel type: dos
  (out)Disk identifier: 0x6c78fd7d
  (out)
  (out)Device     Boot Start       End   Sectors Size Id Type
  (out)
  (out)/dev/xvdb1       2048 157286399 157284352  75G 83 Linux

  
  • Format the volume.

Formatting the volume enables the server to use it to store information. The following example uses the ext4 file system. However, you can use any file system supported by your kernel.

  • ext4 is the fourth extended file system. It is now the current default for Linux kernels. Improvements that were made with ext4 include larger file systems, extents, and journaling, backward compatibility with ext2 and ext3, and an unlimited number of subdirectories.

  • ext3 is the third extended file system. It is a previous generation journaled file system that was commonly used as a default file system for Linux kernels. It eliminated the need to check the file system after an unclean shutdown. The current ext4 builds on these improvements.

Run mkfs -t ext4 /dev/xvdb1 to format the drive.

  
      
  mkfs -t ext4 /dev/xvdb1
  (out)mke2fs 1.42.12 (29-Aug-2014)
  (out)Creating filesystem with 19660544 4k blocks and 4915200 inodes
  (out)Filesystem UUID: 68b809f1-8c0e-4425-a79e-a650301f0db9
  (out)Superblock backups stored on blocks:
  (out)32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
  (out)4096000, 7962624, 11239424
  (out)
  (out)Allocating group tables: done
  (out)Writing inode tables: done
  (out)Creating journal (32768 blocks): done
  (out)Writing superblocks and filesystem accounting information: done

  
  • Mount the volume.

After partitioning and formatting the volume, you must mount it on the server, and then you can use it.

You need to create a mount point (directory) for the block-storage volume.

  
      
  mkdir -p /data
  mount /dev/xvdb1 /data
  df -h
  (out)
  (out)/dev/xvdb1       74G   52M   70G   1% /data

  

Now, your drive is ready for use with your Linux server. However, we strongly recommend performing the following step to ensure that your drive remains persistent after a server reboot.

  • Make the volume persistent.

This step keeps your volume attached after server restarts.

Add your volume and mount point to the static file system maintained in the /etc/fstab file.

Note

In /etc/fstab, add the _netdev option for your drive to prevent attempts to mount the volume before all networking is running.

For this example, edit /etc/fstab and add the following line after the /dev/xvda1 entry:

  
      
  /dev/xvdb1 /data ext4 defaults,noatime,_netdev,nofail 0 2

  

Now the volume persists on the server after the server restarts.

Note

If you ever decide to move the volume to a different server, begin by unmounting the volume. Once unmounted, detach the volume, attach the volume to the new server, and mount it.

Click here to learn how to detach your volume.

Prepare the volume for use on a Microsoft Windows server

Use the following steps to prepare your Block Storage volume for use on a Windows server:

  • Connect to your server.

Use Remote Desktop Protocol (RDP) to log in to your server.

  • Click the Start button.

  • Click Administrative Tools.

  • Click Computer Management.

  • Click Disk Management -> Storage.

  • This displays a view of the current drives attached to your server. There is normally a system drive (C:). Do not select this drive as this is your system drive because selecting it will cause data loss.

  • The new Block Storage drive is identified as disk(X) where X is a number, and it is identified as an unknown type of disk.

  • Right click in the panel where it lists the disk number and unknown type of disk.

  • Select Online.

The information does not change to Not Initialized.

  • Right click in the same panel and select initialize disk.

  • Select the default setting MBR in the new window.

  • Click next.

After the drive is initialized, the new drive shows as Online.

  • In the panel that lists the drive as unallocated, right rick and select New Simple Volume.

This brings up the New Simple Volume Wizard.

  • Click next.

Normally, for a simple setup of the Block Storage volume, you should accept the defaults the New Simple Volume Wizard provides.

  • The next page enables you to assign a drive letter to the new disk. Select the default or provide a letter.

  • Click next.

  • On the Filesystem type page, we recommend that you select NTFS. Accept the default allocation unit size and create a specific volume label for the disk. It is always a good idea to create a volume label for this drive for its intended usage.

  • Click next and finalize the setup.

After the New Simple Volume Wizard completes, the new disk has a volume name, size, type of filesystem and is labeled as Healthy (Primary Partition).

You can start using the new Block Storage volume.

Note

If you decide to detach the Block Storage volume, you must place the disk offline prior to detaching it in the Control Panel. The Block Storage volume does not detach if the Operating System maintains control of it.

To place the disk offline, perform the preceding steps 1 - 7 but select offline instead of online.

Note

If you ever decide to move the volume to a different server, begin by unmounting the volume. Once unmounted, detach the volume, then attach the volume to the new server and simply mount it. Do not initialize or format the Block Storage volume as that destroys all data on the volume.

Click here to learn how to detach your volume.


Related Content