{"id":292506,"date":"2021-07-07T02:31:00","date_gmt":"2021-07-06T23:31:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-add-a-new-drive-to-your-existing-linux-server-cloudsavvy-it\/"},"modified":"2021-07-07T02:31:00","modified_gmt":"2021-07-06T23:31:00","slug":"how-to-add-a-new-drive-to-your-existing-linux-server-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-add-a-new-drive-to-your-existing-linux-server-cloudsavvy-it\/","title":{"rendered":"#How To Add a New Drive to Your Existing Linux Server \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2cbbbd7abb8\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2cbbbd7abb8\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-add-a-new-drive-to-your-existing-linux-server-cloudsavvy-it\/#Install_The_Drive\" >Install The Drive<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-add-a-new-drive-to-your-existing-linux-server-cloudsavvy-it\/#Create_a_New_Filesystem\" >Create a New Filesystem<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-add-a-new-drive-to-your-existing-linux-server-cloudsavvy-it\/#Add_The_Mount_To_fstab\" >Add The Mount To fstab<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How To Add a New Drive to Your Existing Linux Server \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<figure style=\"width: 1400px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage wp-image-4382 size-full\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/12\/ff1bbaef.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"hard drive picture\" width=\"1400\" height=\"646\" src=\"https:\/\/www.shutterstock.com\/image-photo\/close-open-computer-hard-disk-drive-260972465\" data-credittext=\"Elya Vatel\/Shutterstock\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-photo\/close-open-computer-hard-disk-drive-260972465\">Elya Vatel\/Shutterstock<\/a><\/span><\/figcaption><\/figure>\n<p>If you\u2019ve got a hard drive you want to add to your Linux server, physical or virtual, it\u2019s not going to work out of the box. You\u2019ll have to initialize the drive with a filesystem, and set it to automatically mount at boot.<\/p>\n<p>This guide will focus on the basics for getting a new hard drive up and running on Linux. If you need more complex management, we recommend using <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/howto\/40702\/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu\/\">Logical Volume Management (LVM)<\/a> instead, which follows a different procedure. Among other things, this makes managing partitions on drives easier, and allows for easy resizing of logical volumes.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Install_The_Drive\"><\/span>Install The Drive<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>This may seem self explanatory, but it\u2019s not always as simple as just plugging it in. If you\u2019re installing a physical drive in a physical server, you may have to boot into your BIOS or RAID configuration utility to create a new\u00a0<em>logical drive<\/em> out of the physical drive you installed. This way, you can group multiple hard drives together into one large, uniform file system, or simply just use the single drive. If you\u2019re just using a single drive, RAID 0 is your only option. If you have two drives, RAID 1 is a better choice for durability. For three drives, RAID 5 is your best bet, and at four drives and above, RAID 10 or RAID 6 are both good options.<\/p>\n<p>If your RAID controller allows it, you may choose to add a new drive to your existing array and expand the total size. If this is an option, you don\u2019t need to do anything past setting it up with the RAID controller, though you may need to wait through an array rebuild depending on your configuration.<\/p>\n<p>If you\u2019re installing a drive into a cloud server, such as a new <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/aws.amazon.com\/ebs\/?tag=reviewgeek-20\">EBS volume<\/a>, you\u2019ll have to make sure the drive is initialized and is attached to your cloud server. The benefit of cloud drives like EBS is that it\u2019s fully managed; You don\u2019t have to worry about replacing problematic hard drives are dealing with RAID configuration, as that\u2019s all handled by AWS and is abstracted away from you. EBS volumes can also be sw<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ed between instances at will (though <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/aws.amazon.com\/efs\/?tag=reviewgeek-20\">EFS<\/a> is the only AWS drive type that can be attached to multiple instances at once).<\/p>\n<p>Either way, it will work the same way. You can verify that the drive is installed and working properly if a new block level device is found when running <code>lsblk<\/code>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3346\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/12\/43cb596b-1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"700\" height=\"244\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you want more information, you can also run <code>sudo fdisk -l<\/code>, but <code>lsblk<\/code>\u00a0makes for a better screenshot.<\/p>\n<p>Linux treats just about everything on the OS as a file you can write to, and drives are no different. The <code>\/dev\/<\/code>\u00a0folder contains\u00a0<em>device files<\/em>, which are a special interface to the drive hardware itself. Usually, your first drive will be <code>sda<\/code>, with all subsequent mounts coming in alphabetical order.<\/p>\n<pre>sda&#13;\nsdb&#13;\nsdc&#13;\n...<\/pre>\n<p>In this case, the primary OS drive is <code>sda<\/code>, with two partitions (denoted by a number after the drive prefix), one of which is mounted at the root of the file system. The second drive that was just installed is <code>sdb<\/code>, which isn\u2019t mounted and is just an empty disk, devoid of a filesystem. If you\u2019re installing a cloud drive, it will probably come in this same form too, entirely initialized and ready for whatever filesystem you choose to put on it.<\/p>\n<p><strong>A brief word of caution:<\/strong> We\u2019ll assume your drive is <code>sdb<\/code>\u00a0for the rest of this tutorial, since that\u2019s likely to be the default if you\u2019re installing a second drive. However, you\u2019ll want to be extra careful when entering commands, since you don\u2019t want to screw it up and mess with drives that have already been configured.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Create_a_New_Filesystem\"><\/span>Create a New Filesystem<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Since the drive doesn\u2019t have a filesystem, we can\u2019t use it for storing files. Not to worry, as a few commands will make quick work of that.<\/p>\n<p>If you want, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/106873\/how-to-use-fdisk-to-manage-partitions-on-linux\/\">you can partition your drive<\/a> before installing a filesystem. This is optional, as a filesystem can be installed directly to the device itself, which will act as one giant partition. If you\u2019re setting up a non-boot drive, chances are you probably want to make use of the entire thing, so unless you have a specific reason to partition, you can omit this step.<\/p>\n<p>To create a new filesystem on an empty volume, you\u2019ll want to use the aptly named <code>mkfs<\/code>\u00a0command:<\/p>\n<pre>sudo mkfs -t ext4 \/dev\/sdb<\/pre>\n<p>This creates a new <code>ext4<\/code>\u00a0filesystem on <code>sbd<\/code>. Linux has <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/howto\/33552\/htg-explains-which-linux-file-system-should-you-choose\/\">a lot of filesystem types<\/a>, all with varying support. <code>ext4<\/code>\u00a0is stable, and the default filesystem for Linux. After about 50 TB though, it starts to degrade in performance, and filesystems like ZFS and XFS start to become more viable options.<\/p>\n<p>Next, you\u2019ll want to create a mount point. This can be anywhere on your drive, so long as the folder is accessible. By default, Linux uses the <code>\/mnt\/<\/code>\u00a0directory for most temporary mounts, and <code>\/<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">media<\/a>\/<\/code>\u00a0for removable mounts like CDs, but that\u2019s just convention. Really, it doesn\u2019t matter where you mount it, just make a new folder for it:<\/p>\n<pre>sudo mkdir \/mnt\/newdrive<\/pre>\n<p>Make sure this mount folder has proper permissions. Now, you can mount and test the new drive with:<\/p>\n<pre>sudo mount \/dev\/sdb \/mnt\/newdrive<\/pre>\n<p>The drive should now be fully usable, and available from the mount location you\u2019ve chosen.<\/p>\n<p>However, this mount isn\u2019t permanent, and will not persist across reboots. Since that\u2019s obviously an issue for a hard drive, you\u2019ll have to add it to your <code>fstab<\/code>\u00a0file.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Add_The_Mount_To_fstab\"><\/span>Add The Mount To fstab<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><code>fstab<\/code>, or filesystem tab, keeps track of devices and their mount points. It\u2019s responsible for mounting your primary hard drive to <code>\/<\/code>, and any drive added here will become part of the OS in much the same way.<\/p>\n<p><strong>Another word of caution:<\/strong> errors in an <code>fstab<\/code>\u00a0file can cause the system to be unbootable, and unable to be fixed except from <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.andreydba.com\/unix-linux\/how-to\/how-to-fix-boot-failure-due-to-incorrect-etc-fstab\">grub mode<\/a>\u00a0or an external USB. This isn\u2019t a major issue, since you can check for errors before restarting, but you\u2019ll want to make sure to do so.<\/p>\n<p>Anyway, you\u2019ll probably want to back up <code>fstab<\/code>:<\/p>\n<pre>sudo cp \/etc\/fstab \/etc\/fstab.old<\/pre>\n<p>Rather than using the device label (like <code>\/dev\/sdb<\/code>) devices in <code>fstab<\/code>\u00a0must be added via UUID. This is because device order isn\u2019t guaranteed, and it\u2019s very possible for drive letter allocations to change, since they\u2019re added dynamically on startup and whenever drives are hot swapped. You can find your device\u2019s UUID with:<\/p>\n<pre>sudo blkid<\/pre>\n<p>Copy the UUID, and open up <code>fstab<\/code>:<\/p>\n<pre>sudo nano \/etc\/fstab<\/pre>\n<p>You\u2019ll want to add the following line, replacing the UUID with your own, and <code>\/mount\/point<\/code>\u00a0with your own mount point.<\/p>\n<pre>UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx \/mount\/point ext4 defaults,nofail 0 2<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3345\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/12\/cd176396.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"700\" height=\"140\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The <code>nofail<\/code>\u00a0option tells the OS that it\u2019s fine to boot without this drive, or if there are any errors in mounting. If it\u2019s imperative that your system always has this drive available, you\u2019ll want to remove this.<\/p>\n<p>Now, you\u2019ll want to check that there are no errors in <code>fstab<\/code>. Unmount the drive:<\/p>\n<pre>sudo umount \/mount\/point<\/pre>\n<p>And mount the drive using <code>fstab<\/code>:<\/p>\n<pre>sudo mount -a<\/pre>\n<p>If this completed with no errors, you\u2019re good to go. If not, you\u2019ll want to double check that your UUID and configuration is correct, and restore from the backup <code>fstab.old<\/code>\u00a0if you need to.\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/3349\/how-to-add-a-new-drive-to-your-existing-linux-server\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How To Add a New Drive to Your Existing Linux Server \u2013 CloudSavvy IT&#8221; Elya Vatel\/Shutterstock If you\u2019ve got a hard drive you want to add to your Linux server, physical or virtual, it\u2019s not going to work out of the box. You\u2019ll have to initialize the drive with a filesystem, and set it to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":292507,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/12\/ff1bbaef.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-292506","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/292506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=292506"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/292506\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/292507"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=292506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=292506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=292506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}