{"id":4130,"date":"2015-01-27T19:03:35","date_gmt":"2015-01-27T11:03:35","guid":{"rendered":"http:\/\/rmohan.com\/?p=4130"},"modified":"2015-01-27T19:03:35","modified_gmt":"2015-01-27T11:03:35","slug":"create-a-logical-volume-using-linux-lvm","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=4130","title":{"rendered":"Create a Logical Volume using Linux LVM"},"content":{"rendered":"<p>If you like this article, please +1 or Recommend via FB with the provided buttons above:<br \/>\nArticle ID: 137<br \/>\nby: Reese K.<br \/>\nPosted: 16 Oct, 2013<br \/>\nLast updated: 21 Oct, 2013<br \/>\nViews: 561<\/p>\n<p>Create a Logical Volume using Linux LVM<br \/>\nThis example uses a local hard disk to create a logical volume.<\/p>\n<p>1. partition the disk as normal using fdisk.  I new the fdisk options ahead of time from having done this before.<\/p>\n<p>EDS etldev1 ~ # FDISK_CMDLIST=&#8221;n\\np\\n1\\n\\nt\\n8e\\nw\\n&#8221;<br \/>\nEDS etldev1 ~ # echo -e -n &#8220;${FDISK_CMDLIST}&#8221; | ( fdisk \/dev\/sdc )<br \/>\nThis is the same thing as doing it from the fdisk menu as follows:<\/p>\n<p>EDS etldev1 ~ # fdisk \/dev\/sdc<\/p>\n<p>WARNING: DOS-compatible mode is deprecated. It&#8217;s strongly recommended to<br \/>\n         switch off the mode (command &#8216;c&#8217;) and change display units to<br \/>\n         sectors (command &#8216;u&#8217;).<\/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-17769, default 1):<br \/>\nUsing default value 1<br \/>\nLast cylinder, +cylinders or +size{K,M,G} (1-17769, default 17769):<br \/>\nUsing default value 17769<\/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): w<br \/>\nThe partition table has been altered!<\/p>\n<p>Calling ioctl() to re-read partition table.<br \/>\nSyncing disks.<br \/>\n2. Initialize the partition for use by LVM using pvcreate.<\/p>\n<p>3. Create a volume group using the block device specified in pvcreate<\/p>\n<p>4. Create a logical volume in the volume group from step 3<\/p>\n<p>Steps 2, 3, 4 are illustrated below<\/p>\n<p>EDS etldev1 ~ # pvcreate \/dev\/sdc1<br \/>\n  Physical volume &#8220;\/dev\/sdc1&#8221; successfully created<\/p>\n<p>EDS etldev1 ~ # vgcreate vg_dwstore \/dev\/sdc1<br \/>\n  Volume group &#8220;vg_dwstore&#8221; successfully created<\/p>\n<p>EDS etldev1 ~ # vgs<br \/>\n  VG              #PV #LV #SN Attr   VSize   VFree<br \/>\n  vg_dwstore        1   0   0 wz&#8211;n- 136.11g 136.11g<br \/>\n  vg_etldev1        1   8   0 wz&#8211;n- 135.62g 124.00m<br \/>\n  vg_etldev1_data   1   1   0 wz&#8211;n- 136.12g      0 <\/p>\n<p>EDS etldev1 ~ # lvcreate -L 136.11g -n lv_dwstore vg_dwstore<br \/>\n  Rounding up size to full physical extent 136.11 GiB<br \/>\n  Logical volume &#8220;lv_dwstore&#8221; created<\/p>\n<p>EDS etldev1 ~ # mkfs.ext4 \/dev\/vg_dwstore\/lv_dwstore<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 \/>\n8921088 inodes, 35681280 blocks<br \/>\n1784064 blocks (5.00%) reserved for the super user<br \/>\nFirst data block=0<br \/>\nMaximum filesystem blocks=4294967296<br \/>\n1089 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, 7962624, 11239424, 20480000, 23887872<\/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 39 mounts or<br \/>\n180 days, whichever comes first.  Use tune2fs -c or -i to override.<br \/>\nEDS etldev1 ~ #<br \/>\nEDS etldev1 ~ # mkdir \/dwstore<br \/>\nEDS etldev1 ~ # mount \/dev\/vg_dwstore\/lv_dwstore \/dwstore<br \/>\nEDS etldev1 ~ # df -Ph \/dwstore<br \/>\nFilesystem            Size  Used Avail Use% Mounted on<br \/>\n\/dev\/mapper\/vg_dwstore-lv_dwstore  134G  188M  127G   1% \/dwstore<br \/>\nEDS etldev1 ~ #<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you like this article, please +1 or Recommend via FB with the provided buttons above: Article ID: 137 by: Reese K. Posted: 16 Oct, 2013 Last updated: 21 Oct, 2013 Views: 561<\/p>\n<p>Create a Logical Volume using Linux LVM This example uses a local hard disk to create a logical volume.<\/p>\n<p>1. partition the [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,17],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4130"}],"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=4130"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4130\/revisions"}],"predecessor-version":[{"id":4131,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4130\/revisions\/4131"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}