LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (https://www.linuxquestions.org/questions/fedora-35/)
-   -   How to Resize Root LVM Logical Volume??? (https://www.linuxquestions.org/questions/fedora-35/how-to-resize-root-lvm-logical-volume-337823/)

jdupre 06-27-2005 07:31 PM

How to Resize Root LVM Logical Volume???
 
I have been pulling my hair out all afternoon over this:

How do I resize the *root* LVM Logical Volume (/dev/VolGroup00/LogVol00) as created by a "default" install of Fedora?

OR

How do I create the block device entries for LVM Logical volumes when booting with a rescue CD (i.e /dev/VolGroup00/LogVol00)?

OR

How do I unmount /mnt/sysimage if I have mounted it when booting from a rescue CD?


I know how to resize the LV provided that I can unmount it AND have the block device defined in /dev. But, I can't unmount the root volume on a live system. So I must use the "rescue" CD to boot the system.

But, if I boot with the rescue CD and skip mounting the system partitions, then the block entries for LVM in /dev are not created. If I boot from the rescue CD and do mount the system partitions, the /dev block devices are created but I can't umount the /mnt/sysimage (I get a device is busy error). I get this umount error even after unmounting /mnt/sysimage/boot and /mnt/sysimage/dev.

Please help save my hair!

uberNUT69 06-27-2005 07:44 PM

1. resizing lvm root:
Use an LVM2 enabled livecd like:
Debian From Scratch http://people.debian.org/~jgoerzen/dfs/
2. LVM device nodes are created by an lvm2 enabled kernel! :)

WhatsHisName 06-28-2005 01:07 AM

To activate the LVMs in FC4 Rescue Mode, run this from the command line:

lvm vgchange -a y

For a list of LVM commands, run:

lvm help

There is a really good LVM HowTo here http://www.ibiblio.org/pub/Linux/doc...LVM-HOWTO.html

The bottom line about resizing ext3 logical volumes is that it is easy to make them bigger, but difficult to make them smaller. In theory, the resize2fs command can reduce the size of the ext3 filesystem, but in practice, you will get a fatal error message regarding the new target size when you try to reduce the ext3 filesystem.

RedHat has really screwed everyone who uses the installation default LVM partitioning scheme, because it fills the volume group with logical volume(s), but does not provide tools for reducing the ext3 logical volumes to allow others to be created or enlarged. I anticipate that these tools will appear at some future date, presumably before the release of RHEL5. But, for now, you're screwed.

uberNUT69 06-28-2005 07:27 AM

I've had no such problems using DFS, or Debian Sid. Growing/shrinking both filesystems and logical volumes have been painless. As a bonus, using a rescue cd also provides an easy way to dd the filesystems to an image file over nfs before any changes are made (jic;)).

jdupre 06-29-2005 03:01 PM

Thank you for the replies.
I was sucessfull in reducing the root LVM logical volume on a default FC3 install to 10G with the following commands:

Boot with rescue CD. Skip mounting of the system partitions.

# lvm vgchange -a y
# e2fsck -f /dev/VolGroup00/LogVol00
# resize2fs -f /dev/VolGroup00/LogVol00 10G
# lvreduce -L10G /dev/VolGroup00/LogVol00

I recieved a message "Please run e2fsck -f /dev/VolGroup00/LogVol00" when trying to run resize2fs (even after I had run e2fsck) so I added the -f switch to force the resize. All went well.

- Joe

jdupre 06-29-2005 03:46 PM

Sorry, the correct command is:

# lvm lvreduce -L10G /dev/VolGroup00/LogVol00

lvreduce is a symlink not available on the rescue filesystem.

- J

WhatsHisName 06-29-2005 08:03 PM

It’s a good thing that uberNUT69 and jdupre pointed out that resize2fs reduced their ext3's without any problems, because it got me to go back and look at it again.

The bottom line is that resize2fs does an excellent job of reducing the ext3 size, as long as you remember to leave room for the root reserve space when you shrink the ext3.

Previously, I was trying to first reduce the ext3 to a minimal size before reducing the LV size, followed by expanding the ext3 to the new LV size. The idea was to avoid any possibility of clipping the end of the ext3, by first making it smaller than the new LV size. What I forgot to do was to allow for the root reserve space when I picked a target size for the interim ext3. Once that was entered into the calculation, everything worked fine.

uberNUT69 06-30-2005 01:05 AM

I seem to remember the instructions mention multiplying the reported (used) size of the filesystem by 1.1 ... for a "minimum" shrink.

voip_tech_2004 04-10-2006 06:02 PM

I tried lvm lvreduce command and it LOOked like it was working but didnt see the results I was looking for when I did df -h....

Can someone please tell me what's going on with resizing in LVM2???


[root@d400-image ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 2.0G 1.5G 389M 80% /
none 252M 0 252M 0% /dev/shm
/dev/hdc 4.8M 4.8M 0 100% /media/cdrecorder
/dev/mapper/lvm--hdx-lvm0
504M 11M 468M 3% /test_vol

[root@d400-image ~]# umount /dev/lvm-hdx/lvm0 /test_vol
umount: /dev/mapper/lvm--hdx-lvm0: not mounted
umount: /dev/mapper/lvm--hdx-lvm0: not mounted

[root@d400-image ~]# lvm lvreduce -L10M /dev/lvm-hdx/lvm0
/dev/cdrom: open failed: Read-only file system
Rounding up size to full physical extent 12.00 MB
WARNING: Reducing active logical volume to 12.00 MB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvm0? [y/n]: y
Reducing logical volume lvm0 to 12.00 MB
Logical volume lvm0 successfully resized

[root@d400-image ~]# mount /dev/lvm-hdx/lvm0 /test_vol
[root@d400-image ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 2.0G 1.5G 389M 80% /
none 252M 0 252M 0% /dev/shm
/dev/hdc 4.8M 4.8M 0 100% /media/cdrecorder
/dev/mapper/lvm--hdx-lvm0
504M 11M 468M 3% /test_vol


i umounted again and then tried but got below

[root@d400-image ~]# lvm lvreduce -L1M /dev/lvm-hdx/lvm0
/dev/cdrom: open failed: Read-only file system
Rounding up size to full physical extent 4.00 MB
New size (1 extents) matches existing size (1 extents)
lvreduce: Reduce the size of a logical volume

uberNUT69 04-10-2006 08:20 PM

If you are reducing an LVM partition, you should resize the
filesystem on it first. Even if your lvreduce command had
worked as you intented, your df command probably would
not have shown a difference size because the filesystem
hasn't been changed, just the device it sits on.

Next, the lvreduce command is rounding up to the nearest
physical extent, so how about you run your tests on a
larger partition, eg. 50MB ?

voip_tech_2004 04-11-2006 12:07 AM

resize2fs doesn't exist in lvm2... how do resize the filesystem?????

bboy-mass 08-19-2006 10:12 AM

Hi,

Ive been trying to reduce my /root ext3 volume with the above instructions. I had the usual WARNING messages, but my main concern was the following error message:

Bad boot block on volume or volume NOT a ext2 file system????

Whats the cause of this? It seems like other people are using e2fsck on a ext3 file system,
so is mine failing?

BTW, Im using FC5, could this be the problem?

bboy-mass 08-27-2006 04:45 AM

All sorted.

Followed jdupre's guide and it worked a treat.

I put this on the white board at work, and everyone thinks im wonderfull now.:)

Thanks.

dhru 01-25-2007 08:50 AM

hi

command to enter into volume
i want the command to check the size of files and folders which are in volume

gerardw 09-27-2008 08:48 AM

Easy now
 
This is actually pretty easy now, although it wasn't obvious to me. (Fedora Core 6, Kernel 2.6.22)
Although I couldn't use "system-config-lvm," lvextend and resize2fs from the command line was all I needed. Apparently online resizing is now in the Kernel.

linux-who? 07-30-2009 12:06 PM

Quote:

Originally Posted by jdupre (Post 1721395)
Thank you for the replies.
I was sucessfull in reducing the root LVM logical volume on a default FC3 install to 10G with the following commands:

Boot with rescue CD. Skip mounting of the system partitions.

# lvm vgchange -a y
# e2fsck -f /dev/VolGroup00/LogVol00
# resize2fs -f /dev/VolGroup00/LogVol00 10G
# lvreduce -L10G /dev/VolGroup00/LogVol00

I recieved a message "Please run e2fsck -f /dev/VolGroup00/LogVol00" when trying to run resize2fs (even after I had run e2fsck) so I added the -f switch to force the resize. All went well.

- Joe

Hi All....this worked for me as well w/ RHEL 5.2

linux-who? 07-30-2009 12:08 PM

Quote:

Originally Posted by WhatsHisName (Post 1718036)
To activate the LVMs in FC4 Rescue Mode, run this from the command line:

lvm vgchange -a y

For a list of LVM commands, run:

lvm help

There is a really good LVM HowTo here http://www.ibiblio.org/pub/Linux/doc...LVM-HOWTO.html

The bottom line about resizing ext3 logical volumes is that it is easy to make them bigger, but difficult to make them smaller. In theory, the resize2fs command can reduce the size of the ext3 filesystem, but in practice, you will get a fatal error message regarding the new target size when you try to reduce the ext3 filesystem.

RedHat has really screwed everyone who uses the installation default LVM partitioning scheme, because it fills the volume group with logical volume(s), but does not provide tools for reducing the ext3 logical volumes to allow others to be created or enlarged. I anticipate that these tools will appear at some future date, presumably before the release of RHEL5. But, for now, you're screwed.

You hit the nail on the head....
By the way, it doesn't look like RH has addressed this in RHEL5....still screwed....well not totally screwed i guess.....the work around above does work

angelinap 10-02-2010 07:21 AM

It worked on RH ES 5
 
I just followed instructions as per Joe postings ... and worked perfectly!

Thank you!


All times are GMT -5. The time now is 08:01 PM.