{"id":1448,"date":"2011-11-16T22:47:15","date_gmt":"2011-11-16T14:47:15","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=1448"},"modified":"2023-04-28T09:50:01","modified_gmt":"2023-04-28T09:50:01","slug":"how-to-setup-additional-lvm-in-centos-5-5","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-setup-additional-lvm-in-centos-5-5\/","title":{"rendered":"How to Setup Additional LVM in CentOS 5.5"},"content":{"rendered":"<p>In this post, i will share on how to setup additional LVM in CentOS 5.5.<\/p>\n<p>1. Assumed that new hard disk 2 (sdb) has been added in this CentOS 5.5 server.<br \/>\n2. Print the current partition table of the hard disk :<\/p>\n<ol>\n<pre class=\"code\">\n[root@server ~]# fdisk -lu\n\nDisk \/dev\/sda: 21.4 GB, 21474836480 bytes\n255 heads, 63 sectors\/track, 2610 cylinders, total 41943040 sectors\nUnits = sectors of 1 * 512 = 512 bytes\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *          63      208844      104391   83  Linux\n\/dev\/sda2          208845     2313359     1052257+  82  Linux swap \/ Solaris\n\/dev\/sda3         2313360    14667344     6176992+  8e  Linux LVM\n\/dev\/sda4        14667345    41929649    13631152+  8e  Linux LVM\n\nDisk \/dev\/sdb: 21.4 GB, 21474836480 bytes\n255 heads, 63 sectors\/track, 2610 cylinders, total 41943040 sectors\nUnits = sectors of 1 * 512 = 512 bytes\n\nDisk \/dev\/sdb doesn't contain a valid partition table\n<\/pre>\n<\/ol>\n<p>3. Create new partition for \/dev\/sdb using below command.<\/p>\n<ol>\n<pre class=\"code\">\n[root@server ~]# fdisk \/dev\/sdb\nDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel\nBuilding a new DOS disklabel. Changes will remain in memory only,\nuntil you decide to write them. After that, of course, the previous\ncontent won't be recoverable.\n\n\nThe number of cylinders for this disk is set to 2610.\nThere is nothing wrong with that, but this is larger than 1024,\nand could in certain setups cause problems with:\n1) software that runs at boot time (e.g., old versions of LILO)\n2) booting and partitioning software from other OSs\n   (e.g., DOS FDISK, OS\/2 FDISK)\nWarning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)\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-2610, default 1):\nUsing default value 1\nLast cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):\nUsing default value 2610\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: 21.4 GB, 21474836480 bytes\n255 heads, 63 sectors\/track, 2610 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sdb1               1        2610    20964793+  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<\/pre>\n<\/ol>\n<ol>\n<pre class=\"code\">\n[root@server ~]# mke2fs -j \/dev\/sdb1\nmke2fs 1.39 (29-May-2006)\nFilesystem label=\nOS type: Linux\nBlock size=4096 (log=2)\nFragment size=4096 (log=2)\n2621440 inodes, 5241198 blocks\n262059 blocks (5.00%) reserved for the super user\nFirst data block=0\nMaximum filesystem blocks=0\n160 block groups\n32768 blocks per group, 32768 fragments per group\n16384 inodes per group\nSuperblock backups stored on blocks:\n        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,\n        4096000\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 24 mounts or\n180 days, whichever comes first.  Use tune2fs -c or -i to override.\n<\/pre>\n<\/ol>\n<p>4. Next create the new partitions for this LVM.<\/p>\n<ol>\n<pre class=\"code\">\n[root@server ~]# pvcreate \/dev\/sdb1\n  Physical volume \"\/dev\/sdb1\" successfully created\n<\/pre>\n<\/ol>\n<p>5. Display the Physical Volume using command below:<\/p>\n<ol>\n<pre class=\"code\">\n[root@server ~]# pvdisplay\n  --- Physical volume ---\n  PV Name               \/dev\/sda4\n  VG Name               VolGroup00\n  PV Size               13.00 GB \/ not usable 3.67 MB\n  Allocatable           yes (but full)\n  PE Size (KByte)       4096\n  Total PE              3327\n  Free PE               0\n  Allocated PE          3327\n  PV UUID               JgYuxF-UJiB-t148-g5WQ-Lx05-Ozk1-13UwAR\n\n  \"\/dev\/sdb1\" is a new physical volume of \"19.99 GB\"\n  --- NEW Physical volume ---\n  PV Name               \/dev\/sdb1\n  VG Name\n  PV Size               19.99 GB\n  Allocatable           NO\n  PE Size (KByte)       0\n  Total PE              0\n  Free PE               0\n  Allocated PE          0\n  PV UUID               246F8V-FMTR-WNK0-9305-q2sf-PKtC-VQXOQr\n<\/pre>\n<\/ol>\n<p>6. Create new volume group for \/dev\/sdb1. Assumed that previous volume goup is VolGroup00. So next volume group will be VolGroup01.<\/p>\n<ol>\n<pre class=\"code\">\n[root@server ~]# vgcreate VolGroup01 \/dev\/sdb1\n  Volume group \"VolGroup01\" successfully created\n<\/pre>\n<\/ol>\n<p>7. Display the existing Volume Group.<\/p>\n<ol>\n<pre class=\"code\">\n[root@server ~]# vgdisplay\n  --- Volume group ---\n  VG Name               VolGroup01\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               19.99 GB\n  PE Size               4.00 MB\n  Total PE              5118\n  Alloc PE \/ Size       0 \/ 0\n  Free  PE \/ Size       5118 \/ 19.99 GB\n  VG UUID               tvLVhu-6Nzo-jB0b-oZQ4-VY30-9TP4-Dhxvvm\n\n  --- Volume group ---\n  VG Name               VolGroup00\n  System ID\n  Format                lvm2\n  Metadata Areas        1\n  Metadata Sequence No  2\n  VG Access             read\/write\n  VG Status             resizable\n  MAX LV                0\n  Cur LV                1\n  Open LV               1\n  Max PV                0\n  Cur PV                1\n  Act PV                1\n  VG Size               13.00 GB\n  PE Size               4.00 MB\n  Total PE              3327\n  Alloc PE \/ Size       3327 \/ 13.00 GB\n  Free  PE \/ Size       0 \/ 0\n  VG UUID               3XozzT-3A3w-6eXs-XoEb-yRN1-v9FM-N0YheL\n<\/pre>\n<\/ol>\n<p>8. Create logical volumes with the name of optvol into VolGroup01 volume group.<\/p>\n<ol>\n<pre class=\"code\">\n[root@server ~]# lvcreate --name optvol -l 100%FREE VolGroup01\n  Logical volume \"optvol\" created\n<\/pre>\n<\/ol>\n<p>9. Display the logical volumes.<\/p>\n<ol>\n<pre class=\"code\">\n[root@server ~]# lvdisplay\n  --- Logical volume ---\n  LV Name                \/dev\/VolGroup01\/optvol\n  VG Name                VolGroup01\n  LV UUID                YXkMnR-l7gH-tj0r-dCUt-Ncl7-aTmb-Vas4Tp\n  LV Write Access        read\/write\n  LV Status              available\n  # open                 0\n  LV Size                19.99 GB\n  Current LE             5118\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     256\n  Block device           253:1\n\n  --- Logical volume ---\n  LV Name                \/dev\/VolGroup00\/datavol\n  VG Name                VolGroup00\n  LV UUID                KowzAO-WWMj-O0xw-IY31-Gfqv-sjaE-nYvdhk\n  LV Write Access        read\/write\n  LV Status              available\n  # open                 1\n  LV Size                13.00 GB\n  Current LE             3327\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     256\n  Block device           253:0\n<\/pre>\n<\/ol>\n<p>10. creating a file with the mke2fs command<\/p>\n<ol>\n<pre class=\"code\">\n[root@server ~]# mke2fs -j \/dev\/VolGroup01\/optvol\nmke2fs 1.39 (29-May-2006)\nFilesystem label=\nOS type: Linux\nBlock size=4096 (log=2)\nFragment size=4096 (log=2)\n2621440 inodes, 5240832 blocks\n262041 blocks (5.00%) reserved for the super user\nFirst data block=0\nMaximum filesystem blocks=0\n160 block groups\n32768 blocks per group, 32768 fragments per group\n16384 inodes per group\nSuperblock backups stored on blocks:\n        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,\n        4096000\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 38 mounts or\n180 days, whichever comes first.  Use tune2fs -c or -i to override.\n<\/pre>\n<\/ol>\n<ol>\n<pre class=\"code\">\n[root@server ~]# e2label \/dev\/VolGroup01\/optvol \/opt\n<\/pre>\n<\/ol>\n<ol>\n<pre class=\"code\">\n[root@server ~]# vi \/etc\/fstab\n<\/pre>\n<\/ol>\n<ol>\n<pre class=\"code\">\n[root@server ~]# mount \/opt\n<\/pre>\n<\/ol>\n<ol>\n<pre class=\"code\">\n[root@server ~]# df -lh\nFilesystem            Size  Used Avail Use% Mounted on\n\/dev\/sda3             5.8G  4.3G  1.2G  79% \/\n\/dev\/sda1              99M   12M   83M  13% \/boot\ntmpfs                 506M     0  506M   0% \/dev\/shm\n\/dev\/mapper\/VolGroup00-datavol\n                       13G  855M   12G   7% \/data\n\/dev\/mapper\/VolGroup01-optvol\n                       20G  173M   19G   1% \/opt\n<\/pre>\n<\/ol>\n<ol>\n<pre class=\"code\">\n[root@server ~]# fdisk -lu\n\nDisk \/dev\/sda: 21.4 GB, 21474836480 bytes\n255 heads, 63 sectors\/track, 2610 cylinders, total 41943040 sectors\nUnits = sectors of 1 * 512 = 512 bytes\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *          63      208844      104391   83  Linux\n\/dev\/sda2          208845     2313359     1052257+  82  Linux swap \/ Solaris\n\/dev\/sda3         2313360    14667344     6176992+  8e  Linux LVM\n\/dev\/sda4        14667345    41929649    13631152+  8e  Linux LVM\n\nDisk \/dev\/sdb: 21.4 GB, 21474836480 bytes\n255 heads, 63 sectors\/track, 2610 cylinders, total 41943040 sectors\nUnits = sectors of 1 * 512 = 512 bytes\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sdb1              63    41929649    20964793+  8e  Linux LVM\n<\/pre>\n<\/ol>\n<p>References:<\/p>\n<ol>\n<pre class=\"code\">\nhttps:\/\/wiki.archlinux.org\/index.php\/LVM\nhttp:\/\/vr.org\/docs\/centos\/5\/html\/Cluster_Logical_Volume_Manager\/LV_create.html\nhttp:\/\/serverfault.com\/questions\/41904\/volume-group-out-of-space-how-do-i-reclaim-it\nhttp:\/\/www.idevelopment.info\/data\/Unix\/Linux\/LINUX_ManagingPhysicalLogicalVolumes.shtml\nhttp:\/\/en.gentoo-wiki.com\/wiki\/Root_filesystem_over_LVM2,_DM-Crypt_and_RAID\nhttp:\/\/wingloon.com\/2009\/01\/16\/setup-additional-lvm-in-centos-52\/\nhttp:\/\/rute.2038bug.com\/node22.html.gz\n<\/pre>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In this post, i will share on how to setup additional LVM in CentOS 5.5. 1. Assumed that new hard disk 2 (sdb) has been added in this CentOS 5.5&#8230;<\/p>\n","protected":false},"author":6,"featured_media":349,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1002],"tags":[1246,1536,1554,1556],"class_list":["post-1448","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lvm","tag-centos-5-5","tag-linux","tag-logical-volume","tag-lvm"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1448","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=1448"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1448\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/349"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=1448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=1448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=1448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}