[lug] unmount needed to shrink lvms?

Simos blug at chinesetearoom.com
Wed Dec 14 17:56:32 MST 2011


On Wednesday 14 December 2011 5:38 karl horlen wrote:
> i realize now after 2 years or so that that i allocated way too much space to a few LVMs.  i'd like to reclaim some of that wasted space now and allocate it to another LVM that could use the space.
> 
> 
> more specifically i created too much space for the following LVMs
> 
> /tmp
> /var
> /usr
> 
> is it ok to simply umount these partitions on a *live* server to perform the filesystem resize followed by an lvreduce or do i need to boot from a live or rescue cd to safely perform the ops?
> 
> if performing the ops on a *live* server, the system would not be able to write to /var logs if var is umounted for the little time this will take but i'm not sure if that would be a show stopper or not (will it cause the system to get in a bad state?).  if a process or service was using var will it recover ok once /var is brought back online?
> 
> 
> all the commands used to perform the operations to achieve this live in /sbin except for the /usr/sbin/lv* cmds, but perhaps i can just copy the one i need (lvreduce) to / filesystem as a workaround for the absence of /usr?  am i missing anything else by unmounting /usr on a *live* server?
> 
> umounting /tmp is probably fine for the short amt it won't be accessible?
> 
> 
> final question.  
> 
> 
> is there any *accurate* way to insure the filesystem reduction size will be less than or equal to the reduced LV?  or is it always a matter of performing the math and making the LV one or five "units" larger than the filesystem when you reduce it just to be safe? for instance, when extending an LV you can make it use 100% available which frees you from having to do the math.  was wondering is on a reduce you could tell it to resize itself to the new reduced filesystem size vs having to calculate and potentially mess up.

Karl,

It's extremely unlikely that you'll be able to unmount any of these filesystems
on a live server. There are many running system processes that are using them
and the only way to unmount the filesystems would be to kill them first, in which
case it will no longer be a "live" server.

Also, lvreduce will only reduce the logical volume (i.e. the filesystem "container").
You will need to run something resize2fs to shrink the filesystem itself. From the
resize2fs man page on my Debian system:

       The resize2fs program will resize ext2, ext3, or ext4 file systems.  It
       can  be  used  to enlarge or shrink an unmounted file system located on
       device.  If the filesystem is mounted, it can be  used  to  expand  the
       size  of  the  mounted filesystem, assuming the kernel supports on-line
       resizing.  (As of this writing, the Linux 2.6 kernel  supports  on-line
       resize for filesystems mounted using ext3 and ext4.).

Assuming you are running ext3 filesystems, you will almost certainly need to do
this either in single-user mode or a live CD.

Regards,

Simos



More information about the LUG mailing list