{"id":456,"date":"2010-01-23T20:45:15","date_gmt":"2010-01-24T00:45:15","guid":{"rendered":"http:\/\/www.timelordz.com\/blog\/?p=456"},"modified":"2010-01-26T22:33:04","modified_gmt":"2010-01-27T02:33:04","slug":"resize-default-lvm-partitions-and-move-boot","status":"publish","type":"post","link":"https:\/\/www.timelordz.com\/blog\/2010\/01\/resize-default-lvm-partitions-and-move-boot\/","title":{"rendered":"Resizing Default LVM Partitions and Moving \/boot"},"content":{"rendered":"<p><em><span style=\"color: #ff0000;\">Standard Disclaimer:<\/span> This article makes recommendations on using tools to modify your LVM configuration, your \/boot partition, kernel and grub. Data corruption from a mangled LVM, or a (temporarily) unbootable system through a corrupted or mis-configured grub, etc. are entirely possible. I am not responsible for any of this. If you have a running system and break it by changing these things, please realize that I am not to blame, nor will I be able to help you fix things. And of course, making complicated changes on a production environment is not advised. However, if you need to migrate to a larger \/boot partition the following may help you. If you are unfamiliar with partitioning, LVM and grub, please plan on having a least a few hours to work your way through this the first time. Also, have a Live CD and possibly the SuperGrub CD already available before hand. You may also want to practice on a virtual machine before trying this on a running server, etc. Installing Virtualbox and setting an a test VM takes only minutes and provides a superlative learning environment. <\/em><\/p>\n<p>There is only so far you can get with a 69M \/boot.<\/p>\n<p>If you are like me, when you last installed your distro you likely decided to go with the proposed LVM layout. Hey, why not right? This way you can more easily change the sizes of your logical volumes, adding more to home, stealing some from that \/whatever slice you just never really ended up using. Plus you can always add another physical drive later for juicy (or potentially disastrous, I&#8217;ve heard it both ways) multi-volume LVM expansion goodness.<\/p>\n<p>Or perhaps you just said &#8220;yea, sure &#8212; whatever&#8221; on the partitioning steps.<\/p>\n<p>Despite the best, or worst, planning you at times just need to fix what you are left with.<\/p>\n<p>In my case, for some reason know to only God and the face on Mars, when I last installed Suse I accepted the offered LVM layout, and along with the the pathetic 69M \/boot partition. Well, as you start to add some other kernels for Xen, the Suse default and desktop kernels, and if you want to keep any old versions of these, or compile your own, you very quickly realize what a mistake you made.<\/p>\n<p>Now, fixing this is not superlatively difficult of course, but there are easy ways and hard ways.<\/p>\n<p>The hard way involves manually shrinking the LVM Volume Group (vg) which also requires shrinking the Logical Volums (lv) which it contains, which of course requires shrinking the filesystems they contain. Oh the pain.<\/p>\n<p><!--more-->You might think that booting to a Live CD and using gparted is the answer to your prayers, but nope. It lacks LVM support, though it&#8217;s been on the drawing boards for some time it has yet to arrive.<\/p>\n<p>However, this lead me to discover the Enterprise Volume Management System at it&#8217;s <a href=\"http:\/\/sourceforge.net\/projects\/evms\" target=\"_blank\">sourceforge page<\/a>.\u00a0 This is quite a sophisticated filesystem management tool with many options and much greater granular control over your block storage device file systems. Take a look at these EVMS <a href=\"http:\/\/evms.sourceforge.net\/gui_screen\/\" target=\"_blank\">screenshots<\/a>, oh yes indeed &#8212; be still my heart.<\/p>\n<p>Depending on your distro and repos you may be able to simply install evms and evms-gui through your package manager. I simply used an Ubuntu LiveCD and installed both from the standard repos in minutes and was up and running.<\/p>\n<p>Once EVMS is installed, the answer to you tiny \/boot partition &#8212; sorry, your &#8220;size challenged&#8221; partition, are but a few clicks away. The basic recipe is:<\/p>\n<p>1) Use EVMS to shrink the Volume Group a bit. You likely just need to shave off a few hundred megs to make a new \/boot with<\/p>\n<p>2) The drive will likely now have space at the end of the device, the resize of the VG is more easily done by working from the end of, rather than the start of, the VG boundaries. This space is now unpartitioned and available. Simply create a new ext3 partition from it as you normally would, then mount it as perhaps \/newboot.<\/p>\n<p>3) Copy \/ move your files from your old \/boot to your \/newboot. This includes all the kernels, initrd files and (very important) the grub folder and its contents.<\/p>\n<p>4) Edit the menu.1st file in your grub directory in \/newboot. You will have to change the root (hd0,0) lines for each kernel to point to the new location, perhaps root (hd0,2). You may also have a line near the top: gfxmenu (hd0,0)\/message which will also need updated.\u00a0 (The next step clarifies the numbering scheme used.)<\/p>\n<p>5) Set up grub so that is will look to the new partition when booting. This is normally done by reconfiguring grub so using the grub command interface. In my case:<\/p>\n<pre># grub\r\ngrub&gt; root (hd0,2)\r\ngrub&gt; setup (hd0)\r\ngrub&gt; quit\r\n# reboot<\/pre>\n<p>Here we are telling grub that my new grub root (NOT system root) is (hd0,2). Grub numbering starts at zero, so this in fact is telling it \/hda3 (First drive, third partition). The setup command then installs the boot code into the MBR which will now look to the new \/boot partition. (This points grub &#8220;stage one&#8221; that runs at boot to the location containing the files in the \/grub directory (grub &#8220;stage 2&#8221;.)<\/p>\n<p>If things go horribly wrong, DON&#8217;T PANIC. The most likely scenario will be that you reboot and end up at a scary grub&gt; prompt. It is just a matter of telling grub which partition contains the kernel and initrd with the root(hdx,y) command, and then specifying the kernel=vmlinuz-2.6.blah and initrd=initrd-2.6.blah followed by the boot command. Note that grub allows for tab completion on all these steps, so it is usually not difficult to get up and running again.\u00a0 Grub is quite fantastic really, and has a powerful built in environment available at the grub&gt; prompt. If you get stuck on this step, these web sites are loaded with info that should help you get it sorted out.<\/p>\n<p>This <a href=\"http:\/\/www.linuxjournal.com\/article\/4622\" target=\"_blank\">Linux Journal Magazine<\/a> article is a fantastic place to learn more about grub commands and how to directly boot a kernel as briefly outlined above.<\/p>\n<p>And this <a href=\"http:\/\/www.troubleshooters.com\/linux\/grub\/grubpartition.htm\" target=\"_blank\">troubleshooting site<\/a> has some other useful information on grub. (See the section &#8220;making it happen at boot time&#8221;)<\/p>\n<p>Of course, there is also the official grub <a href=\"http:\/\/www.gnu.org\/software\/grub\/manual\/grub.html\" target=\"_blank\">documentation pages<\/a>.<\/p>\n<p>Lastly, if you get hopelessly stuck and can&#8217;t boot your system you might find the <a href=\"http:\/\/supergrubdisk.org\/\" target=\"_blank\">SuperGrub<\/a> Boot CD may save your day. This is a very handy tool and has a menu driven system to help recover from a variety of boot \/ grub \/ MBR\u00a0 related problems.<\/p>\n<p><strong>Closing notes:<\/strong><\/p>\n<p>I also see there is an <a title=\"\/EVMS\/2.5.5\/evms-2.5.5-initrd.gz:  released on 2006-02-26\" href=\"http:\/\/sourceforge.net\/projects\/evms\/files\/EVMS\/2.5.5\/evms-2.5.5-initrd.gz\/download\">evms-2.5.5-initrd.gz<\/a> file in the downloads, which leads me to think how easy it may be to set this up on a PXE network so this tool is readily available to you in a networked environment so you could quickly boot to it and have the tools directly available for system maintenance. I&#8217;ll have to play around with that a bit.<\/p>\n<p>Another option is to follow <a href=\"http:\/\/ubuntuforums.org\/showthread.php?t=216117\" target=\"_blank\">this post<\/a> and use the Fedora system-config-lvm package (converted to a .deb package if you need) which provides a similar GUI LVM management tool. However, EVMS is far more extensive. But its always good to have options.<\/p>\n<p>I hope the above suggestions are helpful to you and that you find evms to be as valuable as I did.<\/p>\n<p>These partitioning issues can be difficult, and having tools like evms can certainly make it much easier.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Standard Disclaimer: This article makes recommendations on using tools to modify your LVM configuration, your \/boot partition, kernel and grub. Data corruption from a mangled LVM, or a (temporarily) unbootable system through a corrupted or mis-configured grub, etc. are entirely possible. I am not responsible for any of this. If you have a running system [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[26],"class_list":["post-456","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux-grub-boot-partition-lvm-evms"],"_links":{"self":[{"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/posts\/456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/comments?post=456"}],"version-history":[{"count":5,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/posts\/456\/revisions"}],"predecessor-version":[{"id":458,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/posts\/456\/revisions\/458"}],"wp:attachment":[{"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/media?parent=456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/categories?post=456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/tags?post=456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}