{"id":2329,"date":"2016-05-11T12:16:22","date_gmt":"2016-05-11T09:16:22","guid":{"rendered":"https:\/\/upcloud.com\/global\/us\/resources\/tutorials\/adding-removing-storage-devices\/"},"modified":"2016-05-11T12:16:22","modified_gmt":"2016-05-11T09:16:22","slug":"adding-removing-storage-devices","status":"publish","type":"tutorial","link":"https:\/\/upcloud.com\/global\/resources\/tutorials\/adding-removing-storage-devices\/","title":{"rendered":"Adding and removing storage devices"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Adding and removing storage disks on a&nbsp;cloud server at your&nbsp;<a rel=\"noopener\" href=\"https:\/\/hub.upcloud.com\/\">UpCloud Control Panel<\/a>&nbsp;is easy, but the changes also require actions on the operating system level. Whether you are looking to increase data storage or make other changes to the disk configurations, this guide will help you to perform the required operations on Linux and Windows hosts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The server must be powered down before attaching or removing storage devices.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/signup.upcloud.com\/\">Test hosting on UpCloud!<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Adding a new disk<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Start by logging into your&nbsp;<a rel=\"noopener\" href=\"https:\/\/hub.upcloud.com\/\">UpCloud Control Panel<\/a>. Shut down the server in question and&nbsp;go to the <i>Storage<\/i>&nbsp;tab in your server settings. Create a new disk by clicking the&nbsp;<em>Add new device<\/em>&nbsp;button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/current-storages.png\" alt=\"Current storage devices\" class=\"wp-image-5911 wpsmartcrop-image\" data-smartcrop-focus=\"[57,6]\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the disk configuration window, select the Create a new disk option,\u00a0and give the new disk a name\u00a0and size in gigabytes as\u00a0required. Then click\u00a0<em>Add\u00a0a storage device\u00a0<\/em>to confirm.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/add-new-25gb-device.png\" alt=\"Adding a new 25GB storage device\" class=\"wp-image-5912\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After the attaching process is complete, you can power the server up again.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/new-25gb-device.png\" alt=\"New 25GB device attached\" class=\"wp-image-5913\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once your server is up and running, you can continue with the process at the OS level. Find the operating system-specific instructions below for Linux distributions and Windows servers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Linux operations<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Connect to your server, for example, using SSH. Check the names of the storage disks currently attached with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">lsblk<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT\nvda 253:0 0 25G 0 disk\n\u2514\u2500vda1 253:1 0 25G 0 part \/\nvdb 253:16 0 25G 0 disk\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The disk you are looking for is usually the last on the list, and will not have partitions on it like <em>vdb<\/em> in the example above.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Partitioning and formatting the disk<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a new partition on the new disk using <em>fdisk.<\/em>&nbsp;Replace the <span style=\"color: #ff0000\"><em>disk<\/em><\/span>&nbsp;in the command below with the new disk name.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo fdisk \/dev\/<span style=\"color: #ff0000\">disk<\/span><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The utility will open its own command prompt showing <em>Command (m for help):<\/em> instead of the usual <em>user@host:\/$.<\/em> The following one-letter commands will be entered in the <em>fdisk<\/em>&nbsp;utility.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, start a new partition configuration with <em>n<\/em>. Use default values by just pressing enter on each of the options, or type in the required parameter if no default value is given.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt; n\n# Primary p, partition 1, start sector 2048, end sector at disk end.<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are looking to install an OS on the new disk, make it bootable with command <em>a<\/em>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt; a\n# Partition 1 if asked.<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Afterwards, you can check that the partition was configured properly, it should show something along the lines of the example underneath.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt; p\nDevice     Boot  Start  End       Sectors   Size  Id  Type\n\/dev\/vdb1  *     2048   52428799  52426752  25G   83  Linux<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If everything is in order, write partition changes to the disk with the command <em>w<\/em>. In case there was a mistake in the setup, delete the faulty partition by entering the command <em>d<\/em> and then create a new one again with command <em>n<\/em>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt; w<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once <em>fdisk<\/em> has finished writing the partition table to the disk it will exit and return you to the usual command prompt. Check that the new partition shows up using the <em>lsblk<\/em>&nbsp;command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">lsblk<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT\nvda    253:0    0  25G  0 disk\n\u2514\u2500vda1 253:1    0  25G  0 part \/\nvdb    253:16   0  25G  0 disk\n\u2514\u2500vdb1 253:17   0  25G  0 part<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should now see both storage disks and their partitions with their correct sizes. The disks will be named something like <em>vda<\/em> or <em>vdb<\/em> and their partitions with the added partition identifier number e.g. <em>vda1<\/em>\u00a0and\u00a0<em>vdb1<\/em>. Notice that some of the commands below require you to enter the disk name while others use the partitions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Set up the partition with a file system type appropriate for your server. Ubuntu and other Debian variants should use EXT4 while CentOS 7 hosts might be using XFS instead.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Creating an EXT4 file system on Debian, Ubuntu or CentOS 6.5\nsudo mkfs.ext4 \/dev\/<span style=\"color: #ff0000\">partition<\/span><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># Creating an XFS file system on CentOS 7.0\nsudo mkfs.xfs \/dev\/<span style=\"color: #ff0000\">partition<\/span><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With the formatting complete, you will next need to create a mounting point for the device.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Mounting a new disk manually<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Mounting a disk is as simple as making a new directory to which you wish to attach the disk, for example, <em>\/disk1<\/em>&nbsp;at your root directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo mkdir \/<span style=\"color: #ff0000\">disk1<\/span><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then, mount the new storage disk on your system at the mounting point you just created.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo mount \/dev\/<span style=\"color: #ff0000\">partition<\/span> \/<span style=\"color: #ff0000\">disk1<\/span><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The added storage space will now be available as a&nbsp;directory on your system.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df -h<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Filesystem  Size  Used  Avail  Use%  Mounted on\n\/dev\/vda1    25G  1.4G    23G    6%  \/\n\/dev\/vdb1    25G   44M    24G    1%  \/disk1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That is it, you can then start using the new storage space.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Remounting a new disk automatically<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To enable the new storage disk to mount automatically at boot, you still need to add it to the <tt>fstab<\/tt> file. The\u00a0<tt>fstab<\/tt>\u00a0file contains descriptive information about the various file systems on your server and needs to be maintained properly. Each file system is described on a separate line in the order they should be mounted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Start by checking the UUID of the new disk using the command below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">blkid<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\/dev\/vda1: UUID=\"9dbc7ddd-5c2b-4e66-b284-ffd3f146c80b\" TYPE=\"ext4\" PARTUUID=\"861dadf7-01\"\n\/dev\/vdb1: UUID=\"3dfce0f1-1c50-455d-adbc-16bd1c0560a2\" TYPE=\"ext4\" PARTUUID=\"3b9f0276-01\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Note down the UUID of the new disk, usually the last on the list. Most systems use the UUID to identify disk devices in the <tt>fstab<\/tt> file but the \/dev\/<span style=\"color: #ff0000\">partition<\/span> denomination would also work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, open the fstab file with your favourite text editor and add the new disk description similar to the examples according to your OS. Remember to set the &lt;UUID of the new disk&gt; like on the first line.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Below are shown examples of the&nbsp;<tt>fstab<\/tt>&nbsp;file from Ubuntu and CentOS.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># On Ubuntu or Debian\nnano \/etc\/fstab<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># &lt;file system&gt;                          &lt;mount point&gt; &lt;type&gt; &lt;options&gt;      &lt;dump&gt; &lt;pass&gt;\nUUID=9dbc7ddd-5c2b-4e66-b284-ffd3f146c80b \/             ext4   errors=remount-ro 0      1\nUUID=new_disk_uuid                        \/disk1        ext4   defaults          1      2<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># On CentOS\nvi \/etc\/fstab<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># &lt;file system&gt;                          &lt;mount point&gt; &lt;type&gt; &lt;options&gt; &lt;dump&gt; &lt;pass&gt;\nUUID=e0c76c31-e8c6-49a1-879c-238266e0fb07 \/             xfs    defaults  1      1\nUUID=new_disk_uuid                        \/disk1        xfs    defaults  1      2<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once you have added the description of the new disk device, save the file and exit the editor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">All done! The new disk will now be always automatically mounted at boot.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Windows operations<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Start by opening the <em>Disk Management<\/em>\u00a0panel by\u00a0right-clicking the Windows Start button and selecting Disk Management from the appearing list. Alternatively, type\u00a0diskmgmt.msc\u00a0in the search or run window and then press enter.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The newly attached storage device should be listed as the&nbsp;last disk in the bottom part of the window. Start by right-clicking the new&nbsp;disk and selecting&nbsp;<em>Online<\/em> to enable the device.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/windows_bring_disk_online.png\" alt=\"Windows bring disk online\" class=\"wp-image-6632\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Next, you will need to initialize it by right-clicking the disk&nbsp;and selecting <em>Initialize Disk<\/em>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/windows_initialize_disk_manually.png\" alt=\"Windows initialize disk manually\" class=\"wp-image-6633\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the next window, initialize the newly attached disk by selecting <em>MBR<\/em> and clicking OK.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/windows_initialize_disk.png\" alt=\"Windows initialize disk\" class=\"wp-image-6634\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Before the new disk can be accessed you will need to format it. Right-click the unallocated partition and select <em>New Simple Volume.<\/em>&nbsp;Go through the wizard, the default options are fine for most cases.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/windows_new_simple_volume.png\" alt=\"Windows create new volume\" class=\"wp-image-6635\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The formatting might take a moment depending on the size of the new volume. You can continue using the server normally until the process is completed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/windows_new_volume_ready.png\" alt=\"Windows new volume ready\" class=\"wp-image-6636\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once the volume creation wizard is done formatting the new partition, the device will show a blue indicator and report the status as\u00a0<em>Healthy<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Done!&nbsp;You can then start using the added storage space as usual.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Unmounting a disk<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Detaching a storage disk is a considerably simpler process than attaching one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To ensure data integrity on your cloud server after the detachment, check that the host does not have active services using the disk&nbsp;being removed. Once you are sure it is safe to detach the device proceed with the steps below for either Linux or Windows hosts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Linux<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Unmount the disk being removed with the command underneath.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo umount <span style=\"color: #ff0000\">mounting_point<\/span>\n# For example\nsudo umount \/disk1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are permanently removing a disk that was configured to automount at boot, you will also need to remove the disk in question from the <tt>fstab<\/tt> file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># On Ubuntu and Debian\nnano \/etc\/fstab\n# Or on CentOS\nvi \/etc\/fstab<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Delete the line describing the disk you want to remove. These are usually easiest to identify according to their mounting points. Then save the file and exit the editor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then, shut down your server either with the Shutdown request at your control panel&nbsp;or by using the command below in your server terminal.<\/p>\n\n\n\n<pre id=\"unmount-from-windows\" class=\"wp-block-preformatted\">sudo shutdown -h now<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When the server is powered down, continue to your <a href=\"https:\/\/hub.upcloud.com\" target=\"_blank\" rel=\"noopener\">UpCloud control panel<\/a>&nbsp;to remove the disk.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Windows<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the <em>Disk Management<\/em>\u00a0panel by\u00a0right-clicking the Windows Start button and selecting Disk Management from the appearing list. Alternatively, type\u00a0diskmgmt.msc\u00a0in the search or run window and then press enter.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Right-click the disk you wish to remove and select Offline to turn off the device.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/windows_make_disk_offline.png\" alt=\"Windows unmount disk\" class=\"wp-image-6637\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Shut down your server at Windows over a Remote Desktop Connection or through the web console at your <a href=\"https:\/\/hub.upcloud.com\" target=\"_blank\" rel=\"noopener\">UpCloud control panel<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Detaching a disk<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">With your server powered down, go to your <a href=\"https:\/\/hub.upcloud.com\" target=\"_blank\" rel=\"noopener\">UpCloud control panel<\/a>&nbsp;and open the&nbsp;<em>Storage<\/em>&nbsp;tab under the server settings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are two ways of removing storage disks.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Detaching a disk simply frees the storage to be attached again and keeps the data for later use.<\/li>\n\n\n\n<li>Deleting a disk removes the device from the server and deletes the data permanently.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Scheduled backups will continue even while the disk is detached according to the\u00a0settings and retention time. Any backups made from the original storage disk are retained when deleting devices and can be used to restore deleted storage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click the&nbsp;eject&nbsp;icon on the&nbsp;storage you wish to remove but not delete.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/detaching-storage-6.png\" alt=\"Detaching storage device\" class=\"wp-image-5914\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively, if you are sure to not need the device any longer, you can click the bin icon to delete the storage device permanently.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/deleting-storage.png\" alt=\"Deleting storage device\" class=\"wp-image-5915\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once the removal operation is complete, you can&nbsp;start up your server again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are later confident that your cloud server runs as it should without the removed device, you can delete the detached\u00a0storage at your UpCloud control panel in the <a rel=\"noopener\" href=\"https:\/\/hub.upcloud.com\/storage\" target=\"_blank\">Storage<\/a>\u00a0section.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","community-category":[283,265,247],"class_list":["post-2329","tutorial","type-tutorial","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/types\/tutorial"}],"author":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/comments?post=2329"}],"version-history":[{"count":0,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2329\/revisions"}],"wp:attachment":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/media?parent=2329"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/community-category?post=2329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}