{"id":11295,"date":"2019-03-12T22:58:28","date_gmt":"2019-03-12T22:58:28","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11295"},"modified":"2019-03-12T22:58:28","modified_gmt":"2019-03-12T22:58:28","slug":"how-to-add-a-new-disk-to-an-existing-linux-server","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/12\/how-to-add-a-new-disk-to-an-existing-linux-server\/","title":{"rendered":"How to Add a New Disk to an Existing Linux Server"},"content":{"rendered":"<p>As system administrators, we would have got requirements wherein we need to configure raw hard disks to the existing servers as part of upgrading server capacity or sometimes disk replacement in case of disk failure.<\/p>\n<p>In this article, I will take you through the steps by which we can add the new raw hard disk to an existing Linux server such as\u00a0<strong>RHEL<\/strong>\/<strong>CentOS<\/strong>\u00a0or\u00a0<strong>Debian<\/strong>\/<strong>Ubuntu<\/strong>.<\/p>\n<p><b>Suggested Read:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/add-disk-larger-than-2tb-to-an-existing-linux\/\" target=\"_blank\" rel=\"noopener\">How to Add a New Disk Larger Than 2TB to An Existing Linux<\/a><\/p>\n<p><strong>Important<\/strong>: Please note that the purpose of this article is to show only how to create a new partition and doesn\u2019t include partition extension or any other switches.<\/p>\n<p>I am using\u00a0<a href=\"https:\/\/www.tecmint.com\/fdisk-commands-to-manage-linux-disk-partitions\/\" target=\"_blank\" rel=\"noopener\">fdisk utility<\/a>\u00a0to do this configuration.<\/p>\n<p>I have added a hard disk of\u00a0<strong>20GB<\/strong>\u00a0capacity to be mounted as a\u00a0<code>\/data<\/code>\u00a0partition.<\/p>\n<p><strong>fdisk<\/strong>\u00a0is a command line utility to view and manage hard disks and partitions on Linux systems.<\/p>\n<pre># fdisk -l\r\n<\/pre>\n<p>This will list the current partitions and configurations.<\/p>\n<div id=\"attachment_25236\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Find-Linux-Partition-Details.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25236\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Find-Linux-Partition-Details.png\" alt=\"Find Linux Partition Details\" width=\"619\" height=\"351\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Find Linux Partition Details<\/p>\n<\/div>\n<p>After attaching the hard disk of\u00a0<strong>20GB<\/strong>\u00a0capacity, the\u00a0<code>fdisk -l<\/code>\u00a0will give the below output.<\/p>\n<pre># fdisk -l\r\n<\/pre>\n<div id=\"attachment_25237\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Find-New-Partition-Details.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25237\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Find-New-Partition-Details.png\" alt=\"Find New Partition Details\" width=\"639\" height=\"448\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Find New Partition Details<\/p>\n<\/div>\n<p>New disk added is shown as\u00a0<code>\/dev\/xvdc<\/code>. If we are adding physical disk it will show as\u00a0<code>\/dev\/sda<\/code>\u00a0based of the disk type. Here I used a virtual disk.<\/p>\n<p>To partition a particular hard disk, for example\u00a0<strong>\/dev\/xvdc<\/strong>.<\/p>\n<pre># fdisk \/dev\/xvdc\r\n<\/pre>\n<p>Commonly used fdisk commands.<\/p>\n<ul>\n<li><code>n<\/code>\u00a0\u2013 Create partition<\/li>\n<li><code>p<\/code>\u00a0\u2013 print partition table<\/li>\n<li><code>d<\/code>\u00a0\u2013 delete a partition<\/li>\n<li><code>q<\/code>\u00a0\u2013 exit without saving the changes<\/li>\n<li><code>w<\/code>\u00a0\u2013 write the changes and exit.<\/li>\n<\/ul>\n<p>Here since we are creating a partition use\u00a0<code>n<\/code>\u00a0option.<\/p>\n<div id=\"attachment_25238\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Create-New-Partition-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25238\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Create-New-Partition-in-Linux.png\" alt=\"Create New Partition in Linux\" width=\"553\" height=\"157\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Create New Partition in Linux<\/p>\n<\/div>\n<p>Create either primary\/extended partitions. By default we can have upto 4 primary partitions.<\/p>\n<div id=\"attachment_25239\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Create-Primary-Partition.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25239\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Create-Primary-Partition.png\" alt=\"Create Primary Partition\" width=\"397\" height=\"95\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Create Primary Partition<\/p>\n<\/div>\n<p>Give the partition number as desired. Recommended to go for the default value\u00a0<code>1<\/code>.<\/p>\n<div id=\"attachment_25240\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Assign-a-Partition-Number.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25240\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Assign-a-Partition-Number.png\" alt=\"Assign a Partition Number\" width=\"334\" height=\"23\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Assign a Partition Number<\/p>\n<\/div>\n<p>Give the value of the first sector. If it is a new disk, always select default value. If you are creating a second partition on the same disk, we need to add\u00a0<code>1<\/code>\u00a0to the last sector of the previous partition.<\/p>\n<div id=\"attachment_25241\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Assign-Sector-to-Partition.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25241\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Assign-Sector-to-Partition.png\" alt=\"Assign Sector to Partition\" width=\"401\" height=\"20\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Assign Sector to Partition<\/p>\n<\/div>\n<p>Give the value of the last sector or the partition size. Always recommended to give the size of the partition. Always prefix\u00a0<code>+<\/code>\u00a0to avoid value out of range error.<\/p>\n<div id=\"attachment_25242\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Assign-Partition-Size.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25242\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Assign-Partition-Size.png\" alt=\"Assign Partition Size\" width=\"621\" height=\"20\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Assign Partition Size<\/p>\n<\/div>\n<p>Save the changes and exit.<\/p>\n<div id=\"attachment_25243\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Save-Partition-Changes.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25243\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Save-Partition-Changes.png\" alt=\"Save Partition Changes\" width=\"674\" height=\"421\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Save Partition Changes<\/p>\n<\/div>\n<p>Now format the disk with\u00a0<strong>mkfs<\/strong>\u00a0command.<\/p>\n<pre># mkfs.ext4 \/dev\/xvdc1\r\n<\/pre>\n<div id=\"attachment_25244\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Format-New-Partition.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25244\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/03\/Format-New-Partition.png\" alt=\"Format New Partition\" width=\"718\" height=\"343\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Format New Partition<\/p>\n<\/div>\n<p>Once formatting has been completed, now mount the partition as shown below.<\/p>\n<pre># mount \/dev\/xvdc1 \/data\r\n<\/pre>\n<p>Make an entry in\u00a0<strong>\/etc\/fstab<\/strong>\u00a0file for permanent mount at boot time.<\/p>\n<pre>\/dev\/xvdc1\t\/data\text4\tdefaults     0   0\r\n<\/pre>\n<h5>Conclusion<\/h5>\n<p>Now you know how to partition a raw disk using\u00a0<a href=\"https:\/\/www.tecmint.com\/fdisk-commands-to-manage-linux-disk-partitions\/\" target=\"_blank\" rel=\"noopener\">fdisk command<\/a>\u00a0and mount the same.<\/p>\n<p>We need to be extra cautious while working with the partitions especially when you are editing the configured disks.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/add-new-disk-to-an-existing-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As system administrators, we would have got requirements wherein we need to configure raw hard disks to the existing servers as part of upgrading server capacity or sometimes disk replacement in case of disk failure. In this article, I will take you through the steps by which we can add the new raw hard disk &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/12\/how-to-add-a-new-disk-to-an-existing-linux-server\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Add a New Disk to an Existing Linux Server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11295","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11295"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11295\/revisions"}],"predecessor-version":[{"id":11296,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11295\/revisions\/11296"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}