{"id":204085,"date":"2020-11-07T08:18:08","date_gmt":"2020-11-07T00:18:08","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=204085"},"modified":"2020-10-26T19:19:04","modified_gmt":"2020-10-26T11:19:04","slug":"linux-lvm-reduce","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-lvm-reduce.html","title":{"rendered":"\u5982\u4f55\u5728Linux\u4e2d\u7f29\u5c0fLVM\u5927\u5c0f\uff08\u903b\u8f91\u5377\u8c03\u6574\uff09"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5f53\u4f60\u5728 LVM \u4e2d\u7684\u78c1\u76d8\u7a7a\u95f4\u8017\u5c3d\u65f6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f29\u5c0f\u73b0\u6709\u7684\u6ca1\u6709\u4f7f\u7528\u5168\u90e8\u7a7a\u95f4\u7684 LVM\uff0c\u800c\u4e0d\u662f\u589e\u52a0\u4e00\u4e2a\u65b0\u7684\u7269\u7406\u78c1\u76d8\uff0c\u5728\u5377\u7ec4\u4e0a\u817e\u51fa\u4e00\u4e9b\u7a7a\u95f2\u7a7a\u95f4\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u51cf\u5c11\/\u7f29\u5c0f\u903b\u8f91\u5377\u662f\u6570\u636e\u635f\u574f\u7684\u6700\u9ad8\u98ce\u9669\u3002\u6240\u4ee5\uff0c\u5982\u679c\u53ef\u80fd\u7684\u8bdd\uff0c\u5c3d\u91cf\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u4f46\u5982\u679c\u6ca1\u6709\u5176\u4ed6\u9009\u62e9\u7684\u8bdd\uff0c\u90a3\u5c31\u7ee7\u7eed\u3002<\/p>\n

\u7f29\u51cf LVM \u4e4b\u524d\uff0c\u5efa\u8bae\u5148\u505a\u4e00\u4e2a\u5907\u4efd\u3002\u5f53\u4f60\u5728 LVM \u4e2d\u7684\u78c1\u76d8\u7a7a\u95f4\u8017\u5c3d\u65f6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f29\u5c0f\u73b0\u6709\u7684\u6ca1\u6709\u4f7f\u7528\u5168\u90e8\u7a7a\u95f4\u7684 LVM\uff0c\u800c\u4e0d\u662f\u589e\u52a0\u4e00\u4e2a\u65b0\u7684\u7269\u7406\u78c1\u76d8\uff0c\u5728\u5377\u7ec4\u4e0a\u817e\u51fa\u4e00\u4e9b\u7a7a\u95f2\u7a7a\u95f4\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1a \u5728 GFS2 \u6216\u8005 XFS \u6587\u4ef6\u7cfb\u7edf\u4e0a\u4e0d\u652f\u6301\u7f29\u5c0f\u3002<\/p>\n

\u5982\u679c\u4f60\u662f\u903b\u8f91\u5377\u7ba1\u7406 \uff08LVM\uff09 \u7684\u65b0\u624b\uff0c\u6211\u5efa\u8bae\u4f60\u4ece\u6211\u4eec\u4e4b\u524d\u7684\u6587\u7ae0\u5f00\u59cb\u5b66\u4e60\u3002<\/p>\n

\"\"<\/p>\n

    \n\u7b2c\u4e00\u90e8\u5206\uff1a\u5982\u4f55\u5728 Linux \u4e2d\u521b\u5efa\/\u914d\u7f6e LVM\uff08\u903b\u8f91\u5377\u7ba1\u7406\uff09
    \n\u7b2c\u4e8c\u90e8\u5206\uff1a\u5982\u4f55\u5728 Linux \u4e2d\u6269\u5c55\/\u589e\u52a0 LVM\uff08\u903b\u8f91\u5377\u8c03\u6574\uff09<\/ol>\n

    \"\"<\/p>\n

    \u51cf\u5c11\u903b\u8f91\u5377\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n

      \n\u5378\u8f7d\u6587\u4ef6\u7cfb\u7edf
      \n\u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf\u662f\u5426\u6709\u4efb\u4f55\u9519\u8bef
      \n\u7f29\u5c0f\u6587\u4ef6\u7cfb\u7edf\u7684\u5927\u5c0f
      \n\u7f29\u5c0f\u903b\u8f91\u5377\u7684\u5927\u5c0f
      \n\u91cd\u65b0\u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf\u662f\u5426\u5b58\u5728\u9519\u8bef\uff08\u53ef\u9009\uff09
      \n\u6302\u8f7d\u6587\u4ef6\u7cfb\u7edf
      \n\u68c0\u67e5\u51cf\u5c11\u540e\u7684\u6587\u4ef6\u7cfb\u7edf\u5927\u5c0f<\/ol>\n

      \u6bd4\u5982\uff1a \u4f60\u6709\u4e00\u4e2a 100GB \u7684\u6ca1\u6709\u4f7f\u7528\u5168\u90e8\u7a7a\u95f4\u7684 LVM\uff0c\u4f60\u60f3\u628a\u5b83\u51cf\u5c11\u5230 80GB\uff0c\u8fd9\u6837 20GB \u53ef\u4ee5\u7528\u4e8e\u5176\u4ed6\u7528\u9014\u3002<\/p>\n

      \r\n# df -h \/testlvm1\r\n \r\nFilesystem              Size Used Avail Use% Mounted on\r\n\/dev\/mapper\/vg01-lv002  100G 15G  85G   12%  \/testlvm1\r\n<\/pre>\n
      \u5378\u8f7d\u6587\u4ef6\u7cfb\u7edf<\/strong><\/div>\n

      \u4f7f\u7528 umount \u547d\u4ee4\u5378\u8f7d\u6587\u4ef6\u7cfb\u7edf\uff1a<\/p>\n

      \r\n# umount \/testlvm1\r\n<\/pre>\n
      \u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf\u662f\u5426\u6709\u4efb\u4f55\u9519\u8bef<\/strong><\/div>\n

      \u4f7f\u7528 e2fsck \u547d\u4ee4\u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf\u662f\u5426\u6709\u9519\u8bef\uff1a<\/p>\n

      \r\n# e2fsck -f \/dev\/mapper\/vg01-lv002\r\n \r\ne2fsck 1.42.9 (28-Dec-2013)\r\nPass 1: Checking inodes, blocks, and sizes\r\nPass 2: Checking directory structure\r\nPass 3: Checking directory connectivity\r\nPass 4: Checking reference counts\r\nPass 5: Checking group summary information\r\n\/dev\/mapper\/vg01-lv002: 13\/6553600 files (0.0% non-contiguous), 12231854\/26212352 blocks\r\n<\/pre>\n
      \u7f29\u5c0f\u6587\u4ef6\u7cfb\u7edf<\/strong><\/div>\n

      \u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u628a testlvm1 \u6587\u4ef6\u7cfb\u7edf\u4ece 100GB \u7f29\u5c0f\u5230 80GB\u3002<\/p>\n

      \u6587\u4ef6\u7cfb\u7edf\u5927\u5c0f\u8c03\u6574\u7684\u5e38\u7528\u8bed\u6cd5\uff08resize2fs\uff09\uff1a<\/p>\n

      \r\nresize2fs [\u73b0\u6709\u903b\u8f91\u5377\u540d] [\u65b0\u7684\u6587\u4ef6\u7cfb\u7edf\u5927\u5c0f]\r\n<\/pre>\n

      \u5b9e\u9645\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

      \r\n# resize2fs \/dev\/mapper\/vg01-lv002 80G\r\n \r\nresize2fs 1.42.9 (28-Dec-2013)\r\nResizing the filesystem on \/dev\/mapper\/vg01-lv002 to 28321400 (4k) blocks.\r\nThe filesystem on \/dev\/mapper\/vg01-lv002 is now 28321400 blocks long.\r\n<\/pre>\n
      \u51cf\u5c11\u903b\u8f91\u5377 \uff08LVM\uff09 \u5bb9\u91cf<\/strong><\/div>\n

      \u73b0\u5728\u4f7f\u7528 lvreduce \u547d\u4ee4\u7f29\u5c0f\u903b\u8f91\u5377\uff08LVM\uff09 \u7684\u5927\u5c0f\u3002\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\uff0c \/dev\/mapper\/vg01-lv002 \u5c06\u628a\u903b\u8f91\u5377 \uff08LVM\uff09 \u4ece 100GB \u7f29\u5c0f\u5230 80GB\u3002<\/p>\n

      LVM \u7f29\u51cf \uff08lvreduce\uff09 \u7684\u5e38\u7528\u8bed\u6cd5\uff1a<\/p>\n

      \r\nlvreduce [\u65b0\u7684 LVM \u5927\u5c0f] [\u73b0\u6709\u903b\u8f91\u5377\u540d\u79f0]\r\n<\/pre>\n

      \u5b9e\u9645\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

      \r\n# lvreduce -L 80G \/dev\/mapper\/vg01-lv002\r\n \r\nWARNING: Reducing active logical volume to 80.00 GiB\r\nTHIS MAY DESTROY YOUR DATA (filesystem etc.)\r\nDo you really want to reduce lv002? [y\/n]: y\r\nReducing logical volume lv002 to 80.00 GiB\r\nLogical volume lv002 successfully resized\r\n<\/pre>\n
      \u53ef\u9009\uff1a\u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf\u662f\u5426\u6709\u9519\u8bef<\/strong><\/div>\n

      \u7f29\u51cf LVM \u540e\u518d\u6b21\u68c0\u67e5\u6587\u4ef6\u7cfb\u7edf\u662f\u5426\u6709\u9519\u8bef\uff1a<\/p>\n

      \r\n# e2fsck -f \/dev\/mapper\/vg01-lv002\r\n \r\ne2fsck 1.42.9 (28-Dec-2013)\r\nPass 1: Checking inodes, blocks, and sizes\r\nPass 2: Checking directory structure\r\nPass 3: Checking directory connectivity\r\nPass 4: Checking reference counts\r\nPass 5: Checking group summary information\r\n\/dev\/mapper\/vg01-lv002: 13\/4853600 files (0.0% non-contiguous), 1023185\/2021235 blocks\r\n<\/pre>\n
      \u6302\u8f7d\u6587\u4ef6\u7cfb\u7edf\u5e76\u68c0\u67e5\u7f29\u5c0f\u540e\u7684\u5927\u5c0f<\/strong><\/div>\n

      \u6700\u540e\u6302\u8f7d\u6587\u4ef6\u7cfb\u7edf\uff0c\u5e76\u68c0\u67e5\u7f29\u5c0f\u540e\u7684\u6587\u4ef6\u7cfb\u7edf\u5927\u5c0f\u3002<\/p>\n

      \u4f7f\u7528 mount \u547d\u4ee4\u6302\u8f7d\u903b\u8f91\u5377\uff1a<\/p>\n

      \r\n# mount \/testlvm1\r\n<\/pre>\n

      \u4f7f\u7528 df \u547d\u4ee4\u68c0\u67e5\u6302\u8f7d\u7684\u5377\u3002<\/p>\n

      \r\n# df -h \/testlvm1\r\n \r\nFilesystem              Size Used Avail Use% Mounted on\r\n\/dev\/mapper\/vg01-lv002  80G  15G  65G   18%  \/testlvm1\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

      \u5f53\u4f60\u5728 LVM \u4e2d\u7684\u78c1\u76d8\u7a7a\u95f4\u8017\u5c3d\u65f6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f29\u5c0f\u73b0\u6709\u7684\u6ca1\u6709\u4f7f\u7528\u5168\u90e8\u7a7a\u95f4\u7684 LVM\uff0c\u800c\u4e0d\u662f\u589e\u52a0\u4e00\u4e2a\u65b0\u7684\u7269\u7406\u78c1\u76d8\uff0c\u5728\u5377\u7ec4\u4e0a\u817e\u51fa\u4e00\u4e9b\u7a7a\u95f2\u7a7a\u95f4\u3002<\/p>\n","protected":false},"author":370,"featured_media":78644,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-204085","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/370"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=204085"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204085\/revisions"}],"predecessor-version":[{"id":204089,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204085\/revisions\/204089"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/78644"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=204085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=204085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=204085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}