{"id":3816,"date":"2018-01-23T18:32:39","date_gmt":"2018-01-23T18:32:39","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=3816"},"modified":"2018-01-23T18:32:39","modified_gmt":"2018-01-23T18:32:39","slug":"add-second-hard-drive-linux","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2018\/01\/23\/add-second-hard-drive-linux\/","title":{"rendered":"Add second hard drive to linux"},"content":{"rendered":"<p>Here is how to add a second disk to linux. In this article, the OS is CentOS 7.<\/p>\n<p>Check to see how many drives are installed: You can do this using the df and fdisk command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# df -h\nFilesystem                     Size  Used Avail Use% Mounted on\n\/dev\/mapper\/centos_plesk-root   14G  3.9G   10G  29% \/\ndevtmpfs                       910M     0  910M   0% \/dev\ntmpfs                          920M  4.0K  920M   1% \/dev\/shm\ntmpfs                          920M  8.6M  912M   1% \/run\ntmpfs                          920M     0  920M   0% \/sys\/fs\/cgroup\n\/dev\/sda1                      497M  215M  282M  44% \/boot\ntmpfs                          184M     0  184M   0% \/run\/user\/1000\n\n<\/pre>\n<p>The above information show the primary disk as sda.<\/p>\n<p>Use fdisk to identify the second drive:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# fdisk -l\n\nDisk \/dev\/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000ab095\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *        2048     1026047      512000   83  Linux\n\/dev\/sda2         1026048    33554431    16264192   8e  Linux LVM\n\nDisk \/dev\/sdb: 17.2 GB, 17179869184 bytes, 33554432 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\n\n<\/pre>\n<p>The sdb drive is the second drive and it has no information on the mount points.<\/p>\n<p>Now we can partition the drive. To partition the disk &#8211; \/dev\/sdb, enter:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# fdisk \/dev\/sdb\n\n<\/pre>\n<p>For help using the partitioner, use the \u201cm\u201d command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\nCommand (m for help): m\nCommand action\n   a   toggle a bootable flag\n   b   edit bsd disklabel\n   c   toggle the dos compatibility flag\n   d   delete a partition\n   l   list known partition types\n   m   print this menu\n   n   add a new partition\n   o   create a new empty DOS partition table\n   p   print the partition table\n   q   quit without saving changes\n   s   create a new empty Sun disklabel\n   t   change a partition&#039;s system id\n   u   change display\/entry units\n   v   verify the partition table\n   w   write table to disk and exit\n   x   extra functionality (experts only)\n\nCommand (m for help): \n\n<\/pre>\n<p>partitions using the command \u201cp\u201d:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\nCommand (m for help): p\n\nDisk \/dev\/sdb: 50.0 GB, 50019202560 bytes\n255 heads, 63 sectors\/track, 6081 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\n\n   Device Boot    Start       End    Blocks   Id  System\n\nCommand (m for help):\n\n<\/pre>\n<p>To create a new partition, issue the command \u201cn\u201d and then select \u201cp\u201d for primary and 1-4 depending on which partition on the drive this is (first, second, third, or fourth):<\/p>\n<p>n(creates a new partition)<\/p>\n<p>p(creates a primary partition)<\/p>\n<p>1(the number 1 denotes the partition will be \/dev\/sdb1)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\nCommand (m for help): n\nCommand action\n  e   extended\n  p   primary partition (1-4)\np\nPartition number (1-4): 1\nFirst cylinder (1-6081, default 1): 1\nLast cylinder or +size or +sizeM or +sizeK (1-6081, default 6081): 6081\n\n\n<\/pre>\n<p>To save the partition, use the \u201cw\u201d command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\nCommand (m for help): w\n\n\nThe partition table has been altered!\n\nCalling ioctl() to re-read partition table.\nSyncing disks.\n<\/pre>\n<p>Now we can check to see if the partition is there:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# fdisk -l\n\nDisk \/dev\/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000ab095\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *        2048     1026047      512000   83  Linux\n\/dev\/sda2         1026048    33554431    16264192   8e  Linux LVM\n\nDisk \/dev\/sdb: 17.2 GB, 17179869184 bytes, 33554432 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: 0x884e64a3\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sdb1            2048    33554431    16776192   83  Linux\n\n<\/pre>\n<p>Format the new disk using mkfs.ext3 command:<\/p>\n<p>To format Linux partions using ext3fs on the new disk, issue the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# mkfs.ext3 \/dev\/sdb1\n\n<\/pre>\n<p>To format Linux partions using ext4fs on the new disk, issue the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# mkfs.ext4 \/dev\/sdb1\n<\/pre>\n<p>Output (for using ext4):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# mkfs.ext4 \/dev\/sdb1\nmke2fs 1.42.9 (28-Dec-2013)\nFilesystem label=\nOS type: Linux\nBlock size=4096 (log=2)\nFragment size=4096 (log=2)\nStride=0 blocks, Stripe width=0 blocks\n1048576 inodes, 4194048 blocks\n209702 blocks (5.00%) reserved for the super user\nFirst data block=0\nMaximum filesystem blocks=2151677952\n128 block groups\n32768 blocks per group, 32768 fragments per group\n8192 inodes per group\nSuperblock backups stored on blocks:\n        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,\n        4096000\n\nAllocating group tables: done\nWriting inode tables: done\nCreating journal (32768 blocks): done\nWriting superblocks and filesystem accounting information: done\n\n<\/pre>\n<p>Mount the new disk using the mount command. First, you&#8217;ll need to create a mount point. We&#8217;ll use \/disk2. This is where we&#8217;ll mount \/dev\/sdb1. Enter the following commands:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# cd \/\n# mkdir disk2\n# mount \/dev\/sdb1 \/disk2\n# df -h\nFilesystem                     Size  Used Avail Use% Mounted on\n\/dev\/mapper\/centos_plesk-root   14G  3.9G   10G  29% \/\ndevtmpfs                       910M     0  910M   0% \/dev\ntmpfs                          920M  4.0K  920M   1% \/dev\/shm\ntmpfs                          920M  8.6M  912M   1% \/run\ntmpfs                          920M     0  920M   0% \/sys\/fs\/cgroup\n\/dev\/sdb1                       16G   47M   15G   1% \/disk2\n\/dev\/sda1                      497M  215M  282M  44% \/boot\ntmpfs                          184M     0  184M   0% \/run\/user\/0\n\n<\/pre>\n<p>Edit \/etc\/fstab so the new drive will automatically mount to \/disk1 on reboot. Add the following:<br \/>\n\/dev\/sdb1       \/disk2      ext4    defaults        0 0<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# nano \/etc\/fstab\n# Created by anaconda on Wed Dec  6 19:53:05 2017\n#\n# Accessible filesystems, by reference, are maintained under &#039;\/dev\/disk&#039;\n# See man pages fstab(5), findfs(8), mount(8) and\/or blkid(8) for more info\n#\n\/dev\/mapper\/centos_plesk-root \/                       xfs     defaults        0 0\nUUID=f9b133be-f059-45e2-a296-ccddb4cebe06 \/boot                   xfs     defaults        0 0\n\/dev\/mapper\/centos_plesk-swap swap                    swap    defaults        0 0\n\/dev\/sdb1       \/disk2      ext4    defaults        0 0\n\n<\/pre>\n<p>Mount the disk<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# mount -a\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is how to add a second disk to linux. In this article, the OS is CentOS 7. Check to see how many drives are installed: You can do this using the df and fdisk command: # df -h Filesystem Size Used Avail Use% Mounted on \/dev\/mapper\/centos_plesk-root 14G 3.9G 10G 29% \/ devtmpfs 910M 0 &#8230; <a title=\"Add second hard drive to linux\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2018\/01\/23\/add-second-hard-drive-linux\/\" aria-label=\"Read more about Add second hard drive to linux\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-3816","post","type-post","status-publish","format-standard","hentry","category-administration"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/3816","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=3816"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/3816\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=3816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=3816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=3816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}