{"id":177343,"date":"2020-04-26T11:47:25","date_gmt":"2020-04-26T03:47:25","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=177343"},"modified":"2020-04-20T09:39:40","modified_gmt":"2020-04-20T01:39:40","slug":"linux-lvm-new","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-lvm-new.html","title":{"rendered":"Linux\u4e0b\u521b\u5efalvm\u865a\u62df\u78c1\u76d8\u9635\u5217+\u811a\u672c\u5316\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u903b\u8f91\u5377\u7ba1\u7406\u5668\uff08\u82f1\u8bed\uff1aLogical Volume Manager\uff0c\u7f29\u5199\u4e3aLVM\uff09\uff0c\u53c8\u8bd1\u4e3a\u903b\u8f91\u5377\u5b97\u7ba1\u7406\u5668\u3001\u903b\u8f91\u6247\u533a\u7ba1\u7406\u5668\u3001\u903b\u8f91\u78c1\u76d8\u7ba1\u7406\u5668\uff0c\u662fLinux\u6838\u5fc3\u6240\u63d0\u4f9b\u7684\u903b\u8f91\u5377\u7ba1\u7406\uff08Logical volume management\uff09\u529f\u80fd\u3002\u5b83\u5728\u786c\u76d8\u7684\u786c\u76d8\u5206\u533a\u4e4b\u4e0a\uff0c\u53c8\u521b\u5efa\u4e00\u4e2a\u903b\u8f91\u5c42\uff0c\u4ee5\u65b9\u4fbf\u7cfb\u7edf\u7ba1\u7406\u786c\u76d8\u5206\u5272\u7cfb\u7edf\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u6700\u5148\u7531IBM\u5f00\u53d1\uff0c\u5728AIX\u7cfb\u7edf\u4e0a\u5b9e\u73b0\uff0cOS\/2 \u64cd\u4f5c\u7cfb\u7edf\u4e0e HP-UX\u4e5f\u652f\u6301\u8fd9\u4e2a\u529f\u80fd\u3002\u57281998\u5e74\uff0cHeinz Mauelshagen \u6839\u636e\u5728 HP-UX \u4e0a\u7684\u903b\u8f91\u5377\u7ba1\u7406\u5668\uff0c\u5199\u4f5c\u51fa\u7b2c\u4e00\u4e2a Linux \u7248\u672c\u7684\u903b\u8f91\u5377\u7ba1\u7406\u5668\u3002<\/p>\n

LVM\u57fa\u672c\u672f\u8bed<\/strong><\/div>\n

PV\uff1a\u7269\u7406\u5377\uff0cPV\u5904\u4e8eLVM\u7cfb\u7edf\u6700\u4f4e\u5c42\uff0c\u5b83\u53ef\u4ee5\u662f\u6574\u4e2a\u786c\u76d8\uff0c\u6216\u8005\u4e0e\u78c1\u76d8\u5206\u533a\u5177\u6709\u76f8\u540c\u529f\u80fd\u7684\u8bbe\u5907\uff08\u5982RAID\uff09\uff0c\u4f46\u548c\u57fa\u672c\u7684\u7269\u7406\u5b58\u50a8\u4ecb\u8d28\u76f8\u6bd4\u8f83\uff0c\u591a\u4e86\u4e0eLVM\u76f8\u5173\u7ba1\u7406\u53c2\u6570
\nVG\uff1a\u5377\u7ec4\uff0c\u521b\u5efa\u5728PV\u4e4b\u4e0a\uff0c\u7531\u4e00\u4e2a\u6216\u591a\u4e2aPV\u7ec4\u6210\uff0c\u53ef\u4ee5\u5728VG\u4e0a\u521b\u5efa\u4e00\u4e2a\u6216\u591a\u4e2a\u201cLVM\u5206\u533a\u201d\uff08\u903b\u8f91\u5377\uff09\uff0c\u529f\u80fd\u7c7b\u4f3c\u975eLVM\u7cfb\u7edf\u7684\u7269\u7406\u786c\u76d8
\nLV\uff1a\u903b\u8f91\u5377\uff0c\u4eceVG\u4e2d\u5206\u5272\u51fa\u7684\u4e00\u5757\u7a7a\u95f4\uff0c\u521b\u5efa\u4e4b\u540e\u5176\u5927\u5c0f\u53ef\u4ee5\u4f38\u7f29\uff0c\u5728LV\u4e0a\u53ef\u4ee5\u521b\u5efa\u6587\u4ef6\u7cfb\u7edf\uff08\u5982\/var,\/home\uff09
\nPE\uff1a\u7269\u7406\u533a\u57df\uff0c\u6bcf\u4e00\u4e2aPV\u88ab\u5212\u5206\u4e3a\u57fa\u672c\u5355\u5143\uff08\u4e5f\u88ab\u79f0\u4e3aPE\uff09\uff0c\u5177\u6709\u552f\u4e00\u7f16\u53f7\u7684PE\u662f\u53ef\u4ee5\u88abLVM\u5bfb\u5740\u7684\u6700\u5c0f\u5b58\u50a8\u5355\u5143\uff0c\u9ed8\u8ba4\u4e3a4MB
\n\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7LVM\u7075\u6d3b\u4fbf\u6377\u7684\u7ba1\u7406\u7cfb\u7edf\u4e2d\u7684\u78c1\u76d8\uff0c\u5e76\u4e14\u6839\u636e\u9700\u6c42\u5feb\u901f\u3001\u65e0\u611f\u5f97\u6269\u5bb9\u76ee\u6807\u78c1\u76d8\uff0c\u5e76\u4e14\u51e0\u4e4e\u4e0d\u4f1a\u5f71\u54cd\u6027\u80fd\u3002<\/p>\n

\u8fc7\u7a0b<\/strong><\/div>\n

\u521b\u5efalvm\u5206\u533a\u7684\u65b9\u6cd5\u5176\u5b9e\u975e\u5e38\u7684\u7b80\u5355\uff0c\u4e3b\u8981\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n

\u521b\u5efa\u78c1\u76d8\u5206\u533apart<\/strong><\/span><\/div>\n

\u76ee\u524d\u505aLVM\u5206\u533a\u6bd4\u8f83\u63a8\u8350\u7684\u5de5\u5177\u8fd8\u662ffdisk\uff0c\u4e0d\u662f\u8bf4parted\u4e0d\u80fd\u505a\uff0c\u800c\u662ffdisk\u53ef\u80fd\u66f4\u52a0\u65b9\u4fbf\u4e00\u70b9\u3002\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n

\r\n# fdisk \/dev\/nvme0n1\r\nCommand (m for help): n ## \u65b0\u5efa\r\nCommand action\r\n   e   extended\r\n   p   primary partition (1-4)\r\np ## \u4e3b\u5206\u533a\r\n\r\nPartition number (1-4): 1 ## \u5206\u533a\u53f7\r\nFirst cylinder (2048-543352123, default 2048):  ## \u56de\u8f66\u7528\u9ed8\u8ba4\u76841\r\nLast cylinder, +cylinders or +size{K,M,G} (2048-543352123, default 543352123): ## \u56de\u8f66\u9ed8\u8ba4\u5927\u5c0f\u5927\u5c0f\r\n\r\nCommand (m for help): t ## \u6539\u53d8toggle\u7c7b\u578b\r\nSelected partition 1\r\nHex code (type L to list codes): 8e ## LVM \u7684\u5206\u533a\u4ee3\u78018e\r\nChanged system type of partition 1 to 8e (Linux LVM)\r\n<\/pre>\n
\u521b\u5efa\u7269\u7406\u5377PV<\/strong><\/span><\/div>\n

\u5728\u5206\u533a\u5b8c\u6210\u4e4b\u540e\u9700\u8981\u505a\u7684\u5c31\u662f\u521b\u5efa\u7269\u7406\u5377\uff0c\u76f4\u63a5\u5c06\u521a\u624d\u521b\u5efa\u7684\u5206\u533a\u8fdb\u884c<\/p>\n

\r\npvcreate\uff1a\r\n\r\n# pvcreate \/dev\/nvme0n1p1\r\n<\/pre>\n
\u521b\u5efa\u865a\u62df\u5377VG<\/strong><\/span><\/div>\n

\u5728\u521b\u5efa\u73a9\u7269\u7406\u5377\u4e4b\u540e\uff0c\u9700\u8981\u5bf9\u8be5\u78c1\u76d8\u8fdb\u884c\u865a\u62df\u5377\u7684\u521b\u5efa\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\u4e00\u4e2a\u865a\u62df\u5377\u53ef\u4ee5\u7531\u591a\u4e2a\u7269\u7406\u5377\u6784\u6210\u3002\u4f8b\u5982\uff1a<\/p>\n

\r\n# vgcreate nvme \/dev\/nvme0n1p1 \/dev\/nvme1n1p1 \/dev\/nvme2n1p1\r\n<\/pre>\n

\u8be5\u547d\u4ee4\u7684\u610f\u4e49\u5c31\u5728\u4e8e\u521b\u5efa\u4e00\u4e2a\u53eb\u505anvme\u7684\u865a\u62df\u5377\uff0c\u7531\/dev\/nvme0n1p1\u3001 \/dev\/nvme1n1p1\u3001 \/dev\/nvme2n1p1\u4e09\u4e2a\u505a\u4e86pv\u7684\u5206\u533a\u6784\u6210<\/p>\n

\u521b\u5efa\u903b\u8f91\u5377LG<\/strong><\/span><\/div>\n

\u5230\u4e86\u8fd9\u4e00\u6b65\uff0c\u57fa\u672c\u4e0aLVM\u7684\u521b\u5efa\u5df2\u7ecf\u5230\u4e86\u5c3e\u58f0\u4e86\uff0c\u6700\u540e\u4e00\u6b65\u5c31\u662f\u4ece\u865a\u62df\u5377\u4e2d\u521b\u5efa\u4e00\u4e2a\u903b\u8f91\u5377\u3002\u5982\u4e0b\uff1a<\/p>\n

\r\n# lvcreate -L 2.91T -n data nvme\r\n<\/pre>\n

\u8fd9\u6761\u547d\u4ee4\u7684\u610f\u601d\u4e3a\u4ece\u865a\u62df\u5377nvme\u4e2d\u521b\u5efa\u4e00\u4e2a2.91T\u7684\u903b\u8f91\u5377\u4f5c\u4e3alvm\u5206\u533a\u5e76\u547d\u540d\u4e3adata\uff0c\u5982\u679c\u60f3\u4e00\u6b21\u6027\u5168\u90e8\u7528\u5b8c\u6240\u6709\u7684\u5bb9\u91cf\uff0c\u4e5f\u53ef\u4ee5\u8fd9\u6837\uff1a<\/p>\n

\r\n# lvcreate -l -n data nvme\r\n<\/pre>\n

\u6b64\u65f6\u5728linux\u7684\/dev\/\u6587\u4ef6\u5939\u4e0b\u9762\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u6709\/nvme\/data\u7684\u6587\u4ef6\u7ed3\u6784\u3002<\/p>\n

\u6302\u8f7d\u5e76\u66f4\u65b0\u6587\u4ef6<\/strong><\/span><\/div>\n

\u5728\u521b\u5efa\u5b8clvm\u5206\u533a\u540e\uff0c\u6211\u4eec\u9700\u8981\u5c06\u5206\u533a\u6302\u5728\u5230\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u4e2d\u3002\u5047\u8bbe\u9700\u8981\u6302\u8f7d\u7684\u8def\u5f84\u662f\/data\u3002<\/p>\n

\r\n# mkdir \/data ##\u521b\u5efa\u8be5\u8def\u5f84\r\n# mount \/dev\/mapper\/nvme-data \/data \r\n<\/pre>\n

#\u9700\u8981\u6ce8\u610f\u7684\u65f6\u5019\u8fd9\u91cc\u63a8\u8350\u4f7f\u7528\/dev\/mapper\/nvme-data\u4f5c\u4e3a\u6302\u8f7d\u7684\u8bbe\u5907\u8def\u5f84\uff0c\u800c\u4e0d\u662f\/dev\/nvme\/data\uff1b\u4e4b\u540e\u901a\u8fc7blkid\u547d\u4ee4\u83b7\u53d6\u8fd9\u4e2a\u65b0\u7684lvm\u5206\u533a\u7684UUID\uff0c\u7136\u540e\u66f4\u65b0\u5230\/etc\/fstab\u4e2d\u5c31\u53ef\u4ee5\u4e86<\/p>\n

\u811a\u672c\u5316<\/strong><\/div>\n

\u4e0a\u8ff0\u7684LVM\u5b9e\u73b0\u8fc7\u7a0b\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7shell\u811a\u672c\u8fdb\u884c\u5b9e\u73b0\uff1a<\/p>\n

\r\n#!\/bin\/bash\r\n\r\n##\u672c\u6848\u4f8b\u4e2d\u4ee5\u670d\u52a1\u5668\u7684\/dev\/nvme0n1\u8fd9\u5757nvme\u78c1\u76d8\u4e3a\u4f8b\u8fdb\u884c\u64cd\u4f5c\r\nOPTS=\"noatime,nobarrier,errors=remount-ro,nofail\"   ##\u90e8\u5206\u5199\u5165\/etc\/fstab\u7684\u56fa\u5b9a\u53d8\u91cf\r\numount \/data\/ && parted \/dev\/nvme0n1 rm 1   ## \u9996\u5148\u786e\u4fdd\u76ee\u6807\u78c1\u76d8\u6ca1\u6709\u6b8b\u7559\u7684\u5206\u533a\u4fe1\u606f\u3002\r\necho \"n\r\np\r\n1\r\n\r\nt\r\n8e\r\nw\r\n\" | fdisk \/dev\/nvme0n1  ##\u901a\u8fc7fdisk\u5de5\u5177\u521b\u5efa\u4e00\u4e2a\u5206\u533a\r\necho \"y\r\n\" | pvcreate \/dev\/nvme0n1p1     ##\u521b\u5efa\u4e00\u4e2a\u7269\u7406\u5377\r\necho \"y\r\ny\r\ny\r\n\" | vgcreate nvme \/dev\/nvme0n1      ##\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u5377\r\necho \"y\r\n\" | lvcreate -L 2.91T -n data nvme && mkfs.ext4 \/dev\/nvme\/data && mount \/dev\/mapper\/nvme-data \/data\/\r\n##\u521b\u5efa\u4e00\u4e2a\u903b\u8f91\u5377\u5e76\u8fdb\u884c\u683c\u5f0f\u5316\uff0c\u7136\u540e\u6302\u8f7d\u5230\u76ee\u6807\u8def\u5f84\r\nsed -i '$d' \/etc\/fstab      ##\u5c06UUID\u7b49\u76f8\u5173\u4fe1\u606f\u66f4\u65b0\u5230\/etc\/fstab\u4e2d\r\n#do\r\n    if [ $? -eq 0 ]; then\r\n        UUID=$(blkid \/dev\/mapper\/nvme-data | sed -e 's\/.*\\(UUID=.*\\) TYPE.*\/\\1\/')\r\n        echo -e \"${UUID}\\t\\t\/data\\t\\text4\\t\\t${OPTS}\\t\\t0 0\" >> \/etc\/fstab\r\n    fi\r\n    seq=$(($seq+1))\r\n#done\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u6700\u5148\u7531IBM\u5f00\u53d1\uff0c\u5728AIX\u7cfb\u7edf\u4e0a\u5b9e\u73b0\uff0cOS\/2 \u64cd\u4f5c\u7cfb\u7edf\u4e0e HP-UX\u4e5f\u652f\u6301\u8fd9\u4e2a\u529f\u80fd\u3002\u57281998\u5e74\uff0cHeinz […]<\/p>\n","protected":false},"author":668,"featured_media":153062,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-177343","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\/177343","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\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=177343"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/177343\/revisions"}],"predecessor-version":[{"id":177435,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/177343\/revisions\/177435"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/153062"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=177343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=177343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=177343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}