Operating System - Linux
1752747 Members
4653 Online
108789 Solutions
New Discussion юеВ

Re: How to shrink filesystem in Red Hat Linux

 
Danesh Qureshi
Regular Advisor

How to shrink filesystem in Red Hat Linux

I have a virtual machine running Red Hat Linux 5.4.

I want to shrink the /(root) filesystem.
Can someone explain I to shrink a filesystem on a virtual machine?

3 REPLIES 3
Alzhy
Honored Contributor

Re: How to shrink filesystem in Red Hat Linux

Matti_Kurkela
Honored Contributor

Re: How to shrink filesystem in Red Hat Linux

You make an image of your preferred Linux Live CD, and boot your virtual machine using that. Then use the tools available on the Live CD to shrink the filesystem.

*On-line* shrinking of a filesystem (type ext2 or ext3) is not possible on RHEL 5.x.

If the filesystem is offline (not mounted), then you can use resize2fs to reduce it. But a root filesystem cannot be unmounted while the system is running, so you must boot from some alternative boot media to shrink the filesystem.

After the filesystem has been shrunk, the next step will be to shrink the LV or partition the filesystem is located in.

*Be very careful! Do not shrink the LV/partition any more than you've actually shrunk the filesystem!*

If you're using LVM, this step is easy to do with the "lvreduce" command, and can be done while the RHEL 5 OS is running, assuming that the filesystem shrinking step was correctly performed.

But if you're using traditional partitions, you need to use fdisk or similar partition table editor. This may be easiest to do while using the alternate boot media: if you resize the root partition of the OS you're currently running, a reboot (or the "partprobe" command) may be required to make the system see the updated partition table.

MK
MK
Alzhy
Honored Contributor

Re: How to shrink filesystem in Red Hat Linux

Oops - did not read post thorughly.

I guess you can try booting in rescue mode and od the resize from there.


OR:


www.mondorescue.org


Use mondorescue to backup OS and Restore rsizing your partitions.

Hakuna Matata.