{"id":61,"date":"2022-03-29T10:17:00","date_gmt":"2022-03-29T08:17:00","guid":{"rendered":"https:\/\/blubb.fish\/?p=61"},"modified":"2022-03-25T10:27:07","modified_gmt":"2022-03-25T09:27:07","slug":"usefull-lvm-commands","status":"publish","type":"post","link":"https:\/\/blubb.fish\/index.php\/2022\/03\/29\/usefull-lvm-commands\/","title":{"rendered":"Usefull LVM commands"},"content":{"rendered":"\n<p>This commands will be used when working with LVM<\/p>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>pvs:<\/li><\/ul>\n\n\n\n<p>pvs shows information about the physical devices<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ pvs                                                                                                              \n  PV         VG     Fmt  Attr PSize  PFree \n  \/dev\/sda   datavg lvm2 a--  &lt;1.82t &lt;1.14t\n<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>vgs:<\/li><\/ul>\n\n\n\n<p>vgs shows inforamtion about the volume group built ontop of the physical volume(s)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vgs                                                                                                              \n  VG     #PV #LV #SN Attr   VSize  VFree \n  datavg   1   2   0 wz--n- &lt;1.82t &lt;1.14t<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>lvs:<\/li><\/ul>\n\n\n\n<p>lvs shows the actual volumes which are usable and can be mounted<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ lvs                                                                                                              \n  LV     VG     Attr       LSize   Pool \n  datalv datavg -wi-ao---- 500.00g                                                    \n  vmslv  datavg -wi-ao---- 200.00g<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>pvcreate:<\/li><\/ul>\n\n\n\n<p>pvcreate is used to add new disks to the LVM manager. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ pvcreate \/dev\/sdb<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>vgcreate:<\/li><\/ul>\n\n\n\n<p>Create a new Volume Group ontop of an Physical Volume Group<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vgcreate testvg \/dev\/sdb<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>lvcreate:<\/li><\/ul>\n\n\n\n<p>Create an logical volume on an Volume Group. <\/p>\n\n\n\n<p>Size can be set with -L or -l. <\/p>\n\n\n\n<p>-L is used for fixed sizes like -L1G or -L50G or -L1T<\/p>\n\n\n\n<p>-l sets size in % of free space of the VG ex.: -l50%VG or -l100%FREE<\/p>\n\n\n\n<p>This will create a volume with 100 % free space used<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lvcreate -n testlv -l100%FREE testvg<\/code><\/pre>\n\n\n\n<p>This will create a volume with 1G Size<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lvcreate -n testlv -L1G testvg<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>pvremove:<\/li><\/ul>\n\n\n\n<p>will remove the physical disk from the LVM configuration<\/p>\n\n\n\n<p>This will not delete the Physical disk. has to be done seperatly<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pvremove \/dev\/sdb<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>vgremove:<\/li><\/ul>\n\n\n\n<p>removes a vg <\/p>\n\n\n\n<p>can be forced with -f option<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vgremove testvg<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>lvremove:<\/li><\/ul>\n\n\n\n<p>remove an LV. has to be unmounted to work and no more open files are allowed<\/p>\n\n\n\n<p>can be forced with -f (will not work if still open files)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lvremove \/dev\/mapper\/testvg-testlv<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>pvdisplay:<\/li><\/ul>\n\n\n\n<p>shows more detailed information of the pv<\/p>\n\n\n\n<p>show for all pv (only have one in my setup)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ pvdisplay                                                                                                        \n  --- Physical volume ---\n  PV Name               \/dev\/sda\n  VG Name               datavg\n  PV Size               &lt;1.82 TiB \/ not usable &lt;1.09 MiB\n  Allocatable           yes \n  PE Size               4.00 MiB\n  Total PE              476932\n  Free PE               297732\n  Allocated PE          179200\n  PV UUID               dnQPBJ-DSfP-9Z5q-jIsc-UcUo-8exV-d2hA0h<\/code><\/pre>\n\n\n\n<p>show for specific pv<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ pvdisplay \/dev\/sda                                                                                                        \n  --- Physical volume ---\n  PV Name               \/dev\/sda\n  VG Name               datavg\n  PV Size               &lt;1.82 TiB \/ not usable &lt;1.09 MiB\n  Allocatable           yes \n  PE Size               4.00 MiB\n  Total PE              476932\n  Free PE               297732\n  Allocated PE          179200\n  PV UUID               dnQPBJ-DSfP-9Z5q-jIsc-UcUo-8exV-d2hA0h<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>vgdisplay:<\/li><\/ul>\n\n\n\n<p>Shows detailed information for the Volume Group<\/p>\n\n\n\n<p>show for al vg (only have one in my setup)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vgdisplay datavg                                                                                                 \n  --- Volume group ---\n  VG Name               datavg\n  System ID             \n  Format                lvm2\n  Metadata Areas        1\n  Metadata Sequence No  5\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               &lt;1.82 TiB\n  PE Size               4.00 MiB\n  Total PE              476932\n  Alloc PE \/ Size       179200 \/ 700.00 GiB\n  Free  PE \/ Size       297732 \/ &lt;1.14 TiB\n  VG UUID               Pc8kpf-EU3e-0NBc-x8bv-3Ngt-nz21-gX2veC<\/code><\/pre>\n\n\n\n<p>Show for specific one<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vgdisplay datavg                                                                                                 \n  --- Volume group ---\n  VG Name               datavg\n  System ID             \n  Format                lvm2\n  Metadata Areas        1\n  Metadata Sequence No  5\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               &lt;1.82 TiB\n  PE Size               4.00 MiB\n  Total PE              476932\n  Alloc PE \/ Size       179200 \/ 700.00 GiB\n  Free  PE \/ Size       297732 \/ &lt;1.14 TiB\n  VG UUID               Pc8kpf-EU3e-0NBc-x8bv-3Ngt-nz21-gX2veC<\/code><\/pre>\n\n\n\n<ul class=\"has-large-font-size wp-block-list\"><li>lvdisplay:<\/li><\/ul>\n\n\n\n<p>Display detailed information about the logical volumes<\/p>\n\n\n\n<p>show all logical volumes<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ lvdisplay                                                                                                        \n  --- Logical volume ---\n  LV Path                \/dev\/datavg\/testlv\n  LV Name                testlv\n  VG Name                datavg\n  LV UUID                9a1oSw-7Xn1-tBJ7-HigR-4MfQ-oZVg-hYGp3e\n  LV Write Access        read\/write\n  LV Creation host, time manj, 2022-03-17 17:03:30 +0100\n  LV Status              available\n  # open                 1\n  LV Size                500.00 GiB\n  Current LE             128000\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     256\n  Block device           254:0\n   \n  --- Logical volume ---\n  LV Path                \/dev\/datavg\/test1lv\n  LV Name                test1lv\n  VG Name                datavg\n  LV UUID                nKzhcg-Osom-H89M-2PMp-d767-Bmvr-w6ZQXx\n  LV Write Access        read\/write\n  LV Creation host, time manj, 2022-03-17 18:12:03 +0100\n  LV Status              available\n  # open                 1\n  LV Size                200.00 GiB\n  Current LE             51200\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     256\n  Block device           254:1\n<\/code><\/pre>\n\n\n\n<p>show specific logical volume<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ lvdisplay \/dev\/mapper\/datavg-testlv                                                                              --- Logical volume ---\n  LV Path                \/dev\/datavg\/testlv\n  LV Name                testlv\n  VG Name                datavg\n  LV UUID                9a1oSw-7Xn1-tBJ7-HigR-4MfQ-oZVg-hYGp3e\n  LV Write Access        read\/write\n  LV Creation host, time manj, 2022-03-17 17:03:30 +0100\n  LV Status              available\n  # open                 1\n  LV Size                500.00 GiB\n  Current LE             128000\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     256\n  Block device           254:0<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This commands will be used when working with LVM pvs: pvs shows information about the physical devices vgs: vgs shows inforamtion about the volume group built ontop of the physical volume(s) lvs: lvs shows the actual volumes which are usable and can be mounted pvcreate: pvcreate is used to add new disks to the LVM [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":2,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions\/63"}],"wp:attachment":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}