{"id":3120,"date":"2015-06-26T10:53:37","date_gmt":"2015-06-26T08:53:37","guid":{"rendered":"https:\/\/contabo.com\/blog\/?p=3120"},"modified":"2021-12-21T14:48:49","modified_gmt":"2021-12-21T13:48:49","slug":"mounting-additional-hard-disks-linux","status":"publish","type":"post","link":"https:\/\/contabo.com\/blog\/mounting-additional-hard-disks-linux\/","title":{"rendered":"Mounting of additional hard disks in Linux"},"content":{"rendered":"<p>In this tutorial, we are going to mount an additional hard disk in Linux.<\/p>\n<p>If you\u2019re not sure about your admin rights, always enter the command sudo -i at the beginning of every session:<\/p>\n<blockquote><p><strong>sudo -i<\/strong><\/p><\/blockquote>\n<p>This command will grant you the rights of a power user, so you don\u2019t have to write the command sudo at the beginning of every command line.<\/p>\n<p>At first, we list all the disks recognized by our system using the fdisk command:<\/p>\n<blockquote><p><strong>fdisk -l<\/strong><\/p><\/blockquote>\n<p><a href=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/fdisk.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3121\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/fdisk.png\" alt=\"fdisk\" width=\"503\" height=\"250\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/fdisk.png 503w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/fdisk-300x149.png 300w\" sizes=\"auto, (max-width: 503px) 100vw, 503px\" \/><\/a><\/p>\n<p>In our example, two hard drives are plugged into our server: <strong>\/dev\/sda<\/strong>, our system disk which amongst other things contains the operating system, and <strong>\/dev\/sdb<\/strong>, an additional 50 GiB hard drive which we are about to mount in our system. The naming of those disks can vary.<\/p>\n<p>First of all, we need to create a partition as well as a partition table. Of course, it is possible to create more than one partition on a disk, but in our example, we want to use the whole capacity of the drive for one partition. For the partitioning we use <strong>cfdisk<\/strong>, the graphical version of <strong>fdisk<\/strong>:<\/p>\n<blockquote><p><strong>cfdisk \/dev\/sdb<\/strong><\/p><\/blockquote>\n<p>If there is no existing partition table on the disk, yet, a menu pops up:<\/p>\n<p><a href=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/dosgptneu.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3145 size-full\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/dosgptneu.png\" alt=\"\" width=\"456\" height=\"239\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/dosgptneu.png 456w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/dosgptneu-300x157.png 300w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/a><\/p>\n<p>For our example, we choose <strong>dos<\/strong>, which writes a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Master_boot_record\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">MBR partition table<\/a> to the disk (for disks larger than 2 TB, we would choose GPT, otherwise we would not be able to make use of the entire available disk space). After that, the main menu of <strong>cfdisk <\/strong>opens:<\/p>\n<p><a href=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3124\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk2.png\" alt=\"cfdisk2\" width=\"643\" height=\"383\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk2.png 643w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk2-300x179.png 300w\" sizes=\"auto, (max-width: 643px) 100vw, 643px\" \/><\/a><\/p>\n<p>Here we can create our partition(s). We create a 50 GiB partition by entering <strong>50G <\/strong>and confirming with the <strong>Enter-Key<\/strong>.<\/p>\n<p><a href=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3125\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk3.png\" alt=\"cfdisk3\" width=\"641\" height=\"382\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk3.png 641w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk3-300x179.png 300w\" sizes=\"auto, (max-width: 641px) 100vw, 641px\" \/><\/a><\/p>\n<p>In the next dialogue, we choose <strong>primary <\/strong>to create a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Disk_partitioning#Primary_partition\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">primary partition<\/a>.<\/p>\n<p><a href=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3127 size-full\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk6.png\" alt=\"\" width=\"642\" height=\"386\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk6.png 642w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/cfdisk6-300x180.png 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><\/a><\/p>\n<p>We confirm with <strong>Write <\/strong>and type in <strong>yes <\/strong>to finish creating the partition.<\/p>\n<p>Now we have a partition, but we cannot store data on it yet, as we still need to create a <a href=\"http:\/\/en.wikipedia.org\/wiki\/File_system\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">file system<\/a> on it. We choose <strong>Quit <\/strong>to leave <strong>cfdisk <\/strong>and check if the partition has been created properly. To do so, we once again use fdisk:<\/p>\n<blockquote><p><strong>fdisk -l<\/strong><\/p><\/blockquote>\n<p><a href=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/fdisk2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3128\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/fdisk2.png\" alt=\"fdisk2\" width=\"517\" height=\"344\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/fdisk2.png 517w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/fdisk2-300x200.png 300w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/a><\/p>\n<p>Our new partition is now listed as\u00a0<strong>\/dev\/sdb1<\/strong>. Thus, everything went as expected.<br \/>\nNow, we&#8217;re going to format the partition with a file system. In Linux, we choose <strong><a href=\"http:\/\/en.wikipedia.org\/wiki\/Ext4\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">ext4<\/a> <\/strong>by default.<\/p>\n<blockquote><p><strong>mkfs.ext4 \/dev\/sdb1<\/strong><\/p><\/blockquote>\n<p><a href=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/mkfs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3129\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/mkfs.png\" alt=\"mkfs\" width=\"634\" height=\"213\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/mkfs.png 634w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/05\/mkfs-300x101.png 300w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><\/a><\/p>\n<p>The formatting is now finished and the hard disk is now prepared for utilisation. Next, we create a folder in which we mount the partition. All data we move or create in this folder after the whole procedure will be stored on our new hard drive. In our example, we use the name <strong>datastore <\/strong>for our folder, but of course you are free to choose any name you like. With the following command, we create the new folder:<\/p>\n<blockquote><p><strong>mkdir \/datastore<\/strong><\/p><\/blockquote>\n<p>In order to mount the partition in the folder we just created, we type the following in our command line:<\/p>\n<blockquote><p><strong>mount \/dev\/sdb1 \/datastore<\/strong><\/p><\/blockquote>\n<p>Our partition is now mounted in <strong>\/datastore<\/strong>. In order to automatically mount the partition after a reboot, we add a line in the configuration file <strong>\/etc\/fstab<\/strong>. But before we do so, we need to find out the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Universally_unique_identifier\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">UUID<\/a> of our partition.<\/p>\n<blockquote><p><strong>blkid \/dev\/sdb1<\/strong><\/p><\/blockquote>\n<p><a href=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/06\/blkid.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3146\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/06\/blkid.png\" alt=\"blkid\" width=\"717\" height=\"17\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/06\/blkid.png 717w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/06\/blkid-300x7.png 300w\" sizes=\"auto, (max-width: 717px) 100vw, 717px\" \/><\/a><\/p>\n<p>The part after &#8220;UUID=&#8221; is the UUID of our partition. We copy it (without the quotation marks) and open <strong>\/etc\/fstab <\/strong>in a text editor:<\/p>\n<blockquote><p><strong>nano \/etc\/fstab<\/strong><\/p><\/blockquote>\n<p>With the arrow keys, we navigate our cursor to the end of the file and paste the following line:<\/p>\n<blockquote><p><strong>UUID=d6ae62ff-c9b7-4a07-aea8-a36f55c5036d \u00a0\u00a0\u00a0\u00a0\u00a0 \/datastore\u00a0\u00a0\u00a0\u00a0\u00a0 ext4\u00a0\u00a0\u00a0 defaults \u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/strong><\/p><\/blockquote>\n<p><a href=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/06\/fstab3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3152 size-full\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/06\/fstab3.png\" alt=\"\" width=\"781\" height=\"183\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/06\/fstab3.png 781w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/06\/fstab3-300x70.png 300w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2015\/06\/fstab3-768x180.png 768w\" sizes=\"auto, (max-width: 781px) 100vw, 781px\" \/><\/a><\/p>\n<p>Make sure to replace the UUID with your actual one.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we are going to mount an additional hard disk in Linux. If you\u2019re not sure about your admin rights, always enter the command sudo -i at the beginning of every session: sudo -i This command will grant you the rights of a power user, so you don\u2019t have to write the command [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[18],"tags":[181,404,510,548,735,894],"ppma_author":[1501],"class_list":["post-3120","post","type-post","status-publish","format-standard","hentry","category-tutorials","tag-contabo","tag-hard-disk","tag-linux","tag-mount","tag-server","tag-vps"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Florian","author_link":"https:\/\/contabo.com\/blog\/author\/florian\/"},"uagb_comment_info":0,"uagb_excerpt":"In this tutorial, we are going to mount an additional hard disk in Linux. If you\u2019re not sure about your admin rights, always enter the command sudo -i at the beginning of every session: sudo -i This command will grant you the rights of a power user, so you don\u2019t have to write the command&hellip;","authors":[{"term_id":1501,"user_id":15,"is_guest":0,"slug":"florian","display_name":"Florian","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/8c45fdc066bed646e72c993402d3bf888e58da85474a9695881eac30fdec47b4?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts\/3120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/comments?post=3120"}],"version-history":[{"count":0,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts\/3120\/revisions"}],"wp:attachment":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/media?parent=3120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/categories?post=3120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/tags?post=3120"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=3120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}