{"id":43,"date":"2007-08-08T22:14:09","date_gmt":"2007-08-09T06:14:09","guid":{"rendered":"https:\/\/www.wkiri.com\/today\/?p=43"},"modified":"2007-08-08T22:42:22","modified_gmt":"2007-08-09T06:42:22","slug":"resizing-linux-partitions","status":"publish","type":"post","link":"https:\/\/www.wkiri.com\/today\/?p=43","title":{"rendered":"Resizing Linux partitions: yes, you can!"},"content":{"rendered":"<p>I recently installed Ubuntu linux, and everything came up working fine.  Then Ubuntu wanted to install &#8220;system updates&#8221; (all packages that have had updates since version 6.0.6 was released), so I let it go ahead and download the 200 MB of upgrades.  One of those upgrades was a new linux kernel (2.6.15-28, vs. my current 2.6.15-26).  To &#8220;install&#8221; this upgrade, Ubuntu attempted to write the new kernel into my \/boot partition.  Which lacked enough space.  &#8220;Write error!&#8221; Ubuntu declared, leaving half of a kernel stuck to the end of the partition.  I cleaned this off, happy to stay with my current kernel, but then I wondered.  Would I ever be able to upgrade my kernel?  Maybe 16 MB was too small for \/boot.  (Kernels are getting large and fat these days!)<\/p>\n<p>After hashing this over with some friends, the solution seemed straightforward.  I decided to stretch \/boot out to cover 128 MB &#8212; plenty of space for several kernels and all of their friends.  Now, partitions are physical divisions of your hard drive, so their position matters.  My 16-MB \/boot partition was first on the disk, followed by my 5-GB \/ partition (less than 1 GB used).  Therefore, I planned to save a full copy of \/boot and \/, modify both partitions, then copy my data back onto the partitions.<\/p>\n<p>After making and checking my full copy of this data, I turned to some man pages to acquaint myself with <tt>fdisk<\/tt> for the partitioning rite.  Here&#8217;s where I learned something: there is a utility, <tt>parted<\/tt>, that will permit you to <i>move<\/i> and <i>resize<\/i> partitions!  (For you geeks, this &#8220;resize&#8221; applies to both the partition and the filesystem, which is what does the trick.) Instead of destroying and re-creating them, saving and copying data, <i>in theory<\/i> I could simply shuffle them around.  <i>In theory<\/I>, this is all I would need to do:<\/p>\n<blockquote><p>\n\/dev\/hda5 goes from 65kB to 16MB<br \/>\n\/dev\/hda6 goes from 16MB to 5256MB<br \/>\nSo&#8230;<\/p>\n<ol><tt><\/p>\n<li>parted \/dev\/hda5\n<li>resize 6 128MB 5256MB <br \/># move and shrink \/dev\/hda6, which is \/, to start at 128MB\n<li>resize 5 65kB 128MB     <br \/># move and grow \/dev\/hda5, which is \/boot, to end at 128MB<br \/>\n<\/tt><\/ol>\n<\/blockquote>\n<p><i>In reality<\/i>, <tt>parted<\/tt> had some tricks up its sleeve.  It flat-out refused to move partition 6 anywhere above 17MB.  (&#8220;Error: unable to satisfy all constraints on the partition.&#8221;)  I still am not sure exactly what those constraints were, but in the end, here&#8217;s what worked:<\/p>\n<blockquote>\n<ol><tt><\/p>\n<li>resize 6 16MB 2000MB <br \/># really, it's mostly empty.  This was safe.  I hoped.\n<li>move 6 2000MB 4000MB<br \/># get partition 6 out of the way.  Note that I couldn't just move it to start at 128MB because you \"can't move a partition to overlap with itself\" and it ended at 2000 MB.\n<li>resize 5 65kB 128MB<br \/># grow partition 5\n<li>resize 6 2000MB 3000MB<br \/># parted won't let me resize 6 back down to start at 128 MB.  I can't move it there, either, because (you guessed it) it would overlap with its current position.  So I had to shrink it again.\n<li>move 6 128MB 1128MB<br \/># now I can move it down!\n<li>resize 6 128MB 5256MB<br \/># and make it bigger.<br \/>\n<\/tt>\n<\/p><\/blockquote>\n<p>Now I have that same post-puzzle fatigue-glow that you get after escaping Zork&#8217;s maze of twisty little passages.  Puzzle completed in 6 steps.  I could have done it in 5 if I&#8217;d known that I&#8217;d need to shrink partition 6 down to 1000MB from the start.  Thank goodness \/ gave me 5 GB to mess around in &#8212; and that the shrinking steps succeeded!  After rebooting, I&#8217;m back up and running, with 120 MB on \/boot (not 128, possibly because partitions like to start and stop on cylinder boundaries?).  Done!  And I can delete that backup copy I made and never needed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently installed Ubuntu linux, and everything came up working fine. Then Ubuntu wanted to install &#8220;system updates&#8221; (all packages that have had updates since version 6.0.6 was released), so I let it go ahead and download the 200 MB of upgrades. One of those upgrades was a new linux kernel (2.6.15-28, vs. my current [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23,2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/posts\/43"}],"collection":[{"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=43"}],"version-history":[{"count":0,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/posts\/43\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}