{"id":89,"date":"2021-04-13T22:39:15","date_gmt":"2021-04-13T14:39:15","guid":{"rendered":"https:\/\/www.soholab.tw\/?p=89"},"modified":"2021-04-13T22:39:15","modified_gmt":"2021-04-13T14:39:15","slug":"ubuntu%e8%aa%bf%e6%95%b4lvm%e7%a9%ba%e9%96%93","status":"publish","type":"post","link":"https:\/\/soholab.tw\/?p=89","title":{"rendered":"ubuntu\u8abf\u6574LVM\u7a7a\u9593"},"content":{"rendered":"\n<p>\u539f\u6587\uff1a\u5c0f\u4fe1\u8c6c\u7684\u539f\u59cb\u90e8\u843d https:\/\/godleon.github.io\/blog\/Linux\/Linux-extend-lvm-from-unused-space\/<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"Preface\">Preface<\/h1>\n\n\n\n<p>\u56e0\u70ba\u525b\u525b\u767c\u73fe\u76e3\u63a7\u4e3b\u6a5f\u7a7a\u9593\u4e0d\u5920\u4e86\uff0c\u8a18\u5f97\u4e4b\u524d\u662f\u4ee5 LVM \u7684\u898f\u5283\u5132\u5b58\u7a7a\u9593\u7684\uff0c\u56e0\u6b64\u9032\u884c\u4e86\u64f4\u5145\u7a7a\u9593\u7684\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u5be6\u969b\u60c5\u5883\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u73fe\u6709\u7684\u786c\u789f\u9084\u6709\u672a\u5206\u5272\u7684\u7a7a\u9593<\/li><li>\u4ee5 LVM \u7684\u65b9\u5f0f\u898f\u5283\u5132\u5b58\u7a7a\u9593\uff0c\u76ee\u524d LV \u7a7a\u9593\u5df2\u7d93\u5feb\u8981\u8017\u76e1<\/li><\/ul>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"Scenario\">Scenario<\/h1>\n\n\n\n<ul class=\"wp-block-list\"><li>host \u4e0a\u53ea\u6709\u4e00\u500b 200GB disk\uff0c\u4f46<strong>\u7576\u521d\u5206\u5272\u6642\u53ea\u4f7f\u7528\u4e86\u7d04 60GB \u7684\u7a7a\u9593\uff0c\u9084\u6709 140GB \u5de6\u53f3\u672a\u5206\u5272\u7a7a\u9593<\/strong><\/li><li>PV \u5df2\u7d93\u6c92\u6709\u7a7a\u9593\u53ef\u7528<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<\/td><td>$ pvdisplay<br>&#8212; Physical volume &#8212;<br>PV Name \/dev\/sda3<br>VG Name ubuntu-vg<br>PV Size &lt;63.00 GiB \/ not usable 0<br>Allocatable yes<br>PE Size 4.00 MiB<br>Total PE 16127<br>Free PE 3327<br>Allocated PE 12800<br>PV UUID cs39RZ-Dfac-qED7-KHNz-Liht-QMtu-FvhS04<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>VG \u53ef\u5206\u914d\u7684\u7a7a\u9593\u4e5f\u6c92\u5f88\u591a\u4e86<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>21<\/td><td>$ vgdisplay<br>&#8212; Volume group &#8212;<br>VG Name ubuntu-vg<br>System ID<br>Format lvm2<br>Metadata Areas 1<br>Metadata Sequence No 2<br>VG Access read\/write<br>VG Status resizable<br>MAX LV 0<br>Cur LV 1<br>Open LV 1<br>Max PV 0<br>Cur PV 1<br>Act PV 1<br>VG Size &lt;63.00 GiB<br>PE Size 4.00 MiB<br>Total PE 16127<br>Alloc PE \/ Size 12800 \/ 50.00 GiB<br>Free PE \/ Size 3327 \/ &lt;13.00 GiB<br>VG UUID LRE3Y3-QvmP-mCI0-D0PT-Hk9w-3tqb-129LhN<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>LV \u7576\u521d\u53ea\u6709\u5206\u914d\u4e86 50 GB \u7a7a\u9593<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>13<br>14<br>15<br>16<br>17<\/td><td>$ lvdisplay<br>&#8212; Logical volume &#8212;<br>LV Path \/dev\/ubuntu-vg\/ubuntu-lv<br>LV Name ubuntu-lv<br>VG Name ubuntu-vg<br>LV UUID xWDQsf-VimA-iX00-Kx6G-NzmJ-yaol-XVZr3L<br>LV Write Access read\/write<br>LV Creation host, time ubuntu-server, 2019-08-05 10:16:13 +0800<br>LV Status available<br># open 1<br>LV Size 50.00 GiB<br>Current LE 12800<br>Segments 1<br>Allocation inherit<br>Read ahead sectors auto<br>&#8211; currently set to 256<br>Block device 253:0<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"Operations\">Operations<\/h1>\n\n\n\n<p>\u76ee\u6a19\u662f\u5c07\u6240\u6709\u672a\u5206\u5272\u7684\u7a7a\u9593\u52a0\u5165\u5230 PV\uff0c\u8b93 VG \u53ef\u4ee5\u6709\u66f4\u591a\u7684\u7a7a\u9593\u53ef\u4ee5\u5206\u914d\u7d66 LV\uff0c\u4ee5\u4e0b\u662f\u64cd\u4f5c\u6b65\u9a5f\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u64f4\u5145\u539f\u6709-partition\uff0c\u4f7f\u7528\u5269\u9918\u7a7a\u9593\">\u64f4\u5145\u539f\u6709 partition\uff0c\u4f7f\u7528\u5269\u9918\u7a7a\u9593<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>21<br>22<br>23<br>24<br>25<br>26<br>27<br>28<br>29<br>30<br>31<br>32<br>33<br>34<br>35<br>36<\/td><td># \u4f7f\u7528 parted \u5de5\u5177\u9032\u884c\u64f4\u5145<br>$ parted<br>GNU Parted 3.2<br>Using \/dev\/sda<br>Welcome to GNU Parted! Type &#8216;help&#8217; to view a list of commands.<br>(parted) print<br>Model: VMware Virtual disk (scsi)<br>Disk \/dev\/sda: 215GB #\u786c\u789f\u5bb9\u91cf\u4e00\u5171\u6709 215GB<br>Sector size (logical\/physical): 512B\/512B<br>Partition Table: gpt<br>Disk Flags:<br># \u5176\u4e2d number 3 \u53ea\u4f7f\u7528\u4e86 67.6GB<br>Number Start End Size File system Name Flags<br>1 1049kB 2097kB 1049kB bios_grub<br>2 2097kB 1076MB 1074MB ext4<br>3 1076MB 68.7GB 67.6GB<br><br># \u57f7\u884c partition resize \u64cd\u4f5c<br>(parted) resizepart<br>Partition number? 3<br>End? [68.7GB]? 215GB #\u4f7f\u7528\u6240\u6709\u7a7a\u9593<br>(parted) print<br>Model: VMware Virtual disk (scsi)<br>Disk \/dev\/sda: 215GB<br>Sector size (logical\/physical): 512B\/512B<br>Partition Table: gpt<br>Disk Flags:<br># \u6b64\u6642 number 3 partition \u5df2\u7d93\u4f7f\u7528\u4e86\u6240\u6709\u7a7a\u9593<br>Number Start End Size File system Name Flags<br>1 1049kB 2097kB 1049kB bios_grub<br>2 2097kB 1076MB 1074MB ext4<br>3 1076MB 215GB 214GB<br><br># \u96e2\u958b parted<br>(parted) quit<br>Information: You may need to update \/etc\/fstab.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u64f4\u5145-PV-\u7a7a\u9593\">\u64f4\u5145 PV \u7a7a\u9593<\/h2>\n\n\n\n<p>\u539f\u672c\u4e0a\u9762\u7684 number 3 partition \u5df2\u7d93\u662f\u73fe\u5b58\u7684 PV\uff0c\u65e2\u7136 partition \u5df2\u7d93\u8b8a\u5927\uff0c\u63a5\u8457\u5c31\u53ef\u4ee5\u76f4\u63a5\u9032\u884c resize \u7684\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>21<br>22<br>23<br>24<br>25<br>26<br>27<br>28<br>29<br>30<\/td><td># pv \u5c1a\u672a\u9032\u884c resize \u524d<br>$ pvdisplay<br>&#8212; Physical volume &#8212;<br>PV Name \/dev\/sda3<br>VG Name ubuntu-vg<br>PV Size &lt;63.00 GiB \/ not usable 0<br>Allocatable yes<br>PE Size 4.00 MiB<br>Total PE 16127<br>Free PE 3327<br>Allocated PE 12800<br>PV UUID cs39RZ-Dfac-qED7-KHNz-Liht-QMtu-FvhS04<br><br># \u57f7\u884c pvresize<br>$ pvresize \/dev\/sda3<br>Physical volume &#8220;\/dev\/sda3&#8221; changed<br>1 physical volume(s) resized \/ 0 physical volume(s) not resized<br><br># pv \u5df2\u7d93\u78ba\u5b9a\u7a7a\u9593\u8b8a\u5927(\u5f9e 63GB -&gt; 199GB)<br>$ pvdisplay<br>&#8212; Physical volume &#8212;<br>PV Name \/dev\/sda3<br>VG Name ubuntu-vg<br>PV Size &lt;199.00 GiB \/ not usable 16.50 KiB<br>Allocatable yes<br>PE Size 4.00 MiB<br>Total PE 50943<br>Free PE 38143<br>Allocated PE 12800<br>PV UUID cs39RZ-Dfac-qED7-KHNz-Liht-QMtu-FvhS04<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u6aa2\u67e5-VG-\u7a7a\u9593\">\u6aa2\u67e5 VG \u7a7a\u9593<\/h2>\n\n\n\n<p>\u5f9e\u4e0b\u9762\u7684\u57f7\u884c\u7d50\u679c\u53ef\u4ee5\u770b\u51fa\uff0c\u5305\u542b\u4e0a\u9762 PV \u7684 VG \u5bb9\u91cf\u4e5f\u8b8a\u5927\u4e86\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>21<\/td><td>$ vgdisplay<br>&#8212; Volume group &#8212;<br>VG Name ubuntu-vg<br>System ID<br>Format lvm2<br>Metadata Areas 1<br>Metadata Sequence No 3<br>VG Access read\/write<br>VG Status resizable<br>MAX LV 0<br>Cur LV 1<br>Open LV 1<br>Max PV 0<br>Cur PV 1<br>Act PV 1<br>VG Size &lt;199.00 GiB # \u8b8a\u6210 199GB \u4e86<br>PE Size 4.00 MiB<br>Total PE 50943<br>Alloc PE \/ Size 12800 \/ 50.00 GiB<br>Free PE \/ Size 38143 \/ &lt;149.00 GiB<br>VG UUID LRE3Y3-QvmP-mCI0-D0PT-Hk9w-3tqb-129LhN<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u64f4\u5145-LV-\u7a7a\u9593\">\u64f4\u5145 LV \u7a7a\u9593<\/h2>\n\n\n\n<p>\u63a5\u8457\u64f4\u5145 LV \u7684\u7a7a\u9593\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>21<br>22<br>23<br>24<br>25<br>26<br>27<br>28<br>29<br>30<br>31<br>32<br>33<br>34<br>35<br>36<br>37<br>38<br>39<br>40<br>41<br>42<br>43<br>44<br>45<br>46<\/td><td># \u539f\u672c\u7684 LV \u7a7a\u9593\u72c0\u6cc1<br>$ lvdisplay<br>&#8212; Logical volume &#8212;<br>LV Path \/dev\/ubuntu-vg\/ubuntu-lv<br>LV Name ubuntu-lv<br>VG Name ubuntu-vg<br>LV UUID xWDQsf-VimA-iX00-Kx6G-NzmJ-yaol-XVZr3L<br>LV Write Access read\/write<br>LV Creation host, time ubuntu-server, 2019-08-05 10:16:13 +0800<br>LV Status available<br># open 1<br>LV Size 50.00 GiB # \u53ea\u6709 50GB<br>Current LE 12800<br>Segments 1<br>Allocation inherit<br>Read ahead sectors auto<br>&#8211; currently set to 256<br>Block device 253:0<br><br># \u5c07 LV \u7a7a\u9593\u64f4\u5145\u6210 100GB<br>$ lvextend -L 100G \/dev\/ubuntu-vg\/ubuntu-lv<br>Size of logical volume ubuntu-vg\/ubuntu-lv changed from 50.00 GiB (12800 extents) to 100.00 GiB (25600 extents).<br>Logical volume ubuntu-vg\/ubuntu-lv successfully resized.<br><br># \u91cd\u65b0\u6aa2\u8996 LV \u72c0\u614b\uff0c\u7a7a\u9593\u5df2\u7d93\u6210\u529f\u7684\u64f4\u5145<br>$ lvdisplay<br>&#8212; Logical volume &#8212;<br>LV Path \/dev\/ubuntu-vg\/ubuntu-lv<br>LV Name ubuntu-lv<br>VG Name ubuntu-vg<br>LV UUID xWDQsf-VimA-iX00-Kx6G-NzmJ-yaol-XVZr3L<br>LV Write Access read\/write<br>LV Creation host, time ubuntu-server, 2019-08-05 10:16:13 +0800<br>LV Status available<br># open 1<br>LV Size 100.00 GiB # \u76ee\u524d\u662f 100GB<br>Current LE 25600<br>Segments 1<br>Allocation inherit<br>Read ahead sectors auto<br>&#8211; currently set to 256<br>Block device 253:0<br><br><br># \u6700\u5f8c\u8981\u4f7f\u7528 resize2fs \u8abf\u6574\u7684\u7a7a\u9593\u624d\u6703\u771f\u6b63\u751f\u6548<br>$ resize2fs \/dev\/ubuntu-vg\/ubuntu-lv<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\uff1a\u5c0f\u4fe1\u8c6c\u7684\u539f\u59cb\u90e8\u843d https:\/\/godleon.github.io\/blog\/Linux\/Linux- [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/soholab.tw\/index.php?rest_route=\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soholab.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soholab.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soholab.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/soholab.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":0,"href":"https:\/\/soholab.tw\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions"}],"wp:attachment":[{"href":"https:\/\/soholab.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soholab.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soholab.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}