{"id":3985,"date":"2012-09-29T00:41:58","date_gmt":"2012-09-28T16:41:58","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=3985"},"modified":"2023-04-28T09:48:59","modified_gmt":"2023-04-28T09:48:59","slug":"how-to-create-additional-lvm-on-centos-6-3","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-create-additional-lvm-on-centos-6-3\/","title":{"rendered":"How to Create Additional LVM on CentOS 6.3"},"content":{"rendered":"<p>This post will covers the steps to create additional Logical volume manager (LVM) on CentOS 6.3. This will very useful when the production system facing run out of disk space to store data. Sometimes there is another request for them to create additional 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\u2019s data is on of the most critical job that must be perform with the right steps and skills. Follow below steps :<\/p>\n<p>1. Assumed that second disk has been added called \/<strong>dev\/sdb<\/strong>. Create new partition for <strong>\/dev\/sdb<\/strong> using below command : <\/p>\n<pre>\n[root@centos63 ~]# 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 0xd29f2d59.\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): n\nCommand action\n   e   extended\n   p   primary partition (1-4)\np\nPartition number (1-4): 1\nFirst cylinder (1-652, default 1):\nUsing default value 1\nLast cylinder, +cylinders or +size{K,M,G} (1-652, default 652):\nUsing default value 652\n\nCommand (m for help): p\n\nDisk \/dev\/sdb: 5368 MB, 5368709120 bytes\n255 heads, 63 sectors\/track, 652 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: 0xd29f2d59\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sdb1               1         652     5237158+  83  Linux\n\nCommand (m for help): t\nSelected partition 1\nHex code (type L to list codes): 8e\nChanged system type of partition 1 to 8e (Linux LVM)\n\nCommand (m for help): p\n\nDisk \/dev\/sdb: 5368 MB, 5368709120 bytes\n255 heads, 63 sectors\/track, 652 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: 0xd29f2d59\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sdb1               1         652     5237158+  8e  Linux LVM\n\nCommand (m for help): w\nThe partition table has been altered!\n\nCalling ioctl() to re-read partition table.\nSyncing disks.\n\n<\/pre>\n<p>2. Convert this disk into a physical volume :<\/p>\n<pre>\n[root@centos63 ~]# pvcreate \/dev\/sdb1\n  Writing physical volume data to disk \"\/dev\/sdb1\"\n  Physical volume \"\/dev\/sdb1\" successfully created\n<\/pre>\n<p>Display the physical volume :<\/p>\n<pre>\n[root@centos63 ~]# pvdisplay\n  --- Physical volume ---\n  PV Name               \/dev\/sda2\n  VG Name               vg_centos63\n  PV Size               7.51 GiB \/ not usable 3.00 MiB\n  Allocatable           yes (but full)\n  PE Size               4.00 MiB\n  Total PE              1922\n  Free PE               0\n  Allocated PE          1922\n  PV UUID               521faS-HW2C-nUrs-yI1E-4OO9-eLmj-1e3bGW\n\n  \"\/dev\/sdb1\" is a new physical volume of \"4.99 GiB\"\n  --- NEW Physical volume ---\n  PV Name               \/dev\/sdb1\n  VG Name\n  PV Size               4.99 GiB\n  Allocatable           NO\n  PE Size               0\n  Total PE              0\n  Free PE               0\n  Allocated PE          0\n  PV UUID               qTmTeq-8qoL-xxEk-Dj5V-zOjl-vEag-P6Jl7L\n<\/pre>\n<p>3. 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 <strong>vg_data<\/strong>.<\/p>\n<pre>\n[root@centos63 ~]# vgcreate vg_data \/dev\/sdb1\n  Volume group \"vg_data\" successfully created\n<\/pre>\n<p>Display the volume group :<\/p>\n<pre>\n[root@centos63 ~]# vgdisplay\n  --- Volume group ---\n  VG Name               vg_data\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               4.99 GiB\n  PE Size               4.00 MiB\n  Total PE              1278\n  Alloc PE \/ Size       0 \/ 0\n  Free  PE \/ Size       1278 \/ 4.99 GiB\n  VG UUID               YV3IYN-3CF9-3Yd1-69ue-wcq4-0UKk-Zk49Vk\n\n  --- Volume group ---\n  VG Name               vg_centos63\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               7.51 GiB\n  PE Size               4.00 MiB\n  Total PE              1922\n  Alloc PE \/ Size       1922 \/ 7.51 GiB\n  Free  PE \/ Size       0 \/ 0\n  VG UUID               G3H7s2-0yfo-vU9W-5g9g-fq9K-tpNO-U2Y7BQ\n<\/pre>\n<p>4. Create logical volumes with the name of <strong>centos63_vol<\/strong> into <strong>vg_data<\/strong> volume group :<\/p>\n<pre>\n[root@centos63 ~]# lvcreate --name centos63_vol -l 100%FREE vg_data\n  Logical volume \"centos63_vol\" created\n<\/pre>\n<p>Display logical volume :<\/p>\n<pre>\n[root@centos63 ~]# lvdisplay\n  --- Logical volume ---\n  LV Path                \/dev\/vg_data\/centos63_vol\n  LV Name                centos63_vol\n  VG Name                vg_data\n  LV UUID                bVRJwM-5CuR-mLf4-tqHV-j5e4-cs3o-ffKL41\n  LV Write Access        read\/write\n  LV Creation host, time centos63.ehowstuff.local, 2012-09-28 22:55:13 +0800\n  LV Status              available\n  # open                 0\n  LV Size                4.99 GiB\n  Current LE             1278\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 Path                \/dev\/vg_centos63\/lv_root\n  LV Name                lv_root\n  VG Name                vg_centos63\n  LV UUID                3Se9Zl-RmAu-f707-1Fv2-wMvX-oH3z-maExU0\n  LV Write Access        read\/write\n  LV Creation host, time centos63.ehowstuff.local, 2012-07-15 20:17:31 +0800\n  LV Status              available\n  # open                 1\n  LV Size                5.54 GiB\n  Current LE             1418\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 Path                \/dev\/vg_centos63\/lv_swap\n  LV Name                lv_swap\n  VG Name                vg_centos63\n  LV UUID                KijzOf-uPjy-JbJd-dcjw-u0XO-aqPA-2GKScq\n  LV Write Access        read\/write\n  LV Creation host, time centos63.ehowstuff.local, 2012-07-15 20:17:33 +0800\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>5. Format the LVM using mke2fs with -j switch command :<\/p>\n<pre>\n[root@centos63 ~]# mke2fs -j \/dev\/vg_data\/centos63_vol\n<\/pre>\n<pre>\n[root@centos63 ~]# mke2fs -j \/dev\/vg_data\/centos63_vol\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\n327680 inodes, 1308672 blocks\n65433 blocks (5.00%) reserved for the super user\nFirst data block=0\nMaximum filesystem blocks=1342177280\n40 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\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<p>6. Create a mount point for the newly created logical volume :<\/p>\n<pre>\n[root@centos63 ~]# mkdir \/mydata\n<\/pre>\n<p>7. Define mount point to use this partitions :<\/p>\n<pre>\n[root@centos63 ~]# e2label \/dev\/vg_data\/centos63_vol \/mydata\n<\/pre>\n<p>8. Modify <strong>\/etc\/fstab<\/strong> and add the following:<\/p>\n<pre>\n[root@centos63 ~]# vi \/etc\/fstab\n<\/pre>\n<pre>\n\/dev\/vg_data\/centos63_vol \/mydata                       ext4    defaults        1 1\n<\/pre>\n<pre>\n#\n# \/etc\/fstab\n# Created by anaconda on Sun Jul 15 20:17:38 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\/vg_centos63-lv_root \/                       ext4    defaults        1 1\nUUID=2217c7b1-4467-4c81-8596-c3ee7758e2cc \/boot                   ext4    defaults        1 2\n\/dev\/mapper\/vg_centos63-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\/dev\/vg_data\/centos63_vol \/mydata                       ext4    defaults        1 1\n<\/pre>\n<p>9. Mount the newly created logical volume :<\/p>\n<pre>\n[root@centos63 ~]# mount \/mydata\n<\/pre>\n<p>10. The newly created logical volume will now mount automatically each time the system is booted.<\/p>\n<pre>\n[root@centos63 ~]# df -lh\nFilesystem            Size  Used Avail Use% Mounted on\n\/dev\/mapper\/vg_centos63-lv_root\n                      5.5G  2.0G  3.3G  39% \/\ntmpfs                 504M     0  504M   0% \/dev\/shm\n\/dev\/sda1             485M   65M  395M  15% \/boot\n\/dev\/mapper\/vg_data-centos63_vol\n                      5.0G  139M  4.6G   3% \/mydata\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This post will covers the steps to create additional Logical volume manager (LVM) on CentOS 6.3. This will very useful when the production system facing run out of disk space&#8230;<\/p>\n","protected":false},"author":6,"featured_media":3620,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2055,1002],"tags":[1254,1536,1546,1554,1555,1556,1713],"class_list":["post-3985","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-lvm","tag-centos-6-3","tag-linux","tag-linux-utilities","tag-logical-volume","tag-logical-volume-manager","tag-lvm","tag-rhel"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/3985","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=3985"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/3985\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/3620"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=3985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=3985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=3985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}