{"id":69092,"date":"2024-10-09T07:05:10","date_gmt":"2024-10-08T23:05:10","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=69092"},"modified":"2024-10-09T07:05:10","modified_gmt":"2024-10-08T23:05:10","slug":"linux-lvm","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-lvm.html","title":{"rendered":"Linux \u903b\u8f91\u5377\u7ba1\u7406LVM"},"content":{"rendered":"

\u903b\u8f91\u5377\u7ba1\u7406LVM\u662f\u4e00\u4e2a\u591a\u624d\u591a\u827a\u7684\u786c\u76d8\u7cfb\u7edf\u5de5\u5177\u3002\u65e0\u8bba\u5728Linux\u6216\u8005\u5176\u4ed6\u7c7b\u4f3c\u7684\u7cfb\u7edf\uff0c\u90fd\u662f\u975e\u5e38\u7684\u597d\u7528\u3002\u4f20\u7edf\u5206\u533a\u4f7f\u7528\u56fa\u5b9a\u5927\u5c0f\u5206\u533a\uff0c\u91cd\u65b0\u8c03\u6574\u5927\u5c0f\u5341\u5206\u9ebb\u70e6\u3002\u4f46\u662f\uff0cLVM\u53ef\u4ee5\u521b\u5efa\u548c\u7ba1\u7406\u201c\u903b\u8f91\u201d\u5377\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u4f7f\u7528\u7269\u7406\u786c\u76d8\u3002\u53ef\u4ee5\u8ba9\u7ba1\u7406\u5458\u5f39\u6027\u7684\u7ba1\u7406\u903b\u8f91\u5377\u7684\u6269\u5927\u7f29\u5c0f\uff0c\u64cd\u4f5c\u7b80\u5355\uff0c\u800c\u4e0d\u635f\u574f\u5df2\u5b58\u50a8\u7684\u6570\u636e\u3002\u53ef\u4ee5\u968f\u610f\u5c06\u65b0\u7684\u786c\u76d8\u6dfb\u52a0\u5230LVM\uff0c\u4ee5\u76f4\u63a5\u6269\u5c55\u5df2\u7ecf\u5b58\u5728\u7684\u903b\u8f91\u5377\u3002LVM\u5e76\u4e0d\u9700\u8981\u91cd\u542f\u5c31\u53ef\u4ee5\u8ba9\u5185\u6838\u77e5\u9053\u5206\u533a\u7684\u5b58\u5728\u3002
\nLVM\u4f7f\u7528\u5206\u5c42\u7ed3\u6784\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002
\n\"Linux
\n\u56fe\u4e2d\u9876\u90e8\uff0c\u9996\u5148\u662f\u5b9e\u9645\u7684\u7269\u7406\u78c1\u76d8\u53ca\u5176\u5212\u5206\u7684\u5206\u533a\u548c\u5176\u4e0a\u7684\u7269\u7406\u5377\uff08PV\uff09\u3002\u4e00\u4e2a\u6216\u591a\u4e2a\u7269\u7406\u5377\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u5377\u7ec4\uff08VG\uff09\u3002\u7136\u540e\u57fa\u4e8e\u5377\u7ec4\u53ef\u4ee5\u521b\u5efa\u903b\u8f91\u5377\uff08LV\uff09\u3002\u53ea\u8981\u5728\u5377\u7ec4\u4e2d\u6709\u53ef\u7528\u7a7a\u95f4\uff0c\u5c31\u53ef\u4ee5\u968f\u5fc3\u6240\u6b32\u7684\u521b\u5efa\u903b\u8f91\u5377\u3002\u6587\u4ef6\u7cfb\u7edf\u5c31\u662f\u5728\u903b\u8f91\u5377\u4e0a\u521b\u5efa\u7684\uff0c\u7136\u540e\u53ef\u4ee5\u5728\u64cd\u4f5c\u7cfb\u7edf\u6302\u8f7d\u548c\u8bbf\u95ee\u3002<\/p>\n

LVM\u6d4b\u8bd5\u8bf4\u660e<\/strong><\/div>\n

\u672c\u6587\u5c06\u4ecb\u7ecd\u600e\u4e48\u5728linux\u4e2d\u521b\u5efa\u548c\u7ba1\u7406LVM\u5377\u3002\u6211\u4eec\u5c06\u4f1a\u5206\u6210\u4e24\u4e2a\u90e8\u5206\u3002\u7b2c\u4e00\u4e2a\u90e8\u5206\uff0c\u6211\u4eec\u9996\u5148\u8981\u5728\u4e00\u4e2a\u786c\u76d8\u4e0a\u521b\u5efa\u591a\u4e2a\u903b\u8f91\u5377\uff0c\u7136\u540e\u5c06\u5b83\u4eec\u6302\u8f7d\u5728\/lvm-mount\u76ee\u5f55\u3002\u7136\u540e\u6211\u4eec\u5c06\u8981\u5bf9\u521b\u5efa\u597d\u7684\u5377\u8c03\u6574\u5927\u5c0f\u3002\u800c\u7b2c\u4e8c\u90e8\u5206\uff0c\u6211\u4eec\u5c06\u4f1a\u4ece\u53e6\u5916\u4e00\u5757\u786c\u76d8\u589e\u52a0\u989d\u5916\u7684\u5377\u5230LVM\u4e2d\u3002<\/p>\n

\u51c6\u5907\u78c1\u76d8\u5206\u533a<\/strong><\/div>\n

\u901a\u8fc7\u4f7f\u7528fdisk\uff0c\u521b\u5efa\u78c1\u76d8\u5206\u533a\u3002\u6211\u4eec\u9700\u8981\u521b\u5efa3\u4e2a1G\u5206\u533a\uff0c\u6ce8\u610f\uff0c\u5e76\u4e0d\u8981\u6c42\u5206\u533a\u7684\u5927\u5c0f\u4e00\u81f4\u3002\u540c\u6837\uff0c\u5206\u533a\u9700\u8981\u4f7f\u7528\u20188e\u2019\u7c7b\u578b\u6765\u4f7f\u4ed6\u4eec\u53ef\u7528\u4e8eLVM\u3002<\/p>\n

# fdisk \/dev\/sdb \r\n<\/pre>\n
Command (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 (1-1044, default 1):  ## \u56de\u8f66\u7528\u9ed8\u8ba4\u76841\r\nLast cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): +1G ## \u5927\u5c0f\r\n\r\nCommand (m for help): t ## \u6539\u53d8\u7c7b\u578b\r\nSelected partition 1\r\nHex code (type L to list codes): 8e ## LVM \u7684\u5206\u533a\u4ee3\u7801\r\nChanged system type of partition 1 to 8e (Linux LVM)\r\n<\/pre>\n

\u91cd\u590d\u4e0a\u9762\u7684\u64cd\u4f5c\u6765\u521b\u5efa\u5176\u4ed6\u4e24\u4e2a\u5206\u533a\u3002\u5206\u533a\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u5e94\u8be5\u6709\u7c7b\u4f3c\u5982\u4e0b\u7684\u8f93\u51fa\uff1a<\/p>\n

# fdisk -l \r\n<\/pre>\n
   Device Boot      Start         End      Blocks   Id  System\r\n\/dev\/sdb1               1         132     1060258+  8e  Linux LVM\r\n\/dev\/sdb2             133         264     1060290   8e  Linux LVM\r\n\/dev\/sdb3             265         396     1060290   8e  Linux LVM\r\n<\/pre>\n
\u51c6\u5907\u7269\u7406\u5377(PV)<\/strong><\/div>\n

\u521a\u521b\u5efa\u7684\u5206\u533a\u662f\u7528\u6765\u50a8\u5b58\u7269\u7406\u5377\u7684\u3002LVM\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u5927\u5c0f\u7684\u7269\u7406\u5377\u3002<\/p>\n

# pvcreate \/dev\/sdb1\r\n# pvcreate \/dev\/sdb2\r\n# pvcreate \/dev\/sdb3 \r\n<\/pre>\n

\u4f7f\u7528\u4e0b\u5217\u547d\u4ee4\u68c0\u67e5\u7269\u7406\u5377\u7684\u521b\u5efa\u60c5\u51b5\u3002\u4e0b\u9762\u622a\u53d6\u90e8\u5206\u8f93\u51fa\u3002\"\/dev\/sdb2\"\u662f\u4e00\u4e2a\u65b0\u7684\"1.01 GiB\"\u7269\u7406\u5377\u3002<\/p>\n

# pvdisplay \r\n<\/pre>\n
  --- NEW Physical volume ---\r\n  PV Name               \/dev\/sdb2\r\n  VG Name\r\n  PV Size               1.01 GiB\r\n  Allocatable           NO\r\n  PE Size               0\r\n  Total PE              0\r\n  Free PE               0\r\n  Allocated PE          0\r\n  PV UUID               jszvzz-ENA2-g5Pd-irhV-T9wi-ZfA3-0xo092\r\n<\/pre>\n

\u4f7f\u7528\u4e0b\u5217\u547d\u4ee4\u53ef\u4ee5\u5220\u9664\u7269\u7406\u5377\u3002<\/p>\n

# pvremove \/dev\/sdb1 \r\n<\/pre>\n
\u51c6\u5907\u5377\u7ec4(VG)<\/strong><\/div>\n

\u4e0b\u5217\u547d\u4ee4\u7528\u6765\u521b\u5efa\u540d\u4e3a'volume-group1'\u7684\u5377\u7ec4\uff0c\u4f7f\u7528\/dev\/sdb1, \/dev\/sdb2 \u548c \/dev\/sdb3\u521b\u5efa\u3002<\/p>\n

# vgcreate volume-group1 \/dev\/sdb1 \/dev\/sdb2 \/dev\/sdb3\r\n<\/pre>\n

\u4f7f\u7528\u4e0b\u5217\u547d\u4ee4\u53ef\u4ee5\u6765\u9a8c\u8bc1\u5377\u7ec4\u3002<\/p>\n

# vgdisplay \r\n<\/pre>\n
  --- Volume group ---\r\n  VG Name               volume-group1\r\n  System ID\r\n  Format                lvm2\r\n  Metadata Areas        3\r\n  Metadata Sequence No  1\r\n  VG Access             read\/write\r\n  VG Status             resizable\r\n  MAX LV                0\r\n  Cur LV                0\r\n  Open LV               0\r\n  Max PV                0\r\n  Cur PV                3\r\n  Act PV                3\r\n  VG Size               3.02 GiB\r\n  PE Size               4.00 MiB\r\n  Total PE              774\r\n  Alloc PE \/ Size       0 \/ 0\r\n  Free  PE \/ Size       774 \/ 3.02 GiB\r\n  VG UUID               bwd2pS-fkAz-lGVZ-qc7C-TaKv-fFUC-IzGNBK\r\n<\/pre>\n

\u4ece\u8f93\u51fa\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u89c1\u5377\u7ec4\u7684\u4f7f\u7528\u91cf\/\u603b\u91cf\u3002\u7269\u7406\u5377\u7ed9\u5377\u7ec4\u63d0\u4f9b\u7a7a\u95f4\u3002\u53ea\u8981\u5728\u8fd9\u4e2a\u5377\u7ec4\u4e2d\u8fd8\u6709\u53ef\u7528\u7a7a\u95f4\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u968f\u610f\u521b\u5efa\u903b\u8f91\u5377\u3002<\/p>\n

\u4f7f\u7528\u4e0b\u5217\u547d\u4ee4\u5220\u9664\u5377\u7ec4\u3002<\/p>\n

# vgremove volume-group1 \r\n<\/pre>\n
\u521b\u5efa\u903b\u8f91\u5377(LV)<\/strong><\/div>\n

\u4e0b\u5217\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a'1v1'\u3001\u5927\u5c0f\u4e3a100MB\u7684\u903b\u8f91\u5377\u3002\u6211\u4eec\u4f7f\u7528\u5c0f\u5206\u533a\u51cf\u5c11\u6267\u884c\u65f6\u95f4\u3002\u8fd9\u4e2a\u903b\u8f91\u5377\u4f7f\u7528\u4e4b\u524d\u521b\u5efa\u7684\u5377\u7ec4\u7684\u7a7a\u95f4\u3002<\/p>\n

# lvcreate -L 100M -n lv1 volume-group1 \r\n<\/pre>\n

\u903b\u8f91\u5377\u53ef\u4f7f\u7528lvdisplay\u547d\u4ee4\u67e5\u770b\u3002<\/p>\n

# lvdisplay \r\n<\/pre>\n
\n
  --- Logical volume ---\r\n  LV Name                \/dev\/volume-group1\/lv1\r\n  VG Name                volume-group1\r\n  LV UUID                YNQ1aa-QVt1-hEj6-ArJX-I1Q4-y1h1-OFEtlW\r\n  LV Write Access        read\/write\r\n  LV Status              available\r\n  # open                 0\r\n  LV Size                100.00 MiB\r\n  Current LE             25\r\n  Segments               1\r\n  Allocation             inherit\r\n  Read ahead sectors     auto\r\n  - currently set to     256\r\n  Block device           253:2\r\n<\/pre>\n

\u73b0\u5728\u903b\u8f91\u5377\u5df2\u7ecf\u51c6\u5907\u597d\u4e86\uff0c\u6211\u4eec\u53ef\u4ee5\u683c\u5f0f\u5316\u548c\u6302\u8f7d\u903b\u8f91\u5377\uff0c\u5c31\u50cf\u5176\u5b83ext2\/3\/4\u5206\u533a\u4e00\u6837\uff01<\/p>\n

# mkfs.ext4 \/dev\/volume-group1\/lv1\r\n# mkdir \/lvm-mount\r\n# mount \/dev\/volume-group1\/lv1 \/lvm-mount\/ \r\n<\/pre>\n

\u4e00\u65e6\u903b\u8f91\u5377\u6302\u8f7d\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5230\u6302\u8f7d\u70b9 \/lvm-mount\/ \u4e0a\u8bfb\u5199\u4e86\u3002\u8981\u521b\u5efa\u548c\u6302\u8f7d\u5176\u5b83\u7684\u903b\u8f91\u5377\uff0c\u6211\u4eec\u91cd\u590d\u8fd9\u4e2a\u8fc7\u7a0b\u3002<\/p>\n

\u6700\u540e\uff0c\u4f7f\u7528lvremove\u6211\u4eec\u53ef\u4ee5\u5220\u9664\u903b\u8f91\u5377\u3002<\/p>\n

# umount \/lvm-mount\/\r\n# lvremove \/dev\/volume-group1\/lv1 \r\n<\/pre>\n
\u6269\u5c55\u4e00\u4e2aLVM\u5377<\/strong><\/div>\n

\u8c03\u6574\u903b\u8f91\u5377\u5927\u5c0f\u7684\u529f\u80fd\u662fLVM\u6700\u6709\u7528\u7684\u529f\u80fd\u3002\u8fd9\u4e2a\u90e8\u5206\u4f1a\u8ba8\u8bba\u6211\u4eec\u600e\u4e48\u6837\u6269\u5c55\u4e00\u4e2a\u5b58\u5728\u7684\u903b\u8f91\u5377\u3002\u4e0b\u9762\uff0c\u6211\u4eec\u5c06\u4f1a\u6269\u5c55\u5148\u524d\u521b\u5efa\u7684\u903b\u8f91\u5377\u2018lv1\u2019\u6269\u5927\u5230200MB\u3002<\/p>\n

\u6ce8\u610f\uff0c\u8c03\u6574\u903b\u8f91\u5377\u5927\u5c0f\u4e4b\u540e\uff0c\u4e5f\u9700\u8981\u5bf9\u6587\u4ef6\u7cfb\u7edf\u8c03\u6574\u5927\u5c0f\u8fdb\u884c\u5339\u914d\u3002\u8fd9\u4e2a\u989d\u5916\u7684\u6b65\u9aa4\u5404\u4e0d\u76f8\u540c\uff0c\u53d6\u51b3\u4e8e\u521b\u5efa\u6587\u4ef6\u7cfb\u7edf\u7684\u7c7b\u578b\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528'lv1'\u521b\u5efa\u4e86ext4\u7c7b\u578b\u7684\u6587\u4ef6\u7cfb\u7edf\uff0c\u6240\u4ee5\u8fd9\u91cc\u7684\u64cd\u4f5c\u662f\u9488\u5bf9ext4\u6587\u4ef6\u7cfb\u7edf\u7684\u3002\uff08ext2\/3\u6587\u4ef6\u7cfb\u7edf\u4e5f\u7c7b\u540c\uff09\u3002\u547d\u4ee4\u7684\u6267\u884c\u987a\u5e8f\u662f\u5f88\u91cd\u8981\u7684\u3002<\/p>\n

\u9996\u5148\uff0c\u6211\u4eec\u5378\u8f7d\u6389lv1\u5377<\/p>\n

# umount \/lvm-mount\/ \r\n<\/pre>\n

\u7136\u540e\uff0c\u8bbe\u7f6e\u5377\u7684\u5927\u5c0f\u4e3a200M<\/p>\n

# lvresize -L 200M \/dev\/volume-group1\/lv1 \r\n<\/pre>\n

\u63a5\u4e0b\u6765\uff0c\u68c0\u67e5\u78c1\u76d8\u9519\u8bef<\/p>\n

# e2fsck -f \/dev\/volume-group1\/lv1 \r\n<\/pre>\n

\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6269\u5c55\u6587\u4ef6\u7cfb\u7edf\u4ee5\u540e\uff0cext4\u4fe1\u606f\u5c31\u66f4\u65b0\u4e86\u3002<\/p>\n

# resize2fs \/dev\/volume-group1\/lv1 \r\n<\/pre>\n

\u73b0\u5728\uff0c\u8fd9\u4e2a\u903b\u8f91\u5377\u5e94\u8be5\u5df2\u7ecf\u6269\u5c55\u5230200MB\u4e86\u3002\u6211\u4eec\u68c0\u67e5LV\u7684\u72b6\u6001\u6765\u9a8c\u8bc1\u3002<\/p>\n

# lvdisplay \r\n<\/pre>\n
\n
  --- Logical volume ---\r\n  LV Name                \/dev\/volume-group1\/lv1\r\n  VG Name                volume-group1\r\n  LV UUID                9RtmMY-0RIZ-Dq40-ySjU-vmrj-f1es-7rXBwa\r\n  LV Write Access        read\/write\r\n  LV Status              available\r\n  # open                 0\r\n  LV Size                200.00 MiB\r\n  Current LE             50\r\n  Segments               1\r\n  Allocation             inherit\r\n  Read ahead sectors     auto\r\n  - currently set to     256\r\n  Block device           253:2\r\n<\/pre>\n

\u73b0\u5728\uff0c\u8fd9\u4e2a\u903b\u8f91\u5377\u53ef\u4ee5\u518d\u6b21\u6302\u8f7d\uff0c\u540c\u6837\u8fd9\u4e2a\u65b9\u6cd5\u4e5f\u53ef\u7528\u4e8e\u5176\u4ed6\u5206\u533a\u3002<\/p>\n

\u7f29\u51cf\u4e00\u4e2aLVM\u5377<\/strong><\/div>\n

\u8fd9\u7ae0\u8282\u4ecb\u7ecd\u7f29\u51cfLVM\u5377\u5927\u5c0f\u7684\u65b9\u6cd5\u3002\u547d\u4ee4\u7684\u987a\u5e8f\u540c\u6837\u91cd\u8981\u3002\u5e76\u4e14\uff0c\u4e0b\u5217\u547d\u4ee4\u5bf9ext2\/3\/4\u6587\u4ef6\u7cfb\u7edf\u540c\u6837\u6709\u6548\u3002<\/p>\n

\u6ce8\u610f\u51cf\u5c11\u903b\u8f91\u5377\u7684\u5927\u5c0f\u503c\u82e5\u5c0f\u4e8e\u50a8\u5b58\u7684\u6570\u636e\u5927\u5c0f\uff0c\u5b58\u50a8\u5728\u540e\u9762\u7684\u6570\u636e\u4f1a\u4e22\u5931\u3002<\/p>\n

\u9996\u5148\uff0c\u5378\u8f7d\u6389\u5377\u3002<\/p>\n

# umount \/dev\/volume-group1\/lv1\r\n\u7136\u540e\uff0c\u68c0\u6d4b\u78c1\u76d8\u9519\u8bef\u3002<\/pre>\n
# e2fsck -f \/dev\/volume-group1\/lv1 \r\n<\/pre>\n

\u63a5\u4e0b\u6765\u7f29\u5c0f\u6587\u4ef6\u7cfb\u7edf\uff0c\u66f4\u65b0ext4\u4fe1\u606f\u3002<\/p>\n

# resize2fs \/dev\/volume-group1\/lv1 100M \r\n<\/pre>\n

\u5b8c\u6210\u4ee5\u540e\uff0c\u51cf\u5c11\u903b\u8f91\u5377\u5927\u5c0f<\/p>\n

# lvresize -L 100M \/dev\/volume-group1\/lv1 \r\n<\/pre>\n

WARNING: Reducing active logical volume to 100.00 MiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce lv1? [y\/n]: y Reducing logical volume lv1 to 100.00 MiB Logical volume lv1 successfully resized<\/p><\/blockquote>\n

\u6700\u540e\uff0c\u9a8c\u8bc1\u8c03\u6574\u540e\u7684\u903b\u8f91\u5377\u5927\u5c0f\u3002<\/p>\n

# lvdisplay \r\n<\/pre>\n
--- Logical volume ---\r\n  LV Name                \/dev\/volume-group1\/lv1\r\n  VG Name                volume-group1\r\n  LV UUID                9RtmMY-0RIZ-Dq40-ySjU-vmrj-f1es-7rXBwa\r\n  LV Write Access        read\/write\r\n  LV Status              available\r\n  # open                 0\r\n  LV Size                100.00 MiB\r\n  Current LE             25\r\n  Segments               1\r\n  Allocation             inherit\r\n  Read ahead sectors     auto\r\n  - currently set to     256\r\n  Block device           253:2\r\n<\/pre>\n
\u6269\u5c55\u4e00\u4e2a\u5377\u7ec4<\/strong><\/div>\n

\u672c\u8282\u5c06\u8ba8\u8bba\u6269\u5c55\u5377\u7ec4\u7684\u65b9\u6cd5\uff0c\u5c06\u4e00\u4e2a\u7269\u7406\u5377\u6dfb\u52a0\u5230\u5377\u7ec4\u3002\u8ba9\u6211\u4eec\u5047\u8bbe\u6211\u4eec\u7684\u5377\u7ec4'volume-group1'\u5df2\u7ecf\u6ee1\u4e86\uff0c\u9700\u8981\u6269\u5927\u3002\u624b\u4e0a\u7684\u786c\u76d8\uff08sdb\uff09\u5df2\u7ecf\u6ca1\u6709\u5176\u4ed6\u7a7a\u95f2\u5206\u533a\uff0c\u6211\u4eec\u6dfb\u52a0\u4e86\u53e6\u5916\u4e00\u4e2a\u786c\u76d8\uff08sdc\uff09\u3002\u6211\u4eec\u5c06\u770b\u5230\u5982\u4f55\u628asdc\u7684\u5206\u533a\u6dfb\u52a0\u5230\u5377\u7ec4\u4ee5\u6269\u5c55\u3002<\/p>\n

\u68c0\u6d4b\u73b0\u5728\u5377\u7ec4\u72b6\u6001<\/p>\n

# vgdisplay volume-group1 \r\n<\/pre>\n
 --- Volume group ---\r\n  VG Name               volume-group1\r\n  System ID\r\n  Format                lvm2\r\n  Metadata Areas        3\r\n  Metadata Sequence No  8\r\n  VG Access             read\/write\r\n  VG Status             resizable\r\n  MAX LV                0\r\n  Cur LV                1\r\n  Open LV               0\r\n  Max PV                0\r\n  Cur PV                3\r\n  Act PV                3\r\n  VG Size               3.02 GiB\r\n  PE Size               4.00 MiB\r\n  Total PE              774\r\n  Alloc PE \/ Size       25 \/ 100.00 MiB\r\n  Free  PE \/ Size       749 \/ 2.93 GiB\r\n  VG UUID               bwd2pS-fkAz-lGVZ-qc7C-TaKv-fFUC-IzGNBK\r\n<\/pre>\n

\u9996\u5148\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a2GB\u5206\u533asdc1\uff0c\u7c7b\u578b\u4e3aLVM\uff088e\uff09\uff0c\u5982\u6559\u7a0b\u524d\u6240\u8ff0\u3002<\/p>\n

# fdisk \/dev\/sdc \r\n<\/pre>\n
Command (m for help): n\r\nCommand action\r\n   e   extended\r\n   p   primary partition (1-4)\r\np\r\nPartition number (1-4): 1\r\nFirst cylinder (1-1044, default 1):\r\nUsing default value 1\r\nLast cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): +2G\r\n\r\nCommand (m for help): t\r\nSelected partition 1\r\nHex code (type L to list codes): 8e\r\nChanged system type of partition 1 to 8e (Linux LVM)\r\n\r\nCommand (m for help): w\r\nThe partition table has been altered!\r\n<\/pre>\n

\u7136\u540e\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u7269\u7406\u5377 \/dev\/sdc1<\/p>\n

# pvcreate \/dev\/sdc1 \r\n<\/pre>\n

\u73b0\u5728\uff0c\u7269\u7406\u5377\u5df2\u7ecf\u51c6\u5907\u597d\u4e86\uff0c\u6211\u4eec\u53ef\u4ee5\u7b80\u5355\u5730\u5c06\u5b83\u589e\u52a0\u5230\u5df2\u5b58\u5728\u7684\u5377\u7ec4'volume-group1'\u4e0a\u3002<\/p>\n

# vgextend volume-group1 \/dev\/sdc1 \r\n<\/pre>\n

\u4f7f\u7528vgdisplay\u6765\u9a8c\u8bc1\uff08\u53ef\u4ee5\u770b\u5230\u5377\u7ec4\u5927\u5c0f\u5df2\u7ecf\u589e\u5927\uff09\u3002<\/p>\n

# vgdisplay \r\n<\/pre>\n
  --- Volume group ---\r\n  VG Name               volume-group1\r\n  System ID\r\n  Format                lvm2\r\n  Metadata Areas        4\r\n  Metadata Sequence No  9\r\n  VG Access             read\/write\r\n  VG Status             resizable\r\n  MAX LV                0\r\n  Cur LV                1\r\n  Open LV               0\r\n  Max PV                0\r\n  Cur PV                4\r\n  Act PV                4\r\n  VG Size               5.03 GiB\r\n  PE Size               4.00 MiB\r\n  Total PE              1287\r\n  Alloc PE \/ Size       25 \/ 100.00 MiB\r\n  Free  PE \/ Size       1262 \/ 4.93 GiB\r\n  VG UUID               bwd2pS-fkAz-lGVZ-qc7C-TaKv-fFUC-IzGNBK\r\n<\/pre>\n

\u6ce8\u610f\uff0c\u5c3d\u7ba1\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u5355\u72ec\u7684\u78c1\u76d8\u505a\u793a\u8303\uff0c\u5176\u5b9e\u53ea\u8981\u662f\u20188e\u2019\u7c7b\u578b\u7684\u78c1\u76d8\u5206\u533a\u90fd\u53ef\u4ee5\u7528\u6765\u6269\u5c55\u5377\u7ec4\u3002<\/p>\n

\u603b\u7ed3\u4e00\u4e0b\uff0cLVM\u662f\u4e00\u4e2a\u975e\u5e38\u7ed9\u529b\u7684\u5de5\u5177\uff0c\u7528\u6765\u521b\u5efa\u548c\u7ba1\u7406\u53ef\u53d8\u5927\u5c0f\u7684\u5206\u533a\u3002\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u4ecb\u7ecd\u4e86\u52a8\u6001\u5206\u533a\u5982\u4f55\u5728LVM\u4e2d\u521b\u5efa\u548c\u4f7f\u7528\u3002\u6211\u4eec\u4e5f\u4ecb\u7ecd\u4e86\u6269\u5c55\/\u7f29\u5c0f\u903b\u8f91\u5377\u548c\u5377\u7ec4\u7684\u65b9\u6cd5\uff0c\u548c\u5982\u4f55\u589e\u52a0\u4e00\u4e2a\u65b0\u7684\u78c1\u76d8\u5230LVM\u3002<\/p>\n

\u5e0c\u671b\u5bf9\u4f60\u6709\u5e2e\u52a9\u3002<\/p>\n


\n

via: http:\/\/xmodulo.com\/2014\/05\/use-lvm-linux.html<\/a><\/p>\n

\u8bd1\u8005\uff1aVic___<\/a> \u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531 LCTT<\/a> \u539f\u521b\u7ffb\u8bd1\uff0cLinux\u4e2d\u56fd<\/a> \u8363\u8a89\u63a8\u51fa<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-3218-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttps:\/\/lrxjmw.cn\/linux-lvm.html<\/a>\u7f16\u8f91\u5458\uff1a\u90ed\u5efa\u9e4f\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u903b\u8f91\u5377\u7ba1\u7406LVM\u662f\u4e00\u4e2a\u591a\u624d\u591a\u827a\u7684\u786c\u76d8\u7cfb\u7edf\u5de5\u5177\u3002\u65e0\u8bba\u5728Linux\u6216\u8005\u5176\u4ed6\u7c7b\u4f3c\u7684\u7cfb\u7edf\uff0c\u90fd\u662f\u975e\u5e38\u7684\u597d\u7528\u3002\u4f20\u7edf\u5206\u533a\u4f7f\u7528\u56fa\u5b9a\u5927\u5c0f\u5206\u533a\uff0c\u91cd\u65b0\u8c03\u6574\u5927\u5c0f\u5341\u5206\u9ebb\u70e6\u3002\u4f46\u662f\uff0cLVM\u53ef\u4ee5\u521b\u5efa\u548c\u7ba1\u7406“\u903b\u8f91”\u5377\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u4f7f\u7528\u7269\u7406\u786c\u76d8\u3002\u53ef\u4ee5\u8ba9\u7ba1\u7406\u5458\u5f39\u6027\u7684\u7ba1\u7406\u903b\u8f91\u5377\u7684\u6269\u5927\u7f29\u5c0f\uff0c\u64cd\u4f5c\u7b80\u5355\uff0c\u800c\u4e0d\u635f\u574f\u5df2\u5b58\u50a8\u7684\u6570\u636e\u3002\u53ef\u4ee5\u968f\u610f\u5c06\u65b0\u7684\u786c\u76d8\u6dfb\u52a0\u5230LVM\uff0c\u4ee5\u76f4\u63a5\u6269\u5c55\u5df2\u7ecf\u5b58\u5728\u7684\u903b\u8f91\u5377\u3002LVM\u5e76\u4e0d\u9700\u8981\u91cd\u542f\u5c31\u53ef\u4ee5\u8ba9\u5185\u6838\u77e5\u9053\u5206\u533a\u7684\u5b58\u5728\u3002<\/p>\n","protected":false},"author":323,"featured_media":6264,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-69092","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\/69092","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\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=69092"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/69092\/revisions"}],"predecessor-version":[{"id":106553,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/69092\/revisions\/106553"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/6264"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=69092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=69092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=69092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}