{"id":2613,"date":"2020-04-09T11:18:02","date_gmt":"2020-04-09T11:18:02","guid":{"rendered":"https:\/\/wiki.thomasandsofia.com\/?p=2613"},"modified":"2020-04-10T01:49:53","modified_gmt":"2020-04-10T01:49:53","slug":"3-volume-group-administration","status":"publish","type":"post","link":"https:\/\/wiki.thomasandsofia.com\/?p=2613","title":{"rendered":"3. Volume Group Administration"},"content":{"rendered":"<p><a href=\"\/2-lvm-logical-volumes\/\">&lt; 2 LVM Logical Volumes<\/a> | <a href=\"\/lvm-commands\/\">Commands<\/a> | <a href=\"\/4-thin-provisioned-logical-volumes\/\">4 Thin Provisioning &gt;<\/a><\/p>\n<h1>15. Overview of PV Administration<\/h1>\n<h2>Commands<\/h2>\n<h4>Create a Physical Volume: pvcreate<\/h4>\n<pre>pvcreate \/dev\/sda1<\/pre>\n<h4>List available Block devices: lvmdiskscan<\/h4>\n<pre>lvmdiskscan<\/pre>\n<h4>Display Physical Volumes: pvdisplay<\/h4>\n<p>Displays information about a PV<\/p>\n<pre>pvdisplay \/dev\/sda1<\/pre>\n<h4>List Physical Volumes: pvs &amp; pvscan<\/h4>\n<pre>pvs\r\npvscan<\/pre>\n<h4>Prevent\/Allow Allocation of a Physical Volume: pvchange<\/h4>\n<p>Prevent (n) or Allow (y) anyone from\/to using the PV in a Logical Volume<\/p>\n<pre># Prevent Usage\r\npvchange -x n \/dev\/sda1\r\n# Allow Usage\r\npvchange -x y \/dev\/sda1<\/pre>\n<h4>Resize a Physical Volume: pvresize<\/h4>\n<p>This probably works best with virtual disks.\u00a0 Use after the drive itself has been modified to add additional space.<\/p>\n<pre>pvresize<\/pre>\n<h4>Remove a Physical Volume: pvremove<\/h4>\n<p>Will remove the device from pvs (pvscan?) lists. (Removes label information from the drive metadata)<\/p>\n<p>* Must be first removed from any volume groups prior to running this command.\u00a0 See vgreduce below.<\/p>\n<pre>pvremove \/dev\/sda1<\/pre>\n<h4>Remove a disk from a Volume Group: vgreduce<\/h4>\n<pre>vgreduce \/dev\/VOL-GROUP \/dev\/sdb1<\/pre>\n<p>&nbsp;<\/p>\n<h1>16. Volume Group Creation with Options<\/h1>\n<h4>vgcreate Options<\/h4>\n<table>\n<tbody>\n<tr>\n<th>Switch<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>-s<\/td>\n<td>Size of extents (Default 4MB)<\/td>\n<\/tr>\n<tr>\n<td>-p<\/td>\n<td>Maximum Physical Volumes<\/td>\n<\/tr>\n<tr>\n<td>-l<\/td>\n<td>Maximum Logical Volumes<\/td>\n<\/tr>\n<tr>\n<td>Switch<\/td>\n<td>Description<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h1>17. Adding, Removing, Displaying\u00a0 &amp; Scanning Physical Volumes to a Volume Group<\/h1>\n<h4>Add a PV to a Volume Group: vgextend<\/h4>\n<pre>vgextend VOL-GROUP \/dev\/sdc1<\/pre>\n<h4>Display Volume Group Information: vgs &amp; vgdisplay<\/h4>\n<pre>vgs\r\nvgdisplay<\/pre>\n<h4>Scan disks for Volume Groups: vgscan<\/h4>\n<ul>\n<li>Running this command might take some time<\/li>\n<\/ul>\n<pre>vgscan<\/pre>\n<h4>Remove a PV from a Volume Group: vgreduce<\/h4>\n<ul>\n<li>Must first remove any Logical Volumes that might be using the PV<\/li>\n<\/ul>\n<pre>rgreduce VOL-GROUP \/dev\/sdc1<\/pre>\n<h4>Activate \/ Deactivate a Volume Group: pvchange<\/h4>\n<p>See above also<\/p>\n<table>\n<tbody>\n<tr>\n<th>Switch<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>-a y<\/td>\n<td>Activate the Volume Group<\/td>\n<\/tr>\n<tr>\n<td>-a n<\/td>\n<td>Deactivate the Group<br \/>\nPrevents mounting of its LVs<\/td>\n<\/tr>\n<tr>\n<td>-x y<\/td>\n<td>Allow Allocation of Logical Volumes<\/td>\n<\/tr>\n<tr>\n<td>-x n<\/td>\n<td>Disallow Allocation of Logical Volumes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h1>18. Changing the Parameters of a Volume Group<\/h1>\n<p><a href=\"https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062220#overview\" target=\"_blank\" rel=\"noopener\">https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062220#overview<\/a><\/p>\n<p>Stopped taking notes here \ud83d\ude41<\/p>\n<p>&nbsp;<\/p>\n<h1>22. Moving a VG from one server to another<\/h1>\n<p><a href=\"https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062286#overview\" target=\"_blank\" rel=\"noopener\">https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062286#overview<\/a><\/p>\n<p>Move VOL-GROUP (sdc1, sdd1, sde1) From Server1 to Server2<\/p>\n<ul>\n<li>Make the disks visible on Server2<\/li>\n<li>Server1: Make the VOL-GROUP inactive\n<ul>\n<li>pvchange -x n<\/li>\n<\/ul>\n<\/li>\n<li>Server1: vgexport VOL-GROUP<\/li>\n<li>Server2: vgscan<\/li>\n<li>Server2: vgimport<\/li>\n<\/ul>\n<h1>23. vgexport &amp; vgimport<\/h1>\n<p>Lab: Migrate a single disk \/sdg1 vol group.<\/p>\n<h4>Server1: Create the PV, VG, LV, add files and export<\/h4>\n<pre># create the volume group (VG)\r\npvcreate \/dev\/sdg1\r\nvgcreate \/dev\/VG \/dev\/sdg1\r\n\r\n# create 2 logical volumes\r\nlvcreate -L 100G -n LV1 \/dev\/VG\r\nlvcreate -L 100G -n LV2 \/dev\/VG\r\n\r\n# format LV1\r\nmkfs -t ext4 \/dev\/VG\/LV1\r\n\r\n# mount LV1\r\nmkdir \/mnt\/mylv1\r\nmount \/dev\/VG\/LV1 \/mnt\/mylv1\r\n\r\n# create some test files\r\ncd \/mnt\/mylv1\r\ntouch test1 test2 test3\r\nll\r\n\r\n# Attempt to deactivate the VG\r\nvgchange -a n \/dev\/VG\r\n  Logical volume \/VG\/LV1 contains a filesystem in use.\r\n  Can't deactivate volume group \"VG\" with 1 open logical volume(s)\r\n\r\n# unmount the LV, deactivate and export\r\numount \/mnt\/mylv1\r\nvgchange -a n \/dev\/VG\r\nvgexport \/dev\/VG\r\n# pvscan for this VG will show it is in an exported state\r\npvscan\r\n  PV \/dev\/sdg1  is in exported VG VG (500 GiB \/ 400 GiB free)\r\n# get the UUID of the disk\r\nvgdisplay -v VG\r\n  ...\r\n  PV NAME   \/dev\/sdg1\r\n  PV UUID   gobblty-gook-lots-o-stuff-here-long-name<\/pre>\n<h4>Move the drives to Server2<\/h4>\n<pre># Verify the PV is available\r\nfdisk -l\r\npvscan\r\n\u00a0PV \/dev\/sdd1 is in exported VG VG (500 GiB \/ 400 GiB free)\r\n# note: ^ the disk id has changed from \/sdg1 to sdd1\r\n\r\n#import the volume group and activate\r\nimport \/dev\/VG\r\n  Volume group \"VG\" successfully imported\r\nvgchange -x y \/dev\/VG\r\n  2 logical volume(s) in volume group \"VG\" now active\r\nvgdisplay -v VG\r\n  ...\r\n  PV NAME \/dev\/sdd1\r\n  PV UUID gobblty-gook-lots-o-stuff-here-long-name\r\n\r\n# mount the logical volume\r\nmkdir \/mnt\/mynewlv1\r\nmount \/dev\/VG\/LV \/mnt\/mynewlv1\r\n\r\n# test\r\ncd \/mnt\/mynewlv1\r\nll\r\n  test1\r\n  test2\r\n  test3<\/pre>\n<p>&nbsp;<\/p>\n<h1>24. LVM Mirroring<\/h1>\n<p><a href=\"https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062332#overview\" target=\"_blank\" rel=\"noopener\">https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062332#overview<\/a><\/p>\n<p>Requires minimum 2 drives.\u00a0 Data is copied to multiple drives at the same time.<\/p>\n<ul>\n<li>Uses 2x as much drive space.<\/li>\n<li>-m1 = 1 mirror copy (total spaced used = 2x -L)<\/li>\n<li>-m2 = 2 mirror copies (total space used = 3x -L)<\/li>\n<\/ul>\n<pre>lvcreate --type mirror -L50G -m1 -n LV VG<\/pre>\n<h1>25. LV Extension<\/h1>\n<p>How to extend (increase the size) of an existing, formatted Logical Volume<\/p>\n<ul>\n<li>Verify there is enough space in the VG<\/li>\n<li>Extend the LV&#8217;s size<\/li>\n<li>Extend the LV&#8217;s file system<\/li>\n<\/ul>\n<pre># Check the size of the LV's Volume Group to make sure enough free space is available.# find the LVs VG\r\nlvdisplay VG# show the used space of the VGs\r\nvgs# extend the size of the LV\r\nlvextend -L +SIZE \/dev\/VG\/LV# Now resize the filesystem to match the size of the disk\r\nresize2fs \/dev\/VG\/LV<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt; 2 LVM Logical Volumes | Commands | 4 Thin Provisioning &gt; 15. Overview of PV Administration Commands Create a Physical Volume: pvcreate pvcreate \/dev\/sda1 List available Block devices: lvmdiskscan lvmdiskscan Display Physical Volumes: pvdisplay Displays information about a PV pvdisplay \/dev\/sda1 List Physical Volumes: pvs &amp; pvscan pvs pvscan Prevent\/Allow Allocation of a Physical ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/wiki.thomasandsofia.com\/?p=2613\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[],"class_list":["post-2613","post","type-post","status-publish","format-standard","hentry","category-logical-volume-manager"],"_links":{"self":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/2613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2613"}],"version-history":[{"count":5,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/2613\/revisions"}],"predecessor-version":[{"id":2633,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/2613\/revisions\/2633"}],"wp:attachment":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}