{"id":68,"date":"2020-10-22T10:11:14","date_gmt":"2020-10-22T02:11:14","guid":{"rendered":"https:\/\/www.db2go.net\/?p=68"},"modified":"2020-10-22T10:12:09","modified_gmt":"2020-10-22T02:12:09","slug":"lvm%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.db2go.net\/?p=68","title":{"rendered":"lvm\u7ba1\u7406"},"content":{"rendered":"<p>\u7ecf\u5e38\u4f7f\u7528lvm\u8fdb\u884c\u76ee\u5f55\u7684\u6269\u5c55,\u8bb0\u5f55\u4e00\u4e0b\u76f8\u5173\u547d\u4ee4\u3002<\/p>\n<p><!--more--><\/p>\n<h2>1.1. \u521b\u5efapv<\/h2>\n<pre><code class=\"language-sh line-numbers\">lvm&gt; pvcreate \/dev\/vdb\n  Physical volume \"\/dev\/vdb\" successfully created.\n<\/code><\/pre>\n<h2>1.2. \u521b\u5efavg<\/h2>\n<pre><code class=\"language-sh line-numbers\">lvm&gt; vgcreate vgdata\n  No command with matching syntax recognised.  Run 'vgcreate --help' for more information.\n  Correct command syntax is:\n  vgcreate VG_new PV ...\n\nlvm&gt; vgcreate vgdata \/dev\/vdb\n  Volume group \"vgdata\" successfully created\nlvm&gt; vgdisplay\n  --- Volume group ---\n  VG Name               vgdata\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               &lt;350.00 GiB\n  PE Size               4.00 MiB\n  Total PE              89599\n  Alloc PE \/ Size       0 \/ 0\n  Free  PE \/ Size       89599 \/ &lt;350.00 GiB\n  VG UUID               Et2eCf-amVd-wDln-6NK1-IDza-YcnC-8XC2Dk\n\n  --- Volume group ---\n  VG Name               centos\n  System ID\n  Format                lvm2\n  Metadata Areas        1\n  Metadata Sequence No  3\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;49.00 GiB\n  PE Size               4.00 MiB\n  Total PE              12543\n  Alloc PE \/ Size       12543 \/ &lt;49.00 GiB\n  Free  PE \/ Size       0 \/ 0\n  VG UUID               3sPMh3-cxGR-wlD3-AhL4-uGfZ-HmCj-kmrPwU\n<\/code><\/pre>\n<h2>1.3. \u521b\u5efalv<\/h2>\n<pre><code class=\"language-sh line-numbers\">lvm&gt; lvcreate -L 100G -n dockerdir vgdata\n  Logical volume \"dockerdir\" created.\nlvm&gt; lvcreate -L 100G -n harbordir  vgdata\n  Logical volume \"harbordir\" created.\nlvm&gt; lvcreate -L 120G -n nfsdir  vgdata\n  Logical volume \"nfsdir\" created.\n\nlvm&gt; lvdisplay vgdata\n  --- Logical volume ---\n  LV Path                \/dev\/vgdata\/dockerdir\n  LV Name                dockerdir\n  VG Name                vgdata\n  LV UUID                NxYNDV-TS7Q-igO3-um3Q-ByHk-GZv2-tomFS0\n  LV Write Access        read\/write\n  LV Creation host, time host-192-168-3-6, 2019-05-27 11:17:48 +0800\n  LV Status              available\n  # open                 0\n  LV Size                100.00 GiB\n  Current LE             25600\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     8192\n  Block device           253:2\n\n  --- Logical volume ---\n  LV Path                \/dev\/vgdata\/harbordir\n  LV Name                harbordir\n  VG Name                vgdata\n  LV UUID                m1lNfZ-QYqv-Lo1n-hTSu-WBy9-yAuv-fGsfNA\n  LV Write Access        read\/write\n  LV Creation host, time host-192-168-3-6, 2019-05-27 11:18:29 +0800\n  LV Status              available\n  # open                 0\n  LV Size                100.00 GiB\n  Current LE             25600\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     8192\n  Block device           253:3\n\n  --- Logical volume ---\n  LV Path                \/dev\/vgdata\/nfsdir\n  LV Name                nfsdir\n  VG Name                vgdata\n  LV UUID                D02GtI-MPdw-Tzuz-tKmD-1TTc-pPOo-j4vGRk\n  LV Write Access        read\/write\n  LV Creation host, time host-192-168-3-6, 2019-05-27 11:18:47 +0800\n  LV Status              available\n  # open                 0\n  LV Size                120.00 GiB\n  Current LE             30720\n  Segments               1\n  Allocation             inherit\n  Read ahead sectors     auto\n  - currently set to     8192\n  Block device           253:4\n\nlvm&gt; exit\n  Exiting.\n<\/code><\/pre>\n<h2>1.4. \u683c\u5f0f\u5316\u78c1\u76d8<\/h2>\n<pre><code class=\"language-sh line-numbers\">mkfs.ext4 \/dev\/vgdata\/dockerdir\nmkfs.ext4 \/dev\/vgdata\/nfsdir\nmkfs.ext4 \/dev\/vgdata\/harbordir\n<\/code><\/pre>\n<h2>1.5. \u521b\u5efa\u6302\u8f7d\u70b9,\u5e76\u6302\u8f7d<\/h2>\n<pre><code class=\"language-sh line-numbers\">[root@host-192-168-3-6 ~]# mkdir \/nfsdata\n[root@host-192-168-3-6 ~]# mkdir \/harbordata\n[root@host-192-168-3-6 ~]# mkdir \/dockerdata\n[root@host-192-168-3-6 ~]# vim \/etc\/fstab\n\n[root@host-192-168-3-6 ~]# cat \/etc\/fstab\n#\n# \/etc\/fstab\n# Created by anaconda on Fri Apr 26 16:10:55 2019\n#\n# Accessible filesystems, by reference, are maintained under '\/dev\/disk'\n# See man pages fstab(5), findfs(8), mount(8) and\/or blkid(8) for more info\n#\n\/dev\/mapper\/centos-root \/                       xfs     defaults        0 0\nUUID=4ec1bdd6-fcd8-48c5-ab4e-f905e9e4df27 \/boot                   xfs     defaults        0 0\n\/dev\/mapper\/centos-swap swap                    swap    defaults        0 0\n\/dev\/vgdata\/dockerdir \/dockerdata ext4 defaults 0 0\n\/dev\/vgdata\/nfsdir \/nfsdata ext4 defaults 0 0\n\/dev\/vgdata\/harbordir \/harbordata ext4 defaults 0 0\n\n\n[root@host-192-168-3-6 ~]# mount -a\n[root@host-192-168-3-6 ~]# df -h\n\u6587\u4ef6\u7cfb\u7edf                      \u5bb9\u91cf  \u5df2\u7528  \u53ef\u7528 \u5df2\u7528% \u6302\u8f7d\u70b9\n\/dev\/mapper\/centos-root        44G  1.3G   43G    3% \/\ndevtmpfs                       16G     0   16G    0% \/dev\ntmpfs                          16G     0   16G    0% \/dev\/shm\ntmpfs                          16G  8.5M   16G    1% \/run\ntmpfs                          16G     0   16G    0% \/sys\/fs\/cgroup\n\/dev\/vda1                    1014M  142M  873M   14% \/boot\n\/dev\/mapper\/vgdata-dockerdir   99G   61M   94G    1% \/dockerdata\n\/dev\/mapper\/vgdata-nfsdir     118G   61M  112G    1% \/nfsdata\n\/dev\/mapper\/vgdata-harbordir   99G   61M   94G    1% \/harbordata\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7ecf\u5e38\u4f7f\u7528lvm\u8fdb\u884c\u76ee\u5f55\u7684\u6269\u5c55,\u8bb0\u5f55\u4e00\u4e0b\u76f8\u5173\u547d\u4ee4\u3002<\/p>\n <a href=\"https:\/\/www.db2go.net\/?p=68\" title=\"lvm\u7ba1\u7406\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">lvm\u7ba1\u7406<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[9],"tags":[],"class_list":["entry","author-suredandan","has-more-link","post-68","post","type-post","status-publish","format-standard","category-linux"],"views":2108,"_links":{"self":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=68"}],"version-history":[{"count":1,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":69,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions\/69"}],"wp:attachment":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}