{"id":228,"date":"2009-05-10T12:07:40","date_gmt":"2009-05-10T10:07:40","guid":{"rendered":"http:\/\/raftaman.net\/?p=228"},"modified":"2021-05-15T11:46:42","modified_gmt":"2021-05-15T09:46:42","slug":"online-resizing-ext3-partitions","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=228","title":{"rendered":"Online resizing ext3 partitions"},"content":{"rendered":"<p>First, we have to delete our current partition and create a bigger one (don&#8217;t be afraid, no data will be lost):<\/p>\n<pre class=\"brush: plain; light: true; title: ; notranslate\" title=\"\">\r\n# fdisk \/dev\/xvda\r\n<\/pre>\n<p>Type m to get a list of all commands:<\/p>\n<pre class=\"brush: plain; light: true; title: ; notranslate\" title=\"\">\r\nCommand (m for help): m\r\nCommand action\r\n   a   toggle a bootable flag\r\n   b   edit bsd disklabel\r\n   c   toggle the dos compatibility flag\r\n   d   delete a partition\r\n   l   list known partition types\r\n   m   print this menu\r\n   n   add a new partition\r\n   o   create a new empty DOS partition table\r\n   p   print the partition table\r\n   q   quit without saving changes\r\n   s   create a new empty Sun disklabel\r\n   t   change a partition's system id\r\n   u   change display\/entry units\r\n   v   verify the partition table\r\n   w   write table to disk and exit\r\n   x   extra functionality (experts only)\r\n<\/pre>\n<p>Let&#8217;s print out the partition table and look for the ext3 partition, we want to enlarge (it&#8217;s easy here, there is just one partition):<\/p>\n<pre class=\"brush: plain; light: true; title: ; notranslate\" title=\"\">\r\nCommand (m for help): p\r\n\r\nDisk \/dev\/xvda: 5218 MB, 5218304000 bytes\r\n255 heads, 63 sectors\/track, 634 cylinders\r\nUnits = cylinders of 16065 * 512 = 8225280 bytes\r\n\r\n    Device Boot      Start         End      Blocks   Id  System\r\n\/dev\/xvda1   *           1         634     5092573+  83  Linux\r\n<\/pre>\n<p>Now we delete the old partition (\/dev\/xvda1) and create a new one with the maximum available size:<\/p>\n<pre class=\"brush: plain; light: true; title: ; notranslate\" title=\"\">\r\nCommand (m for help): d\r\nSelected partition 1\r\n\r\nCommand (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-634, default 1): \r\nUsing default value 1\r\nLast cylinder or +size or +sizeM or +sizeK (1-634, default 634): \r\nUsing default value 634\r\n<\/pre>\n<p>Our original \/dev\/xvda1 had the bootable flag (see fdisk -l output), so we must add it to our new \/dev\/xvda1 again:<\/p>\n<pre class=\"brush: plain; light: true; title: ; notranslate\" title=\"\">\r\nCommand (m for help): a\r\nPartition number (1-4): 1\r\n<\/pre>\n<p>Now let&#8217;s write our new partition table and exit fdisk:<\/p>\n<pre class=\"brush: plain; light: true; title: ; notranslate\" title=\"\">\r\nCommand (m for help): w\r\nThe partition table has been altered!\r\n\r\nCalling ioctl() to re-read partition table.\r\n\r\nWARNING: Re-reading the partition table failed with error 16: Device or resource busy.\r\nThe kernel still uses the old table.\r\nThe new table will be used at the next reboot.\r\nSyncing disks.\r\n<\/pre>\n<p>After rebooting the system (!) we can online-resize the filesystem with a simple command:<\/p>\n<pre class=\"brush: plain; light: true; title: ; notranslate\" title=\"\">\r\n# resize2fs \/dev\/xvda1 \r\nresize2fs 1.39 (29-May-2006)\r\nFilesystem at \/dev\/xvda1 is mounted on \/; on-line resizing required\r\nPerforming an on-line resize of \/dev\/xvda1 to 1522150 (4k) blocks.\r\nThe filesystem on \/dev\/xvda1 is now 1522150 blocks long.\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>First, we have to delete our current partition and create a bigger one (don&#8217;t be afraid, no data will be lost): # fdisk \/dev\/xvda Type m to get a list of all commands: Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=228\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13,7,16],"class_list":["post-228","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-centos","tag-fedora","tag-xen"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=228"}],"version-history":[{"count":6,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":2705,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/228\/revisions\/2705"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}