-   Red Hat (
-   -   Shrinking a Logical Volume With LVM (

jimmyjiang 02-28-2008 04:08 PM

Shrinking a Logical Volume With LVM
I have a centOS 5 server with LVM,
[root@p3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
17G 3.7G 13G 23% /
/dev/hda1 99M 25M 70M 26% /boot
tmpfs 256M 0 256M 0% /dev/shm
[root@p3 ~]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw,size=256m)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

since the "/" take all the space, I want to shrink it, but how can I umount it?

[root@p3 ~]# umount /
umount: /: device is busy
umount: /: device is busy

thanks in advance!

rayfordj 02-28-2008 04:45 PM

I'm not sure this is something you can do while running on the root volume.

The easiest route (or the route I'd take) will probably be to boot to rescue media, activate the VolumeGroup, force fsck /dev/VolGroup00/LogVol00, resize2fs to the reduced size you want, lvreduce the LogicalVolume.

Keep in mind that if you reduce it too much (smaller than you have data consumption) you'll run into problems. also, you don't want to reduce the LV smaller than the filesystem. I usually fudge an extent or two just to be safe.

May not be a bad idea to have a backup of anything you want to keep ahead of time... just in case. ;)

If all goes well, then you reboot successfully and use the reclaimed extents for whatever other Logical Volume(s) you want.

All times are GMT -5. The time now is 05:24 AM.