{"id":2732,"date":"2019-07-23T14:38:02","date_gmt":"2019-07-23T18:38:02","guid":{"rendered":"https:\/\/easy-admin.ca\/?p=2732"},"modified":"2019-07-23T15:46:00","modified_gmt":"2019-07-23T19:46:00","slug":"adding-a-hard-drive-in-centos-7","status":"publish","type":"post","link":"https:\/\/easy-admin.ca\/index.php\/2019\/07\/23\/adding-a-hard-drive-in-centos-7\/","title":{"rendered":"Adding a hard drive in Centos 7"},"content":{"rendered":"<p>Whether installing a new physical hard drive to a server or adding an additional disk to your cloud server or VPS, you\u2019ll need to configure CentOS to be able to use it.<\/p>\n<p>We\u2019re going to assume the drive is connected, so first of all, we need to find it.<\/p>\n<p>First of all, we need to know the naming convention your server is using for drives, and we can find this with the \u2018df\u2019 command.<\/p>\n<pre>[user@server ~] df\r\nFilesystem \u00a0 \u00a0 1K-blocks\u00a0 \u00a0 Used Available Use% Mounted on\r\n\/dev\/vda2 \u00a0 \u00a0 \u00a0 24733776 2521604\u00a0 20942668\u00a0 11% \/\r\n\/dev\/vda1\u00a0 \u00a0 \u00a0 \u00a0 1007512\u00a0 203260\u00a0 \u00a0 751824\u00a0 22% \/boot<\/pre>\n<p>The two lines above show that this particular server is using the vd* notation, but sd* is also used. \u00a0Here the primary drive, vda, has two partitions \u2013 vda1 and vda2.<\/p>\n<p>We can now use the following command to find other disks:<\/p>\n<pre>[user@server ~] <span style=\"color: #ff0000;\">ls -1 \/dev\/[sv]d[a-z]<\/span>\r\n\/dev\/vda\r\n\/dev\/vdb<\/pre>\n<p>We can see both our original disk, vda, and the new disk vdb. \u00a0Now to create a filesystem the new disk with the \u2018mkfs.ext4\u2019 utility.<\/p>\n<pre>[user@server ~] sudo mkfs.ext4 \/dev\/vdb<\/pre>\n<p>This will just take a few seconds.<\/p>\n<p>To use the new disk we now need to mount it. \u00a0When you\u2019ve decided where you want to mount the disk, first create that folder on your server. \u00a0We\u2019re going to use \u2018home2\u2019 for our disk.<\/p>\n<pre>[user@server ~] sudo mkdir \/home2<\/pre>\n<p>We can now mount the disk to that location:<\/p>\n<pre>[user@server ~] sudo\u00a0mount \/dev\/vdb \/home2<\/pre>\n<p>Revisiting the df command we can now see that the new disk is mounted.<\/p>\n<pre>[user@server ~] df\r\nFilesystem \u00a0 \u00a0 1K-blocks\u00a0 \u00a0 Used Available Use% Mounted on\r\n\/dev\/vda2 \u00a0 \u00a0 \u00a0 24733776 2521604\u00a0 20942668\u00a0 11% \/\r\n\/dev\/vda1\u00a0 \u00a0 \u00a0 \u00a0 1007512\u00a0 203260\u00a0 \u00a0 751824\u00a0 22% \/boot\r\n\/dev\/vdb \u00a0 \u00a0 \u00a0 \u00a025000000 \u00a0 \u00a0 100  24999900   1% \/home2<\/pre>\n<p>To ensure the disk is automatically mounted when the server is rebooted, we also need to add it to fstab. \u00a0Our preferred editor is \u2018nano\u2019 so we type<\/p>\n<pre>[user@server ~] sudo nano \/etc\/fstab<\/pre>\n<p>We add, to the end of the file, the line:<\/p>\n<pre>\/dev\/vdb \/home2 ext4 defaults 0 0<\/pre>\n<p>Then CTRL + O to save and CTRL + X to exit.<\/p>\n<p>The disk will now stay mounted after reboot and you can begin using it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Whether installing a new physical hard drive to a server or adding an additional disk to your cloud server or VPS, you\u2019ll need to configure CentOS to be able to use it. We\u2019re going to assume the drive is connected, so first of all, we need to find it. First of all, we need to &hellip; <a href=\"https:\/\/easy-admin.ca\/index.php\/2019\/07\/23\/adding-a-hard-drive-in-centos-7\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Adding a hard drive in Centos 7<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2732","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts\/2732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/comments?post=2732"}],"version-history":[{"count":0,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts\/2732\/revisions"}],"wp:attachment":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/media?parent=2732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/categories?post=2732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/tags?post=2732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}