- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Extend /var
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2009 12:04 AM
тАО10-11-2009 12:04 AM
No LVM;Red Hat 5. df -h shows that /var is around 100% (ext3). The / is almost empty. Is there anyway to shrink the / and extend the /var? Any lost of data would result?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2009 03:22 AM
тАО10-11-2009 03:22 AM
SolutionShrinking a filesystem is always somewhat risky, so a good backup is a must before beginning.
Because you don't have LVM, if you un-allocate disk space by shrinking the root filesystem and the partition it's located in, you can only use the space by creating a completely new partition or by destroying and re-creating the partition that is located immediately after the root filesystem on the disk.
(I don't know of a partition management program that could move the beginning of an ext2/ext3 filesystem. Resize an ext3 partition, yes. Move its beginning point on the disk, no.)
Knowing the physical layout of your partitions would be important in determining what can be done and how best to proceed. Please show us the output of "fdisk -l".
The re-organization will very likely be a major operation, so it would be reasonable to plan it very carefully first. An important thing to consider is: what is causing /var to be full? Could it cause a need for further expansion in the future?
If you need to backup and re-create partitions anyway, it might be worth your while to take the extra trouble of converting the system (or at least some partitions) to LVM layout at the same time.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2009 04:52 AM
тАО10-11-2009 04:52 AM
Re: Extend /var
- df -h
- du /var | sort -rn |head -30
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2009 05:03 AM
тАО10-11-2009 05:03 AM
Re: Extend /var
fdisk -l is showing:
/dev/sda2 /
/dev/sda3 /usr
/dev/sda5 /var
...
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2009 05:27 AM
тАО10-11-2009 05:27 AM
Re: Extend /var
DeviceBoot Start End Id System
/dev/sda1 1 25 83 Linux
/dev/sda2 26 2946 83 Linux
/dev/sda3 2947 5698 83 Linux
/dev/sda4 5699 8833 5 Extended
/dev/sda5 5699 7003 83 Linux
....
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2009 07:59 AM
тАО10-11-2009 07:59 AM
Re: Extend /var
You said you have "Red Hat 5".
Do you mean the current Red Hat _Enterprise_ Linux 5 or the ancient RedHat Linux 5.x (released back in 1997-1998 and thoroughly obsolete now)?
If it's the latter, back up your data and reinstall with a newer version. Seriously.
Your fdisk -l output is obviously missing a few lines at the beginning that would tell the total capacity of the disk.
Nevertheless, I can see two things:
1.) Your /usr is physically located between / and /var on your disk, so you would have to manipulate both /usr and /var to make use of any space you could gain by reducing /. That may complicate things, unless...
2.) Your partial fdisk -l output shows:
> /dev/sda4 5699 8833 5 Extended
> /dev/sda5 5699 7003 83 Linux
From this, I can see that cylinders 7004 - 8833 are within the extended partition but not part of /dev/sda5 (/var). The important question is, do you have /dev/sda6 (or any further partitions on this disk) or not?
If /dev/sda5 is the last partition on this disk, cyls 7004-8833 are currently unallocated. As they are located immediately after /var, adding them to /var would be very simple.
---------------
Procedure for extending /dev/sda5, assuming that it's the last allocated partition on the disk and has some unallocated space after it:
Take a backup first.
Start fdisk with "fdisk /dev/sda", delete partition /dev/sda5 and re-create it so that the starting cylinder stays the same (5699 in your case) but the ending cylinder value is larger. If there are no partitions beyond /dev/sda5, you can use the the last cylinder of the disk (8833) as the ending cylinder, which should in your case more than double the current capacity of your /var.
Remember that the fdisk only writes the new partition table to disk when you use the "w" command. If you think you may have made a mistake, just use the "q" command instead to exit without making any actual changes. Write to disk only after triple checking you've got it right.
When writing the changes to the disk, fdisk will detect that the disk still has mounted filesystems on it, and the changes will be effective only after a reboot. The fdisk command won't force you to reboot, but you cannot proceed with the expansion until you do it.
(If there are neither mounted filesystems nor active swap partitions on a disk, the kernel can detect the new partition layout immediately. But as /dev/sda2 contains your root filesystem, that is not possible in this case.)
After a reboot, the partition has been extended and the kernel is made aware of the new size, but the filesystem still reflects the old size.
In RHEL5, that is fixed with with a simple command: "resize2fs /dev/sda5". It will automatically detect that the filesystem is mounted and smaller than the partition it's in. It will perform an on-line extension, and then the expanded capacity of /var will be available for use.
-----------
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2009 09:48 AM
тАО10-11-2009 09:48 AM
Re: Extend /var
Thanks a lot for the information you provided so far.
Just to make things clearer:
The version is the new RHEL 5
I have /dev/sda6 which means from your previous reply that both /usr and /var have to be manipulated.
In this scenario, can you please shed more lights on how to shrink the / file system and proceed with /usr and /var.
thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2009 09:09 PM
тАО10-11-2009 09:09 PM
Re: Extend /var
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2009 06:21 AM
тАО10-12-2009 06:21 AM
Re: Extend /var
Good luck...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2009 10:04 PM
тАО10-13-2009 10:04 PM
Re: Extend /var
booting to single user mode, fdisk and change the partition size and after resize2fs. Is it right?
Thank you.