{"id":910,"date":"2014-01-27T13:24:32","date_gmt":"2014-01-27T18:24:32","guid":{"rendered":"http:\/\/www.gamescheat.ca\/?p=910"},"modified":"2019-09-04T19:57:39","modified_gmt":"2019-09-05T00:57:39","slug":"add-new-disk-to-red-hat-linux-server-create-new-filesystem-without-reboot","status":"publish","type":"post","link":"http:\/\/www.gamescheat.ca\/?p=910","title":{"rendered":"Add new disk to Red Hat Linux server, create new filesystem without reboot."},"content":{"rendered":"<p>If you are running a VMware virtual Red Hat Linux server then it is very easy to add a new disk. For physical servers with hot add capability this is also possible.  I am going to show you how to add a new disk to Red Hat Linux complete with a new filesystem, without rebooting the server.<\/p>\n<div style=\"float: right;\"><div style=\"margin: 15px 15px 15px 15px\";><script type=\"text\/javascript\"><!--\ngoogle_ad_client = \"pub-3319935785736004\";\ngoogle_alternate_color = \"FFFFFF\";\ngoogle_ad_width = 200;\ngoogle_ad_height = 200;\ngoogle_ad_format = \"200x200_as\";\ngoogle_ad_type = \"text_image\";\ngoogle_ad_channel =\"\";\ngoogle_color_border = \"cccccc\";\ngoogle_color_link = \"cc0000\";\ngoogle_color_bg = \"ffffff\";\ngoogle_color_text = \"000000\";\ngoogle_color_url = \"008000\";\n\/\/--><\/script>\n<script type=\"text\/javascript\"\n  src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\n<\/script><\/div><\/div><p>List the disks installed. The command lsscsi is not installed in the default installation of Red Hat, you will need to install it.  This will be list of current disks before rescanning.<\/p>\n<blockquote><p>[root@linux ~]# lsscsi<br \/>\n[1:0:0:0]    cd\/dvd  NECVMWar VMware IDE CDR10 1.00  \/dev\/sr0<br \/>\n[2:0:0:0]    disk    VMware   Virtual disk     1.0   \/dev\/sda<br \/>\n[2:0:1:0]    disk    VMware   Virtual disk     1.0   \/dev\/sdb<\/p><\/blockquote>\n<p>List all scsi host value.<\/p>\n<blockquote><p>[root@linux ~]# ll \/sys\/class\/scsi_host<br \/>\ntotal 0<br \/>\nlrwxrwxrwx 1 root root 0 Jan 14 21:40 host0 -> ..\/..\/devices\/pci0000:00\/0000:00:07.1\/host0\/scsi_host\/host0<br \/>\nlrwxrwxrwx 1 root root 0 Jan 14 21:40 host1 -> ..\/..\/devices\/pci0000:00\/0000:00:07.1\/host1\/scsi_host\/host1<br \/>\nlrwxrwxrwx 1 root root 0 Jan 14 21:40 host2 -> ..\/..\/devices\/pci0000:00\/0000:00:10.0\/host2\/scsi_host\/host2<\/p><\/blockquote>\n<p>Normally you would have to reboot the server to see the new disk, but you can rescan the SCSI bus for a new disk without rebooting.<\/p>\n<blockquote><p>[root@linux ~]# echo \u201c- \u2013 -\u201d > \/sys\/class\/scsi_host\/host0\/scan<br \/>\n[root@linux ~]# echo \u201c- \u2013 -\u201d > \/sys\/class\/scsi_host\/host1\/scan<br \/>\n[root@linux ~]# echo \u201c- \u2013 -\u201d > \/sys\/class\/scsi_host\/host2\/scan\n<\/p><\/blockquote>\n<p>List all disks found, sdc is the new disk that did not appear in the original scan.<\/p>\n<blockquote><p>[root@linux ~]# lsscsi<br \/>\n[1:0:0:0]    cd\/dvd  NECVMWar VMware IDE CDR10 1.00  \/dev\/sr0<br \/>\n[2:0:0:0]    disk    VMware   Virtual disk     1.0   \/dev\/sda<br \/>\n[2:0:1:0]    disk    VMware   Virtual disk     1.0   \/dev\/sdb<br \/>\n[2:0:2:0]    disk    VMware   Virtual disk     1.0   \/dev\/sdc<\/p><\/blockquote>\n<p>Create a new partition on sdc using fdisk.<\/p>\n<blockquote><p>[root@linux ~]# fdisk \/dev\/sdc<br \/>\nDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel<br \/>\nBuilding a new DOS disklabel with disk identifier 0xafebcbd2.<br \/>\nChanges will remain in memory only, until you decide to write them.<br \/>\nAfter that, of course, the previous content won\u2019t be recoverable.<\/p>\n<p>Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)<\/p>\n<p>WARNING: DOS-compatible mode is deprecated. It\u2019s strongly recommended to<br \/>\n         switch off the mode (command \u2018c\u2019) and change display units to<br \/>\n         sectors (command \u2018u\u2019).<\/p>\n<p>Command (m for help): n<br \/>\nCommand action<br \/>\n   e   extended<br \/>\n   p   primary partition (1-4)<br \/>\np<br \/>\nPartition number (1-4): 1<br \/>\nFirst cylinder (1-2610, default 1):<br \/>\nUsing default value 1<br \/>\nLast cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):<br \/>\nUsing default value 2610<\/p>\n<p>Command (m for help): p<\/p>\n<p>Disk \/dev\/sdc: 21.5 GB, 21474836480 bytes<br \/>\n255 heads, 63 sectors\/track, 2610 cylinders<br \/>\nUnits = cylinders of 16065 * 512 = 8225280 bytes<br \/>\nSector size (logical\/physical): 512 bytes \/ 512 bytes<br \/>\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<br \/>\nDisk identifier: 0xafebcbd2<\/p>\n<p>   Device Boot      Start         End      Blocks   Id  System<br \/>\n\/dev\/sdc1               1        2610    20964793+  83  Linux<\/p>\n<p>Command (m for help): t<br \/>\nSelected partition 1<br \/>\nHex code (type L to list codes): 8e<br \/>\nChanged system type of partition 1 to 8e (Linux LVM)<\/p>\n<p>Command (m for help): p<\/p>\n<p>Disk \/dev\/sdc: 21.5 GB, 21474836480 bytes<br \/>\n255 heads, 63 sectors\/track, 2610 cylinders<br \/>\nUnits = cylinders of 16065 * 512 = 8225280 bytes<br \/>\nSector size (logical\/physical): 512 bytes \/ 512 bytes<br \/>\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<br \/>\nDisk identifier: 0xafebcbd2<\/p>\n<p>   Device Boot      Start         End      Blocks   Id  System<br \/>\n\/dev\/sdc1               1        2610    20964793+  8e  Linux LVM<\/p>\n<p>Command (m for help): w<br \/>\nThe partition table has been altered!<\/p>\n<p>Calling ioctl() to re-read partition table.<br \/>\nSyncing disks.<\/p><\/blockquote>\n<p>Display the new partition sdc1.<\/p>\n<blockquote><p>[root@linux ~]# fdisk -l<br \/>\n\u2026\u2026\u2026\u2026\u2026\u2026.<br \/>\n\u2026\u2026\u2026<br \/>\n\u2026.<br \/>\nDisk \/dev\/sdc: 21.5 GB, 21474836480 bytes<br \/>\n255 heads, 63 sectors\/track, 2610 cylinders<br \/>\nUnits = cylinders of 16065 * 512 = 8225280 bytes<br \/>\nSector size (logical\/physical): 512 bytes \/ 512 bytes<br \/>\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<br \/>\nDisk identifier: 0xafebcbd2<\/p>\n<p>   Device Boot      Start         End      Blocks   Id  System<br \/>\n\/dev\/sdc1               1        2610    20964793+  8e  Linux LVM<\/p><\/blockquote>\n<p>Create a new physical volume.<\/p>\n<blockquote><p>[root@linux ~]# pvcreate \/dev\/sdc1<br \/>\n  dev_is_mpath: failed to get device for 8:33<br \/>\n  Physical volume \u201c\/dev\/sdc1\u201d successfully created<\/p><\/blockquote>\n<p>List all physical volumes. Notice sdc1 is not assigned to any volume group yet.<\/p>\n<blockquote><p>[root@linux ~]# pvs<br \/>\n  PV         VG          Fmt  Attr PSize  PFree<br \/>\n  \/dev\/sda2  VolGroup    lvm2 a\u2013  19.51g     0<br \/>\n  \/dev\/sdb1  VolGroupOpt lvm2 a\u2013  20.00g     0<br \/>\n  \/dev\/sdc1              lvm2 a\u2013  19.99g 19.99g<\/p><\/blockquote>\n<p>Create new volume group VoGroupLog on sdc1.<\/p>\n<blockquote><p>[root@linux ~]# vgcreate voGroupLog \/dev\/sdc1<br \/>\n  Volume group \u201cvoGroupLog\u201d successfully created<\/p><\/blockquote>\n<p>List all volume groups.<\/p>\n<blockquote><p>[root@linux ~]# vgs<br \/>\n  VG              #PV #LV #SN Attr   VSize  VFree<br \/>\n  VolGroup          1   2   0 wz\u2013n- 19.51g     0<br \/>\n  voGroupLog        1   0   0 wz\u2013n- 19.99g 19.99g<br \/>\n  VolGroupOpt       1   1   0 wz\u2013n- 20.00g     0<\/p><\/blockquote>\n<p>Create new logical volume lv_log using 100% of available free space in voGroupLog<\/p>\n<blockquote><p>[root@linux ~]# lvcreate -l 100%FREE -n lv_log voGroupLog<br \/>\n  Logical volume \u201clv_log\u201d created<\/p><\/blockquote>\n<p>List all logical volumes.<\/p>\n<blockquote><p>[root@linux ~]# lvs<br \/>\n  LV         VG              Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert<br \/>\n  lv_root    VolGroup        -wi-ao\u2014- 15.57g<br \/>\n  lv_swap    VolGroup        -wi-ao\u2014-  3.94g<br \/>\n  lv_log     voGroupLog      -wi-a\u2014\u2013 19.99g<br \/>\n  lv_opt     VolGroupOpt     -wi-ao\u2014- 20.00g<\/p><\/blockquote>\n<p>Make new ext4 filesystem on lv_log.<\/p>\n<blockquote><p>[root@linux ~]# mkfs.ext4 \/dev\/mapper\/voGroupLog-lv_log<br \/>\nmke2fs 1.41.12 (17-May-2010)<br \/>\nFilesystem label=<br \/>\nOS type: Linux<br \/>\nBlock size=4096 (log=2)<br \/>\nFragment size=4096 (log=2)<br \/>\nStride=0 blocks, Stripe width=0 blocks<br \/>\n1310720 inodes, 5240832 blocks<br \/>\n262041 blocks (5.00%) reserved for the super user<br \/>\nFirst data block=0<br \/>\nMaximum filesystem blocks=4294967296<br \/>\n160 block groups<br \/>\n32768 blocks per group, 32768 fragments per group<br \/>\n8192 inodes per group<br \/>\nSuperblock backups stored on blocks:<br \/>\n        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,<br \/>\n        4096000<\/p>\n<p>Writing inode tables: done<br \/>\nCreating journal (32768 blocks): done<br \/>\nWriting superblocks and filesystem accounting information: done<\/p>\n<p>This filesystem will be automatically checked every 25 mounts or<br \/>\n180 days, whichever comes first.  Use tune2fs -c or -i to override.<\/p><\/blockquote>\n<p>Create a new directory \/MyLog for mounting the new filesystem.<\/p>\n<blockquote><p>[root@linux \/]# mkdir MyLog<\/p><\/blockquote>\n<p>List the path for the new logical volume, it is \/dev\/mapper\/VoGroupLog-lv_log.  You need this information for mounting it.<\/p>\n<blockquote><p>[root@linux \/]# ll \/dev\/mapper<br \/>\ntotal 0<br \/>\ncrw-rw\u2014- 1 root root 10, 58 Jan 14 21:40 control<br \/>\nlrwxrwxrwx 1 root root      7 Jan 14 21:40 VolGroup-lv_root -> ..\/dm-0<br \/>\nlrwxrwxrwx 1 root root      7 Jan 14 21:40 VolGroup-lv_swap -> ..\/dm-1<br \/>\nlrwxrwxrwx 1 root root      7 Jan 14 21:40 VolGroupOpt-lv_opt -> ..\/dm-2<br \/>\nlrwxrwxrwx 1 root root      7 Jan 27 11:47 voGroupLog-lv_log -> ..\/dm-3<\/p><\/blockquote>\n<p>Mount the filesystem.<\/p>\n<blockquote><p>[root@linux \/]# mount \/dev\/mapper\/voGroupLog-lv_log \/MyLog<\/p><\/blockquote>\n<p>List all mounted filesystem.<\/p>\n<blockquote><p>[root@linux \/]# df -hT<br \/>\nFilesystem                             Type   Size  Used Avail Use% Mounted on<br \/>\n\/dev\/mapper\/VolGroup-lv_root           ext4    16G  6.9G  7.7G  48% \/<br \/>\ntmpfs                                  tmpfs  7.3G     0  7.3G   0% \/dev\/shm<br \/>\n\/dev\/sda1                              ext4   485M   92M  368M  20% \/boot<br \/>\n\/dev\/mapper\/VolGroupOpt-lv_opt         ext4    20G   14G  5.5G  71% \/opt<br \/>\n\/dev\/mapper\/voGroupLog-lv_log ext4    20G  172M   19G   1% \/MyLog<\/p><\/blockquote>\n<p>Add the new mount path to the \/etc\/fstab file so it will persist after a reboot,add the below line.<\/p>\n<blockquote><p>\/dev\/mapper\/voGroupLog-lv_log \/MyLog           ext4    defaults        1 1<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>If you are running a VMware virtual Red Hat Linux server then it is very easy to add a new disk. For physical servers with hot add capability this is also possible. I am going to show you how to&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/www.gamescheat.ca\/?p=910\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"tags":[55,77,61],"_links":{"self":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/910"}],"collection":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=910"}],"version-history":[{"count":1,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/910\/revisions"}],"predecessor-version":[{"id":911,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/910\/revisions\/911"}],"wp:attachment":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=910"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}