{"id":2251,"date":"2012-03-13T23:01:47","date_gmt":"2012-03-13T15:01:47","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=2251"},"modified":"2023-04-28T09:49:40","modified_gmt":"2023-04-28T09:49:40","slug":"how-to-create-additional-lvm-on-rhel-6centos-6","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-create-additional-lvm-on-rhel-6centos-6\/","title":{"rendered":"How to Create Additional LVM on RHEL 6\/CentOS 6"},"content":{"rendered":"<p>Most of the linux administrator facing run out of disk space to store data and sometimes there is another request for them to create additional logical volume manager(LVM) for new system or to store data. It is possible to perform this task if that system administrator has the right skill on linux. Otherwise, they will put themselves and the organization in the disaster or risk as working with the system&#8217;s data is on of the most critical job that must be perform with the right steps and skills. In this post, i will show how to create additional LVM on Red Hat Enterprise Linux 6 (RHEL 6) system. This step may apply to CentOS 6.0. CentOS 6.1 and CentOS 6.2.<\/p>\n<p>1. By typing the mount command with no arguments shows us all currently mounted filesystems<\/p>\n<pre>\n[root@rhel6 ~]# mount\n\/dev\/mapper\/VolGroup-lv_root on \/ type ext4 (rw)\nproc on \/proc type proc (rw)\nsysfs on \/sys type sysfs (rw)\ndevpts on \/dev\/pts type devpts (rw,gid=5,mode=620)\ntmpfs on \/dev\/shm type tmpfs (rw)\n\/dev\/sda1 on \/boot type ext4 (rw)\nnone on \/proc\/sys\/fs\/binfmt_misc type binfmt_misc (rw)\n<\/pre>\n<p>2. Print the current partition table of the hard disk :<\/p>\n<pre>\n[root@rhel6 ~]# fdisk -l\n\nDisk \/dev\/sda: 12.9 GB, 12884901888 bytes\n255 heads, 63 sectors\/track, 1566 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x0000690f\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *           1          64      512000   83  Linux\nPartition 1 does not end on cylinder boundary.\n\/dev\/sda2              64        1567    12069888   8e  Linux LVM\n\nDisk \/dev\/dm-0: 10.2 GB, 10242490368 bytes\n255 heads, 63 sectors\/track, 1245 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\nDisk \/dev\/dm-0 doesn't contain a valid partition table\n\nDisk \/dev\/dm-1: 2113 MB, 2113929216 bytes\n255 heads, 63 sectors\/track, 257 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\nDisk \/dev\/dm-1 doesn't contain a valid partition table\n\nDisk \/dev\/sdb: 12.9 GB, 12884901888 bytes\n255 heads, 63 sectors\/track, 1566 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\nDisk \/dev\/sdb doesn't contain a valid partition table\n<\/pre>\n<p>3. Create new partition for \/dev\/sdb using below command :<\/p>\n<pre>\n[root@rhel6 ~]# fdisk \/dev\/sdb\nDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel\nBuilding a new DOS disklabel with disk identifier 0x1adc0629.\nChanges will remain in memory only, until you decide to write them.\nAfter that, of course, the previous content won't be recoverable.\n\nWarning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)\n\nWARNING: DOS-compatible mode is deprecated. It's strongly recommended to\n         switch off the mode (command 'c') and change display units to\n         sectors (command 'u').\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'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\nCommand action\n   e   extended\n   p   primary partition (1-4)\np\nPartition number (1-4): 1\nFirst cylinder (1-1566, default 1):\nUsing default value 1\nLast cylinder, +cylinders or +size{K,M,G} (1-1566, default 1566):\nUsing default value 1566\n\nCommand (m for help): w\nThe partition table has been altered!\n\nCalling ioctl() to re-read partition table.\nSyncing disks.\n<\/pre>\n<p>4. Convert this disk into a physical volume :<\/p>\n<pre>\n[root@rhel6 ~]# pvcreate \/dev\/sdb1\n  Physical volume \"\/dev\/sdb1\" successfully created\n<\/pre>\n<p>Display the physical volume :<\/p>\n<pre>\n[root@rhel6 ~]# pvdisplay\n  --- Physical volume ---\n  PV Name               \/dev\/sda2\n  VG Name               VolGroup\n  PV Size               11.51 GiB \/ not usable 3.00 MiB\n  Allocatable           yes (but full)\n  PE Size               4.00 MiB\n  Total PE              2946\n  Free PE               0\n  Allocated PE          2946\n  PV UUID               tzxpC7-70n1-OuUQ-kMfT-H627-VHAA-kroHvm\n\n  \"\/dev\/sdb1\" is a new physical volume of \"12.00 GiB\"\n  --- NEW Physical volume ---\n  PV Name               \/dev\/sdb1\n  VG Name\n  PV Size               12.00 GiB\n  Allocatable           NO\n  PE Size               0\n  Total PE              0\n  Free PE               0\n  Allocated PE          0\n  PV UUID               SoWQ5U-CmmA-tjIY-KDh0-H3gU-qVpa-tx4n6n\n<\/pre>\n<p>5. With the physical volume created we now need to create new volume group for it. In this case i will give the volume group name  VolGroup_rhel6 :<\/p>\n<pre>\n[root@rhel6 ~]# vgcreate VolGroup_rhel6 \/dev\/sdb1\n  Volume group \"VolGroup_rhel6\" successfully created\n<\/pre>\n<p>Display the volume group<\/p>\n<pre>\n[root@rhel6 ~]# vgdisplay\n  --- Volume group ---\n  VG Name               VolGroup_rhel6\n  System ID\n  Format                lvm2\n  Metadata Areas        1\n  Metadata Sequence No  1\n  VG Access             read\/write\n  VG Status             resizable\n  MAX LV                0\n  Cur LV                0\n  Open LV               0\n  Max PV                0\n  Cur PV                1\n  Act PV                1\n  VG Size               11.99 GiB\n  PE Size               4.00 MiB\n  Total PE              3070\n  Alloc PE \/ Size       0 \/ 0\n  Free  PE \/ Size       3070 \/ 11.99 GiB\n  VG UUID               mg2I2s-8u5l-Mjm7-oKrQ-yYJ3-yzaO-mq2u9v\n\n  --- Volume group ---\n  VG Name               VolGroup\n  System ID\n  Format                lvm2\n  Metadata Areas        1\n  Metadata Sequence No  3\n  VG Access             read\/write\n  VG Status             resizable\n  MAX LV                0\n  Cur LV                2\n  Open LV               2\n  Max PV                0\n  Cur PV                1\n  Act PV                1\n  VG Size               11.51 GiB\n  PE Size               4.00 MiB\n  Total PE              2946\n  Alloc PE \/ Size       2946 \/ 11.51 GiB\n  Free  PE \/ Size       0 \/ 0\n  VG UUID               uROlLN-3aef-Cb7G-rJ8W-EyY0-aDaf-TyeE5T\n<\/pre>\n<p>6. Create logical volumes with the name of rhelvol into VolGroup_rhel6 volume group :<\/p>\n<pre>\n[root@rhel6 ~]# lvcreate --name rhelvol -l 100%FREE VolGroup_rhel6\n  Logical volume \"rhelvol\" created\n<\/pre>\n<p>Display logical volume :<\/p>\n<pre>\n[root@rhel6 ~]# lvdisplay\n  --- Logical volume ---\n  LV Name                \/dev\/VolGroup_rhel6\/rhelvol\n  VG Name                VolGroup_rhel6\n  LV UUID                o3RQMB-O3Lu-TB2h-7pSm-A2kI-sh1W-rXb1Ce\n  LV Write Access        read\/write\n  LV Status              available\n  # open                 0\n  LV Size                11.99 GiB\n  Current LE             3070\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     256\n  Block device           253:2\n\n  --- Logical volume ---\n  LV Name                \/dev\/VolGroup\/lv_root\n  VG Name                VolGroup\n  LV UUID                1f4tl8-rCgZ-yI9J-xCsI-Hrh2-5DUS-DJF5N2\n  LV Write Access        read\/write\n  LV Status              available\n  # open                 1\n  LV Size                9.54 GiB\n  Current LE             2442\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     256\n  Block device           253:0\n\n  --- Logical volume ---\n  LV Name                \/dev\/VolGroup\/lv_swap\n  VG Name                VolGroup\n  LV UUID                Kpw601-Wcvj-EM8b-FJnh-v2f6-5CqT-rV2JdT\n  LV Write Access        read\/write\n  LV Status              available\n  # open                 1\n  LV Size                1.97 GiB\n  Current LE             504\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     256\n  Block device           253:1\n<\/pre>\n<p>7. Creating a file with the mke2fs command :<\/p>\n<pre>\n[root@rhel6 ~]# mke2fs -j \/dev\/VolGroup_rhel6\/rhelvol\n<\/pre>\n<pre>\n[root@rhel6 ~]# mke2fs -j \/dev\/VolGroup_rhel6\/rhelvol\nmke2fs 1.41.12 (17-May-2010)\nFilesystem label=\nOS type: Linux\nBlock size=4096 (log=2)\nFragment size=4096 (log=2)\nStride=0 blocks, Stripe width=0 blocks\n786432 inodes, 3143680 blocks\n157184 blocks (5.00%) reserved for the super user\nFirst data block=0\nMaximum filesystem blocks=3221225472\n96 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\nWriting inode tables: done\nCreating journal (32768 blocks): done\nWriting superblocks and filesystem accounting information: done\n\nThis filesystem will be automatically checked every 37 mounts or\n180 days, whichever comes first.  Use tune2fs -c or -i to override.\n<\/pre>\n<pre>\n[root@rhel6 ~]# e2label \/dev\/VolGroup_rhel6\/rhelvol \/opt\n<\/pre>\n<pre>\n[root@rhel6 ~]# vi \/etc\/fstab\n<\/pre>\n<pre>\n#\n# \/etc\/fstab\n# Created by anaconda on Wed Jan  4 03:41:29 2012\n#\n# Accessible filesystems, by reference, are maintained under '\/dev\/disk'\n# See man pages fstab(5), findfs(8), mount(8) and\/or blkid(8) for more info\n#\n\/dev\/mapper\/VolGroup-lv_root \/                       ext4    defaults        1 1\n\/dev\/VolGroup_rhel6\/rhelvol \/opt                       ext4    defaults        1 1\nUUID=0e03e7c9-6971-4783-8fb9-fc251febf486 \/boot                   ext4    defaults        1 2\n\/dev\/mapper\/VolGroup-lv_swap swap                    swap    defaults        0 0\ntmpfs                   \/dev\/shm                tmpfs   defaults        0 0\ndevpts                  \/dev\/pts                devpts  gid=5,mode=620  0 0\nsysfs                   \/sys                    sysfs   defaults        0 0\nproc                    \/proc                   proc    defaults        0 0\n<\/pre>\n<pre>\n[root@rhel6 \/]# mount \/opt\n<\/pre>\n<pre>\n[root@rhel6 \/]# df -h\nFilesystem            Size  Used Avail Use% Mounted on\n\/dev\/mapper\/VolGroup-lv_root\n                      9.4G  2.1G  6.9G  23% \/\ntmpfs                 504M     0  504M   0% \/dev\/shm\n\/dev\/sda1             485M   29M  432M   7% \/boot\n\/dev\/mapper\/VolGroup_rhel6-rhelvol\n                       12G  159M   12G   2% \/opt\n<\/pre>\n<p>Type the mount command with no arguments to shows the updated mounted filesystems. \/dev\/mapper\/VolGroup_rhel6-rhelvol now exist at the bottom :<\/p>\n<pre>\n[root@rhel6 ~]# mount\n\/dev\/mapper\/VolGroup-lv_root on \/ type ext4 (rw)\nproc on \/proc type proc (rw)\nsysfs on \/sys type sysfs (rw)\ndevpts on \/dev\/pts type devpts (rw,gid=5,mode=620)\ntmpfs on \/dev\/shm type tmpfs (rw)\n\/dev\/sda1 on \/boot type ext4 (rw)\nnone on \/proc\/sys\/fs\/binfmt_misc type binfmt_misc (rw)\n\/dev\/mapper\/VolGroup_rhel6-rhelvol on \/opt type ext4 (rw)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Most of the linux administrator facing run out of disk space to store data and sometimes there is another request for them to create additional logical volume manager(LVM) for new&#8230;<\/p>\n","protected":false},"author":6,"featured_media":1499,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2055,1156,1002,2058],"tags":[1253,1536,1546,1554,1555,1556,1713,1715],"class_list":["post-2251","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-hard-disk","category-lvm","category-rhel","tag-centos-6-2","tag-linux","tag-linux-utilities","tag-logical-volume","tag-logical-volume-manager","tag-lvm","tag-rhel","tag-rhel-6"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=2251"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2251\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/1499"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=2251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=2251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=2251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}