{"id":53,"date":"2015-12-03T19:29:51","date_gmt":"2015-12-03T11:29:51","guid":{"rendered":"http:\/\/www.prayerlaputa.com\/?p=53"},"modified":"2015-12-03T19:29:51","modified_gmt":"2015-12-03T11:29:51","slug":"%e4%bd%bf%e7%94%a8fdisk%e5%92%8cresize2fs%e9%87%8d%e7%bd%aeubuntu%e7%b3%bb%e7%bb%9f%e5%88%86%e5%8c%ba%e8%a1%a8%e3%80%90%e8%bd%ac%e8%bd%bd%e3%80%91","status":"publish","type":"post","link":"http:\/\/prayerlaputa.com\/?p=53","title":{"rendered":"\u4f7f\u7528fdisk\u548cresize2fs\u91cd\u7f6eubuntu\u7cfb\u7edf\u5206\u533a\u8868\u3010\u8f6c\u8f7d\u3011"},"content":{"rendered":"<p>\u6211\u53ea\u662f\u4e2a\u642c\u8fd0\u5de5\uff0c\u521a\u597d\u78b0\u5230\u865a\u62df\u673a\u4e2dubuntu\u7a7a\u95f4\u4e0d\u591f\u3001\u9700\u8981\u6269\u5927\u865a\u62df\u673a\u78c1\u76d8\uff0cvmware\u600e\u4e48\u6269\u5c55\u7f51\u4e0a\u5e16\u5b50\u5f88\u591a\uff0c\u4e0d\u8bf4\u4e86\uff0c\u4f46vmware\u6269\u5c55\u865a\u62df\u673a\u78c1\u76d8\u540e\uff0c\u6587\u4ef6\u7cfb\u7edf\u4e2d\u5e76\u6ca1\u6709\u53cd\u5e94\u5904\u7406\uff0c\u5c31\u9700\u8981\u6211\u4eec\u6765\u66f4\u65b0\u5206\u533a\u8868\u5565\u7684\u3002\u7136\u540e\u8fd9\u4e2a\u6211\u67e5\u4e86\u597d\u591a\u5e16\u5b50\uff0c\u7ec8\u4e8e\u627e\u5230\u6bd4\u8f83\u9760\u8c31\u7684\u5e16\u5b50\uff0c\u9042\u8f6c\u8f7d\u4e00\u4e0b\uff0c\u505a\u4e2a\u8bb0\u5f55\uff08\u8bdd\u8bf4\u5ea6\u5a18\u771f\u641c\u4e0d\u51fa\u4e1c\u897f\u554a\uff0c\u8fd8\u662fgoogle\u8fd8\u662f\u2026\u2026\uff09<br \/>\n\u539f\u5e16\u5730\u5740\uff1a<a href=\"http:\/\/askubuntu.com\/questions\/24027\/how-can-i-resize-an-ext-root-partition-at-runtime\">http:\/\/askubuntu.com\/questions\/24027\/how-can-i-resize-an-ext-root-partition-at-runtime<\/a><br \/>\n\u53e6\u4e00\u4e2a\u7c7b\u4f3c\u7684\u5e16\u5b50\u4e5f\u8d34\u51fa\u6765\uff1a<a href=\"https:\/\/www.rootusers.com\/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-machine-disk\/\">https:\/\/www.rootusers.com\/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-machine-disk\/<\/a><!--more--><br \/>\nvmware\u5012\u662f\u7ed9\u51fa\u4e86\u4fee\u6539RedHat\/CentOS\u7684\u4fee\u6539\u65b9\u5f0f\uff1a<a href=\"http:\/\/kb.vmware.com\/selfservice\/microsites\/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1006371\">http:\/\/kb.vmware.com\/selfservice\/microsites\/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1006371<\/a><span id=\"more-596\"><\/span><br \/>\n\u4ee5\u4e0b\u662f\u5e16\u5b50\u6b63\u6587\uff1a<br \/>\nHow can I increase the size of the root partition of a system at runtime?<br \/>\nI have a partition that is not allocated after the root partition (which is also ext4), how can I add that unallocated space to the space allocated to the root partition without having to shutdown the server?<br \/>\n&nbsp;<br \/>\nThere are two steps to this: First, the partition must be resized. If you\u2019re using LVM, it\u2019s easy; if you\u2019re using classic partitions, it\u2019s a bit more complicated, and might require a reboot (though you never have to boot another system or live CD).<br \/>\nOne fragile but feasible approach (worked for me) is to use <code>fdisk<\/code> by first deleting the partition, then carefully recreating it with a larger size at the same position. You can do this while the partition is mounted, but you will need to reboot for the kernel to notice the changed partition table.<br \/>\nExample:<\/p>\n<pre><code>$ sudo fdisk \/dev\/sda\nCommand (m for help): p\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *        2048     9437183     4717568   83  Linux\nCommand (m for help): d\nSelected partition 1\nCommand (m for help): p\n   Device Boot      Start         End      Blocks   Id  System\nCommand (m for help): n\nCommand action\n   e   extended\n   p   primary partition (1-4)\np\nPartition number (1-4, default 1): 1\nFirst sector (2048-10485759, default 2048):\nUsing default value 2048\nLast sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759):\nUsing default value 10485759\nCommand (m for help): p\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1            2048    10485759     5241856   83  Linux\nCommand (m for help): w\nThe partition table has been altered!\nCalling ioctl() to re-read partition table.\nWARNING: Re-reading the partition table failed with error 16: Device or resource busy.\nThe kernel still uses the old table. The new table will be used at\nthe next reboot or after you run partprobe(8) or kpartx(8)\nSyncing disks.\n<\/code><\/pre>\n<p>Again, it is critical that the new partition starts at the same block as the old. The Id should also match (83 for Linux systems). Be prepared to lose all your data at the slightest typo.<br \/>\nRemember to add the boot flag again, if necessary.<br \/>\nBy now it should be apparent why people recommend using a live CD. \ud83d\ude09<br \/>\nHowever, once the partition is resized (and the system rebooted, if necessary), it\u2019s a simple matter of running <code>resize2fs<\/code> on the file system, and you can do this even when it\u2019s mounted as the root partition.<br \/>\nExample:<\/p>\n<pre><code>$ sudo resize2fs \/dev\/sda1<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u53ea\u662f\u4e2a\u642c\u8fd0\u5de5\uff0c\u521a\u597d\u78b0\u5230\u865a\u62df\u673a\u4e2dubuntu\u7a7a\u95f4\u4e0d\u591f\u3001\u9700\u8981\u6269\u5927\u865a\u62df\u673a\u78c1\u76d8\uff0cvmware\u600e\u4e48\u6269\u5c55\u7f51\u4e0a\u5e16\u5b50\u5f88\u591a\uff0c\u4e0d <a href='http:\/\/prayerlaputa.com\/?p=53' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[7,12,14],"tags":[34,44,46],"_links":{"self":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/53"}],"collection":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=53"}],"version-history":[{"count":0,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/53\/revisions"}],"wp:attachment":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}