LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   reducing ext3 lvm's. (https://www.linuxquestions.org/questions/red-hat-31/reducing-ext3-lvms-301270/)

majeztik 03-13-2005 08:01 PM

reducing ext3 lvm's.
 
Hey guys,

I am trying to resize an LVM from 5000mb to 1000mb. It is currently using an ext3 filesystem. I need to be able to do this without losing any data that is on the partition.

Now after doing a bit of research I came across the example:

umount /home
e2fsadm −L−1G /dev/myvg/
mount /home

Now i know this will certainly work with an ext2 filesystem, but what about ext3?

any comments are appreciated.

cheers.

majeztik 03-14-2005 12:33 AM

hey guys,

I found a solution to this:

Quote:

Logical volumes may be resized dynamically while preserving the data on the volume, if the volume's filesystem supports resizing.

The e2fsadm command allows resizing of an ext2 or ext3 based logical volume. It is a front-end to utilities like lvextend, lvreduce, and resize2fs. ext2online can be used to grow mounted ext2/3 filesystems. Lvextend must be called first to grow the logical volume.

The following commands will grow the mounted /dev/vg0/data filesystem.

lvextend -L +500M /dev/vg0/data

ext2online /dev/vg0/data

e2fsadm -L -16M /dev/vg0/scratch (reduce /dev/vg0/scratch by 16 MB)

e2fsadm -L +128M /dev/vg0/data (extend /dev/vg0/data by 128 MB)

e2fsadm -l -8 /dev/vg0/data (reduce /dev/vg0/data by 8 extents)

For other filesystems, the lvextend utility can be used to add unallocated extents in the volume group to a logical volume. Then native utilities for the filesystem can be used to expand it to fill the volume. To reduce a filesystem, first the native utilities should be used to shrink the filesystem, then lvreduce should be used to shrink the logical volume.

voip_tech_2004 04-10-2006 05:51 PM

lvm2 on rhel 4 does not have e2fsadm(it's obsolete).

[root@d400-image ~]# lvresize --resizefs -L 1M /dev/lvm-hdx/lvm0
/dev/cdrom: open failed: Read-only file system
Rounding up size to full physical extent 4.00 MB
fsadm: execlp failed: No such file or directory
fsadm failed: 2

Is there any solution in rhel 4 with NO e2fsadm but still want to shirnk the lv???

RHELL 04-12-2006 02:33 PM

resize2fs, then lvreduce.

voip_tech_2004 04-15-2006 02:24 PM

resize2fs does not exist on rhel 4

shankarjha 04-16-2006 11:11 PM

resize2fs /dev/lvm-hdx/lvm0 +100M
umount /dev/lvm-hdx/lvm0
lvreduce -L +100M /dev/lvm-hdx/lvm0
mount /dev/lvm-hdx/lvm0
ex2online /dev/lvm-hdx/lvm0
Shankar
RHCE

rizhun 01-04-2010 08:18 AM

Did anyone test this?

I needed to decrease a LV from 2GB to 1GB.

I followed a similar method online, but now I have an error when I try and fsck, here's what I did:

Code:

$ umount /my/mount/point
$ fsck -n /lv/device/path                      # returned clean
$ tune2fs -O ^has_journal /lv/device/path      # convert to ext2
$ e2fsck -f /lv/device/path                    # still clean
$ resize2fs /lv/device/path 1G                  # 1GB is orig size
$ e2fsck -f /lv/device/path                    # still clean
$ lvreduce -L -1G /lv/device/path
$ vgreduce myvg /dev/sdd
$ tune2fs -j /lv/device/path
$ fsck -n /lv/device/path
fsck 1.38 (30-Jun-2005)
e2fsck 1.38 (30-Jun-2005)
The filesystem size (according to the superblock) is 1048576 blocks
The physical size of the device is 1044480 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort? no

/lv/device/path contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/lv/device/path: 449/262144 files (18.3% non-contiguous), 138541/1048576 blocks

If it's toast, I can restore, but it will annoy me if I don't know how I broke it!

Thanks,

rizhun 01-04-2010 08:52 AM

Fixed it:

Code:

$ e2fsck -f /lv/device/path
$ resize2fs /lv/device/path

I guess this set it back to the original size, which was the entire disk (not including the newly removed disk).


All times are GMT -5. The time now is 12:53 PM.