{"id":270,"date":"2013-02-11T09:42:53","date_gmt":"2013-02-11T08:42:53","guid":{"rendered":"http:\/\/www.tinone71.com\/wordpress\/?p=270"},"modified":"2015-01-09T15:47:38","modified_gmt":"2015-01-09T15:47:38","slug":"create-and-remove-physical-volumes-assign-physical-volumes-to-volume-groups-create-and-delete-logical-volumes-create-and-remove-physical-volumes","status":"publish","type":"post","link":"https:\/\/www.tinone71.com\/wp\/?p=270","title":{"rendered":"Create and remove physical volumes, assign physical volumes to volume groups, create and delete logical volumes Create and remove physical volumes"},"content":{"rendered":"<div style=\"\" class=\"ssag-opads-main     \" ><\/div><p>Creating a physical volume in LVM is the first step in the LVM setup. Its the part where you actually tell Red Hat Enterprise Linux that you want a disk to be used for LVM.<\/p>\n<p>pvcreate is the command used to add the physical volumes, or physical partitions.<\/p>\n<p>~] pvcreate \/dev\/sdb<br \/>\n~] Physical volume &#8220;\/dev\/sdb&#8221; successfully created<\/p>\n<p>pvremove is used to disassociate the volume from LVM.<\/p>\n<p>~] pvremove \/dev\/sdb<br \/>\n~] Labels on physical volume &#8220;\/dev\/sdb&#8221; successfully wiped<\/p>\n<p>Assign physical volumes to volume groups<\/p>\n<p>Once that physical volume has been created we can add it to a volume group with the vgcreate or vgextend (if the volume group has already been created).<\/p>\n<p>If the volume group does not exist, you can create it and add physical volumes in one shot:<\/p>\n<p>~] vgextend MyVolGroup \/dev\/sdc<br \/>\nNo physical volume label read from \/dev\/sdc<br \/>\nPhysical volume &#8220;\/dev\/sdc&#8221; successfully created<br \/>\nVolume group &#8220;MyVolGroup&#8221; successfully extended<\/p>\n<p>To assign a new physical volume to an existing volume group we use vgextend:<\/p>\n<p>~] vgextend MyVolGroup \/dev\/sdc<br \/>\nVolume group &#8220;MyVolGroup&#8221; successfully extended<\/p>\n<p>Similarly if we want to remove \/dev\/sdc from that group we would run &#8221;vgreduce&#8221;:<\/p>\n<p>~] vgreduce MyVolGroup \/dev\/sdc<br \/>\nRemoved &#8220;\/dev\/sdc&#8221; from volume group &#8220;MyVolGroup&#8221;<\/p>\n<p>Create and delete logical volumes<\/p>\n<p>Logical Volumes have similar commands to create and delete as Volume Groups and Physical Volumes.<\/p>\n<p>To create a new logical volume:<\/p>\n<p>~] lvcreate -L 100M MyVolGroup<br \/>\nLogical volume &#8220;lvol0&#8221; created<\/p>\n<p>To display the volume after for confirmation:<\/p>\n<p>~] lvdisplay MyVolGroup<br \/>\n&#8212; Logical volume &#8212;<br \/>\nLV Name \/dev\/MyVolGroup\/lvol0<br \/>\nVG Name MyVolGroup<br \/>\nLV UUID zwLMev-i63w-7Jpk-XuqZ-VGl7-89Ov-WpoewP<br \/>\nLV Write Access read\/write<br \/>\nLV Status available<br \/>\n# open 0<br \/>\nLV Size 100.00 MiB<br \/>\nCurrent LE 25<br \/>\nSegments 1<br \/>\nAllocation inherit<br \/>\nRead ahead sectors auto<br \/>\n&#8211; currently set to 256<br \/>\nBlock device 253:2<\/p>\n<p>To delete the logical volume you would use the LV Name listed in the results of lvdisplay:<\/p>\n<p>:::bash ~] lvremove \/dev\/MyVolGroup\/lvol0 Do you really want to remove active logical volume lvol0? [y\/n]: y Logical volume &#8220;lvol0&#8221; successfully removed<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a physical volume in LVM is the first step in the LVM setup. Its the part where<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/270"}],"collection":[{"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=270"}],"version-history":[{"count":1,"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":374,"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions\/374"}],"wp:attachment":[{"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tinone71.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}