{"id":551,"date":"2019-08-20T15:32:08","date_gmt":"2019-08-20T15:32:08","guid":{"rendered":"https:\/\/server-help.org\/?p=551"},"modified":"2019-08-20T15:46:41","modified_gmt":"2019-08-20T15:46:41","slug":"add-block-storage-to-cloud-server-with-linux","status":"publish","type":"post","link":"https:\/\/server-help.org\/index.php\/2019\/08\/20\/add-block-storage-to-cloud-server-with-linux\/","title":{"rendered":"Add Block Storage to Cloud Server with Linux"},"content":{"rendered":"\n<p>After creating a Block Storage volume in the Cloud Panel and assigning it to a server, Linux servers will need to be configured to access the new Block Storage. Learn how to add Block Storage to a Cloud Server with Linux.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Scenario 1: Assign Block Storage as Separate Storage<\/h4>\n\n\n\n<p> Connect to the server with SSH, then use the <code>lsblk<\/code> command to list all available block storage devices: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost ~]# lsblk\nNAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT\nsda               8:0    0  120G  0 disk\n\u251c\u2500sda1            8:1    0    1G  0 part \/boot\n\u2514\u2500sda2            8:2    0  119G  0 part\n  \u251c\u2500centos-root 253:0    0  117G  0 lvm  \/\n  \u2514\u2500centos-swap 253:1    0    2G  0 lvm  &#91;SWAP]\nsdb               8:16   0  200G  0 disk\nsr0              11:0    1 1024M  0 rom<\/code><\/pre>\n\n\n\n<p><strong>NOTE<\/strong> The Block Storage \ndevice will only need to be formatted the first time you use it. If you \ndetach the Block Storage device then attach it to another server, <strong>do not<\/strong> format the device.<\/p>\n\n\n\n<p>Formatting the Block Storage device will erase all data on the device.<\/p>\n\n\n\n<p>Use the following command to format the Block Storage device:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost ~]# mkfs.&lt;File-System> &lt;Block Storage Name><\/code><\/pre>\n\n\n\n<p>In this case we will format our Block Storage with XFS File System:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost ~]# mkfs.xfs \/dev\/sdb<\/code><\/pre>\n\n\n\n<p>Now, we need to create a mount point for the Block Storage.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost ~]# mkidr \/mnt\/block<\/code><\/pre>\n\n\n\n<p>Next, we mount the Block Storage to our mount point \/mnt\/block<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost ~]# mount \/dev\/sdb \/mnt\/block<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"> Scenario 2: Assign Block Storage to Extend Server disk space.<\/h4>\n\n\n\n<p> Connect to the server with SSH, then use the <code>lsblk<\/code> command to list all available block storage devices:  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost ~]# lsblk\nNAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT\nsda               8:0    0  120G  0 disk\n\u251c\u2500sda1            8:1    0    1G  0 part \/boot\n\u2514\u2500sda2            8:2    0  119G  0 part\n  \u251c\u2500centos-root 253:0    0  117G  0 lvm  \/\n  \u2514\u2500centos-swap 253:1    0    2G  0 lvm  &#91;SWAP]\nsdb               8:16   0  200G  0 disk\nsr0              11:0    1 1024M  0 rom<\/code><\/pre>\n\n\n\n<p> Use the following command to format the Block Storage device: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost ~]# mkfs.xfs \/dev\/sdb<\/code><\/pre>\n\n\n\n<p>Now, we need create a Partition for our Block Storage using <strong>fdisk<\/strong>, in order to create Physical Volume Group. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost mnt]# fdisk \/dev\/sdb\nWelcome to fdisk (util-linux 2.23.2).\n\nChanges will remain in memory only, until you decide to write them.\nBe careful before using the write command.\n\nDevice does not contain a recognized partition table\nBuilding a new DOS disklabel with disk identifier 0xfc537643.\n\nCommand (m for help): p\n\nDisk \/dev\/sdb: 214.7 GB, 214748364800 bytes, 419430400 sectors\nUnits = sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk label type: dos\nDisk identifier: 0xfc537643\n\n   Device Boot      Start         End      Blocks   Id  System\n\nCommand (m for help): n\nPartition type:\n   p   primary (0 primary, 0 extended, 4 free)\n   e   extended\nSelect (default p): p\nPartition number (1-4, default 1):\nFirst sector (2048-419430399, default 2048):\nUsing default value 2048\nLast sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):\nUsing default value 419430399\nPartition 1 of type Linux and of size 200 GiB is set\n\nCommand (m for help): p\n\nDisk \/dev\/sdb: 214.7 GB, 214748364800 bytes, 419430400 sectors\nUnits = sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk label type: dos\nDisk identifier: 0xfc537643\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sdb1            2048   419430399   209714176   83  Linux\n\nCommand (m for help): t\nSelected partition 1\nHex code (type L to list all codes): 8e\nChanged type of partition 'Linux' to 'Linux LVM'\n\nCommand (m for help): p\n\nDisk \/dev\/sdb: 214.7 GB, 214748364800 bytes, 419430400 sectors\nUnits = sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk label type: dos\nDisk identifier: 0xfc537643\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sdb1            2048   419430399   209714176   8e  Linux LVM\n\nCommand (m for help): w\nThe partition table has been altered!\n\nCalling ioctl() to re-read partition table.\nSyncing disks.\n&#91;root@localhost mnt]# partprobe\n<\/code><\/pre>\n\n\n\n<p>Now, we create Physical Volume Group.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost mnt]# pvcreate \/dev\/sdb1<\/code><\/pre>\n\n\n\n<p>Then we list our Physical Volume Groups:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost mnt]# pvdisplay\n  --- Physical volume ---\n  PV Name               \/dev\/sda2\n  VG Name               centos\n  PV Size               &lt;119.00 GiB \/ not usable 2.00 MiB\n  Allocatable           yes (but full)\n  PE Size               4.00 MiB\n  Total PE              30463\n  Free PE               0\n  Allocated PE          30463\n  PV UUID               3yclEq-3Vje-FkPd-X8NU-Mj8t-ZTcA-skrzFm\n\n  \"\/dev\/sdb1\" is a new physical volume of \"&lt;200.00 GiB\"\n  --- NEW Physical volume ---\n  PV Name               \/dev\/sdb1\n  VG Name\n  PV Size               &lt;200.00 GiB\n  Allocatable           NO\n  PE Size               0\n  Total PE              0\n  Free PE               0\n  Allocated PE          0\n  PV UUID               YlRvcQ-IvYT-6D9A-jrdI-bzPV-IFc7-FCJqxA\n<\/code><\/pre>\n\n\n\n<p>Then, we need to Extend our existing Volume Group, the existing Volume Group name is <strong>centos<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost mnt]# vgextend centos \/dev\/sdb1\nVolume group \"centos\" successfully extended<\/code><\/pre>\n\n\n\n<p>Finally, we proceed with Extending our centos Volume Group.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost mnt]# lvextend -l +100%FREE \/dev\/mapper\/centos-root<\/code><\/pre>\n\n\n\n<p>Then, we apply File System changes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@localhost mnt]# xfs_growfs \/dev\/mapper\/centos-root<\/code><\/pre>\n\n\n\n<p>Now the Server disk has been Extended.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After creating a Block Storage volume in the Cloud Panel and assigning it to a server, Linux servers will need to be configured to access the new Block Storage. Learn how to add Block Storage to a Cloud Server with Linux. Scenario 1: Assign Block Storage as Separate Storage Connect to the server with SSH,&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,4,1],"tags":[],"_links":{"self":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/551"}],"collection":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/comments?post=551"}],"version-history":[{"count":4,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/551\/revisions"}],"predecessor-version":[{"id":556,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/551\/revisions\/556"}],"wp:attachment":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/media?parent=551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/categories?post=551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/tags?post=551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}