System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Reducing ext3 LVM2 filesystem on RHEL 4 AS.

SOLVED
Go to solution
Gulam Mohiuddin
Regular Advisor

Reducing ext3 LVM2 filesystem on RHEL 4 AS.

I would like to reduce /u02 filesystem about 5GB (from 35GB to 30GB), this mount point is not in use now.

I would really appreciate if someone could provide me appropriate commands/steps.

[root@dev06 ~]# df -h /u02
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup01-LogVol12
35G 15G 19G 45% /u02

Thanks,

Gulam.
Everyday Learning.
1 REPLY
Ivan Ferreira
Honored Contributor
Solution

Re: Reducing ext3 LVM2 filesystem on RHEL 4 AS.

Before reducing the size of a file system, take a full backup of it!!!!

You must reduce in two parts:

- Reduce the ext3 file system
- Reduce the logical volume

You must ensure that when you reduce the logical volume, the logical volume size is not less that the file system size or you can loss the data, so you can reduce the file system size and then reduce the logical volume to a size a little bigger than the file system size, to ensure that you won't break the file system.

Procedure to reduce a 6 GB file system/logical volume to 5 GB, in this case, is /dev/rhel4vg/lvrhel4:

*** Check the current size:

# df -h /mnt/rhel4
S.ficheros Tamaño Usado Disp Uso% Montado en
/dev/mapper/rhel4vg-lvrhel4
6,0G 141M 5,8G 3% /mnt/rhel4

# lvdisplay /dev/rhel4vg/lvrhel4
--- Logical volume ---
LV Name /dev/rhel4vg/lvrhel4
VG Name rhel4vg
LV UUID HcD4Es-Ar4s-0GaI-e3GS-29bI-8uuV-EE9NJH
LV Write Access read/write
LV Status available
# open 1
LV Size 6,00 GB
Current LE 1536
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:2

*** Umount the file system an run fsck:

# umount /mnt/rhel4/

# e2fsck -f /dev/mapper/rhel4vg-lvrhel4
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found. Create? yes

Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/mapper/rhel4vg-lvrhel4: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/rhel4vg-lvrhel4: 11/786432 files (18.2% non-contiguous), 60567/1572864 blocks

*** Resize the file sytem to 5 GB

# resize2fs /dev/rhel4vg/lvrhel4 5G
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/rhel4vg/lvrhel4 to 1310720 (4k) blocks.
The filesystem on /dev/rhel4vg/lvrhel4 is now 1310720 blocks long.

*** Resize the logical volume to a value a little bigger than 5 GB (Here you can see in the warning that will be reduced to 5,18 GB)

# lvreduce /dev/rhel4vg/lvrhel4 -L 5300M
/dev/cdrom: open failed: Sistema de ficheros de sólo lectura
Attempt to close device '/dev/cdrom' which is not open.
WARNING: Reducing active logical volume to 5,18 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvrhel4? [y/n]: y
Reducing logical volume lvrhel4 to 5,18 GB
Logical volume lvrhel4 successfully resized

*** Verify the new sizes

# lvdisplay /dev/rhel4vg/lvrhel4
--- Logical volume ---
LV Name /dev/rhel4vg/lvrhel4
VG Name rhel4vg
LV UUID HcD4Es-Ar4s-0GaI-e3GS-29bI-8uuV-EE9NJH
LV Write Access read/write
LV Status available
# open 0
LV Size 5,18 GB
Current LE 1325
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:2

# mount /mnt/rhel4/

# df -h /mnt/rhel4/
S.ficheros Tamaño Usado Disp Uso% Montado en
/dev/mapper/rhel4vg-lvrhel4
5,0G 141M 4,8G 3% /mnt/rhel4


Pretty cool!!, isn't it??
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?