{"id":2225,"date":"2013-07-12T11:13:00","date_gmt":"2013-07-12T03:13:00","guid":{"rendered":"http:\/\/rmohan.com\/?p=2225"},"modified":"2013-07-12T11:13:27","modified_gmt":"2013-07-12T03:13:27","slug":"add-disk-on-rhel-6","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=2225","title":{"rendered":"Add disk on Rhel 6"},"content":{"rendered":"<p>There are two ways to configure a new disk drive into a Red Hat Enterprise Linux 6 system. One very simple method is to create one or more Linux partitions on the new drive, create Linux file systems on those partitions and then mount them at specific mount points so that they can be accessed. This approach will be covered in this chapter.<\/p>\n<div>Another approach is to add the new space to an existing volume group or create a new volume group. When RHEL 6 is installed a volume group is created and named vg_hostname, where\u00a0hostname\u00a0is the host name of the system. Within this volume group are two logical volumes named\u00a0lv_root\u00a0and\u00a0lv_swap\u00a0that are used to store the \/ file system and swap partition respectively. By configuring the new disk as part of a volume group we are able to increase the disk space available to the existing logical volumes. Using this approach we are able, therefore, to increase the size of the \/ file system by allocating some or all of the space on the new disk to lv_root. This topic will be discussed in detail in\u00a0<a title=\"Adding a New Disk to an RHEL 6 Volume Group and Logical Volume\" href=\"http:\/\/www.techotopia.com\/index.php\/Adding_a_New_Disk_to_an_RHEL_6_Volume_Group_and_Logical_Volume\" target=\"_blank\">Adding a New Disk to an RHEL 6 Volume Group and Logical Volume\u00a0<\/a>.<\/div>\n<h2>Getting Started<\/h2>\n<div>This tutorial assumes that the new physical hard drive has been installed on the system and is visible to the operating system. The best way to do this is to enter the system BIOS during the boot process and ensuring that the BIOS sees the disk drive. Sometimes the BIOS will provide a menu option to scan for new drives. If the BIOS does not see the disk drive double check the connectors and jumper settings (if any) on the drive.<\/div>\n<h2>Finding the New Hard Drive in RHEL 6<\/h2>\n<div>Assuming the drive is visible to the BIOS it should automatically be detected by the operating system. Typically, the disk drives in a system are assigned device names beginning hd or sd followed by a letter to indicate the device number. For example, the first device might be \/dev\/sda, the second \/dev\/sdb and so on.<\/div>\n<div>The following is output from a system with only one physical disk drive:<\/div>\n<pre># ls \/dev\/sd*\r\n\/dev\/sda   \/dev\/sda1  \/dev\/sda2<\/pre>\n<div>This shows that the disk drive represented by \/dev\/sda is itself divided into 2 partitions, represented by\u00a0\/dev\/sda1\u00a0and\u00a0\/dev\/sda2.<\/div>\n<div>The following output is from the same system after a second hard disk drive has been installed:<\/div>\n<pre># ls \/dev\/sd*\r\n\/dev\/sda   \/dev\/sda1  \/dev\/sda2 \/dev\/sdb<\/pre>\n<div>As shown above, the new hard drive has been assigned to the device file\/dev\/sdb. Currently the drive has no partitions shown (because we have yet to create any).<\/div>\n<div>At this point we have a choice of creating partitions and file systems on the new drive and mounting them for access or adding the disk as a physical volume as part of a volume group. To perform the former continue with this chapter, otherwise read\u00a0<a title=\"Adding a New Disk to an RHEL 6 Volume Group and Logical Volume\" href=\"http:\/\/www.techotopia.com\/index.php\/Adding_a_New_Disk_to_an_RHEL_6_Volume_Group_and_Logical_Volume\" target=\"_blank\">Adding a New Disk to an RHEL 6 Volume Group and Logical Volume\u00a0<\/a>for details on configuring Logical Volumes.<\/div>\n<h2>Creating Linux Partitions<\/h2>\n<div>The next step is to create one or more Linux partitions on the new disk drive. This is achieved using the\u00a0fdisk\u00a0utility which takes as a command-line argument the device to be partitioned:<\/div>\n<pre># su -\r\n# fdisk \/dev\/sdb\r\nDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel\r\nBuilding a new DOS disklabel with disk identifier 0xd1082b01.\r\nChanges will remain in memory only, until you decide to write them.\r\nAfter that, of course, the previous content won't be recoverable.\r\n\r\nWarning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)\r\n\r\nWARNING: DOS-compatible mode is deprecated. It's strongly recommended to\r\n         switch off the mode (command 'c') and change display units to\r\n         sectors (command 'u').\r\n\r\nCommand (m for help):<\/pre>\n<div>As instructed, switch off DOS compatible mode and change the units to sectors by entering the\u00a0c\u00a0and\u00a0u\u00a0commands:<\/div>\n<pre>Command (m for help): c\r\nDOS Compatibility flag is not set\r\nCommand (m for help): u\r\nChanging display\/entry units to sectors<\/pre>\n<div>In order to view the current partitions on the disk enter the p command:<\/div>\n<pre>Command (m for help): p\r\n\r\nDisk \/dev\/sdb: 34.4 GB, 34359738368 bytes\r\n255 heads, 63 sectors\/track, 4177 cylinders\r\nUnits = cylinders of 16065 * 512 = 8225280 bytes\r\nSector size (logical\/physical): 512 bytes \/ 512 bytes\r\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\r\nDisk identifier: 0xd1082b01\r\n\r\n   Device Boot      Start         End      Blocks   Id  System<\/pre>\n<div>As we can see from the above fdisk output the disk currently has no partitions because it is a previously unused disk. The next step is to create a new partition on the disk, a task which is performed by entering n (for new partition) and p (for primary partition):<\/div>\n<pre>Command (m for help): n\r\nCommand action\r\n   e   extended\r\n   p   primary partition (1-4)\r\np\r\nPartition number (1-4):<\/pre>\n<div>In this example we only plan to create one partition which will be partition 1. Next we need to specify where the partition will begin and end. Since this is the first partition we need it to start at the first available sector and since we want to use the entire disk we specify the last sector as the end. Note that if you wish to create multiple partitions you can specify the size of each partition by sectors, bytes, kilobytes or megabytes.<\/div>\n<pre>Partition number (1-4): 1\r\nFirst sector (2048-67108863, default 2048):\r\nUsing default value 2048\r\nLast sector, +sectors or +size{K,M,G} (2048-67108863, default 67108863):\r\nUsing default value 67108863<\/pre>\n<div>Now that we have specified the partition we need to write it to the disk using the w command:<\/div>\n<pre>Command (m for help): w\r\nThe partition table has been altered!\r\n\r\nCalling ioctl() to re-read partition table.\r\nSyncing disks.<\/pre>\n<div>If we now look at the devices again we will see that the new partition is visible as \/dev\/sdb1:<\/div>\n<pre># ls \/dev\/sd*\r\n\/dev\/sda  \/dev\/sda1  \/dev\/sda2  \/dev\/sdb  \/dev\/sdb1<\/pre>\n<div>The next step is to create a filesystem on our new partition.<\/div>\n<h2>Creating a Filesystem on an RHEL 6 Disk Partition<\/h2>\n<div>We now have a new disk installed, it is visible to RHEL 6 and we have configured a Linux partition on the disk. The next step is to create a Linux file system on the partition so that the operating system can use it to store files and data. The easiest way to create a file system on a partition is to use the mkfs.ext4 utility which takes as arguments the label and the partition device:<\/div>\n<pre># \/sbin\/mkfs.ext4 -L \/backup \/dev\/sdb1\r\nmke2fs 1.41.12 (17-May-2010)\r\nFilesystem label=\/backup\r\nOS type: Linux\r\nBlock size=4096 (log=2)\r\nFragment size=4096 (log=2)\r\nStride=0 blocks, Stripe width=0 blocks\r\n2097152 inodes, 8388352 blocks\r\n419417 blocks (5.00%) reserved for the super user\r\nFirst data block=0\r\nMaximum filesystem blocks=4294967296\r\n256 block groups\r\n32768 blocks per group, 32768 fragments per group\r\n8192 inodes per group\r\nSuperblock backups stored on blocks:\r\n        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,\r\n        4096000, 7962624\r\n\r\nWriting inode tables: done\r\nCreating journal (32768 blocks): done\r\nWriting superblocks and filesystem accounting information: done\r\n\r\nThis filesystem will be automatically checked every 36 mounts or\r\n180 days, whichever comes first.  Use tune2fs -c or -i to override.<\/pre>\n<h2>Mounting a Filesystem<\/h2>\n<div>Now that we have created a new filesystem on the Linux partition of our new disk drive we need to mount it so that it is accessible. In order to do this we need to create a mount point. A mount point is simply a directory or folder into which the filesystem will be mounted. For the purposes of this example we will create a\u00a0\/backup\u00a0directory to match our filesystem label (although it is not necessary that these values match):<\/div>\n<pre># mkdir \/backup<\/pre>\n<div>The filesystem may then be manually mounted using the mount command:<\/div>\n<pre># mount \/dev\/sdb1 \/backup<\/pre>\n<div>Running the mount command with no arguments shows us all currently mounted filesystems (including our new filesystem):<\/div>\n<pre># mount\r\n\/dev\/mapper\/vg_rhel6-lv_root on \/ type ext4 (rw)\r\nproc on \/proc type proc (rw)\r\nsysfs on \/sys type sysfs (rw)\r\ndevpts on \/dev\/pts type devpts (rw,gid=5,mode=620)\r\ntmpfs on \/dev\/shm type tmpfs (rw,rootcontext=\"system_u:object_r:tmpfs_t:s0\")\r\n\/dev\/sda1 on \/boot type ext4 (rw)\r\nnone on \/proc\/sys\/fs\/binfmt_misc type binfmt_misc (rw)\r\nsunrpc on \/var\/lib\/nfs\/rpc_pipefs type rpc_pipefs (rw)\r\n\/dev\/sr0 on \/media\/RHEL_6.0 x86_64 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=500,gid=500,iocharset=utf8,mode=0400,dmode=0500)\r\n\/dev\/sdb1 on \/backup type ext4 (rw)<\/pre>\n<h2>Configuring RHEL 6 to Automatically Mount a Filesystem<\/h2>\n<div>In order to set up the system so that the new filesystem is automatically mounted at boot time an entry needs to be added to the\u00a0\/etc\/fstab\u00a0file.<\/div>\n<div>The following example shows an fstab file configured to automount our\u00a0\/backuppartition:<\/div>\n<pre>\/dev\/mapper\/vg_rhel6-lv_root \/                       ext4    defaults        1 1\r\nUUID=4a9886f5-9545-406a-a694-04a60b24df84 \/boot                   ext4    defaults        1 2\r\n\/dev\/mapper\/vg_rhel6-lv_swap swap                    swap    defaults        0 0\r\ntmpfs                   \/dev\/shm                tmpfs   defaults        0 0\r\ndevpts                  \/dev\/pts                devpts  gid=5,mode=620  0 0\r\nsysfs                   \/sys                    sysfs   defaults        0 0\r\nproc                    \/proc                   proc    defaults        0 0\r\nLABEL=\/backup           \/backup                 ext4    defaults        1 2<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There are two ways to configure a new disk drive into a Red Hat Enterprise Linux 6 system. One very simple method is to create one or more Linux partitions on the new drive, create Linux file systems on those partitions and then mount them at specific mount points so that they can be accessed. [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2225"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2225"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2225\/revisions"}],"predecessor-version":[{"id":2227,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2225\/revisions\/2227"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}