Link to home
Start Free TrialLog in
Avatar of Mark Geerlings
Mark GeerlingsFlag for United States of America

asked on

How can I resize /var smaller in a new LVM system?

I'm in the process of setting up a new Linux server, so I have no production data on it yet, and nothing installed or running on it yet other than the O/S.  This is Oracle's "Enterprise Linux 4" (same as RedHat 4AS).  I chose "LVM" during the install and remembered to set up separate partitions for: /home, /opt, /tmp and /usr (plus the default partitions for /boot and /swap) then left the balance of the RAID1 local SCSI disk (about 70GB) for: /var.  But, I should have set up two more separate partitions of 8GB each and left /var somewhat smaller.

I'm assuming there must be a way to resize /var smaller under LVM and create to new partitions in that space without having to do a complete O/S re-install, right?  At this point an O/S re-install would only waste about 3 hours of my time, and there would be no data loss, but I'm trying to avoid the waste of time and learn some more about what's possible in Linux too.  I may be an expert in Oracle but I have no UNIX experience and only limited Linux experience.

What are my options?  Is there a relatively easy way to make my (ext3) /var partition smaller?
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of noci
noci

Oh, and if there is not sufficient space available on the system you might be able to temporily plug an USB disk into the system, to add a few GB of storage..
Avatar of Mark Geerlings

ASKER

My in-house source of Linux information was tied up on another issue for a while today, but he got back with me recently and helped to do a reboot from the install disk one, and choose "linux rescue".  That starts Linux from the CD so it doesn't mount any of the partitions on the hard drive.  Then we could use a resize utility to make /var smaller, then reboot from the hard drive.  This seems like a lot of work, and something I can't do on a production server.

So, I think the lesson here is that even though RedHat added a Logical Volume Manager to apparently make some file system and/or partition maintenance in Linux somewhat easier than before, I still should not assume that I can ever do an on-line resize of a Linux file system/partition.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You both confirmed that file systems (or partitions) in Linux can only be made larger, not smaller (at least not without major effort, and at least one reboot).  That's a key point that I was not aware of.  I heard about "Logical Volume Manager" and assumed that it would support growing and/or shrinking of volumes (or file systems or partitions).  But unless I'm willing to leave a chunk of the physical disk unpartitioned when setting up a new server, it looks like Logical Volume Manager doesn't do much for me.
It is not only limited by LVM, it also is by the file systems.
File systems used to static, later they were built growable (fairly easy).
But to shrink a filesystem you need to move all all files to a point below the size you want to keep. AFAICT only two OS's have a move file function to support defragmentation
Windows NT and OpenVMS. So for other systems it wall allway be a guess where a file lands
when copied & deleted.
Thank you, noci.  Those happen to be the only two OS's that I've had much experience with (DOS/Windows and VMS) so my frame of reference for what is "normal" in an OS is influenced by those two systems, not UNIX.  I realize that Linux is very much like UNIX, but since I don't know UNIX, that comparison doesn't help me.