{"id":78,"date":"2013-09-30T07:22:13","date_gmt":"2013-09-30T07:22:13","guid":{"rendered":"http:\/\/muse.oneshot.in\/?p=78"},"modified":"2013-09-30T07:22:13","modified_gmt":"2013-09-30T07:22:13","slug":"resize-root-lvm-logical-volume","status":"publish","type":"post","link":"https:\/\/muse.oneshot.in\/?p=78","title":{"rendered":"Resize Root LVM Logical Volume"},"content":{"rendered":"<p><tt>If the volume to be reduced is the root partition that you currently <\/tt><tt>have booted, then you won't be able to unmount, and a somewhat more <\/tt><tt>involved procedure is needed. If you already have another bootable <\/tt><tt>harddisk, then perhaps the easiest thing to do is boot that disk with <\/tt><tt>the disk to be modified as a secondary disk, and then just modify the <\/tt><tt>volume using the above mentioned steps. <\/tt><tt>If you don't have another bootable harddisk, presumably you have a <\/tt><tt>bootable OS installation cdrom\/dvd, which can be booted in linux rescue <\/tt><tt>mode. That is, allow the CD to boot, and at the first prompt, type <\/tt><tt>\"linux rescue\". If that works, you are on your way. When a prompt is <\/tt><tt>given asking whether you want it to find and mount partitions, select <\/tt><tt>\"skip\". I found that if I allowed it to mount the root partition, I <\/tt><tt>could not unmount it. After a few more moments, it should finish and <\/tt><tt>drop you to a prompt. <\/tt><tt>In rescue mode, the vgscan, etc commands are not directly present, but <\/tt><tt>the executable lvm is, which can do all those things. When you run lvm, <\/tt><tt>you will get a new prompt, where you type lvm commands. In the <\/tt><tt>following, the linux prompt is '#' and the lvm prompt is '&gt;'. And I have <\/tt><tt>used the default group\/volume names supplied by Fedora, since presumably <\/tt><tt>a newbie reading this will have used the defaults, and anyone else will <\/tt><tt>be able to figure out what to change. <\/tt><tt>When we skipped allowing linux rescue to find and mount the logical <\/tt><tt>volumes, it also did not create device files we will need to use. So the <\/tt><tt>first task to be accomplished is to use lvm to create those device files. <\/tt><\/p>\n<pre># lvm\r\n&gt; vgscan<\/pre>\n<p><tt>It should should show the existing group or groups. The first task <\/tt><tt>required is to activate the group. <\/tt><\/p>\n<pre>&gt; vgchange -a y VolGroup00\r\nThen generate the device files.\r\n&gt; vgmknodes\r\n&gt; exit<\/pre>\n<p><tt>Now shrink the existing filesystem to something a bit smaller than what <\/tt><tt>you want the final filesystem size to be. You will first need to run <\/tt><tt>fsck on the filesystem. For example, I wanted a 36GByte final size, so I <\/tt><tt>used: <\/tt><\/p>\n<pre># e2fsck -f \/dev\/mapper\/VolGroup00-LogVol00\r\n# resize2fs \/dev\/mapper\/VolGroup00-LogVol00 35G<\/pre>\n<p><tt>Now we can shrink the volume to the desired size. Yes, the lvreduce <\/tt><tt>command uses a different device file name. <\/tt><\/p>\n<pre># lvm\r\n&gt; lvreduce -L36G \/dev\/VolGroup00\/LogVol00\r\n&gt; exit<\/pre>\n<p><tt>Now expand the filesystem to the full size of the volume. Notice that no <\/tt><tt>size parameter is used in the resize command this time. <\/tt><\/p>\n<pre># resize2fs \/dev\/mapper\/VolGroup00-LogVol00\r\nNow you can try to mount and look at it.\r\n# mkdir \/mnt\/sysimage\r\n# mount \/dev\/mapper\/VolGroup00-LogVol00 \/mnt\/sysimage\r\n# df\r\n# ls \/mnt\/sysimage\r\nIt should show up with the right 36GByte size, and everything intact.\r\nCourtesy: Redhat Archives\r\nNote: All the Postings here are tested and then posted<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If the volume to be reduced is the root partition that you currently have booted, then you won&#8217;t be able to unmount, and a somewhat more involved procedure is needed. If you already have another bootable harddisk, then perhaps the easiest thing to do is boot that disk with the disk to be modified as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-information-technology","category-redhat"],"_links":{"self":[{"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=78"}],"version-history":[{"count":1,"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":79,"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions\/79"}],"wp:attachment":[{"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/muse.oneshot.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}