Link to home
Start Free TrialLog in
Avatar of Chris Kenward
Chris KenwardFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to swap or extend CentOS partition

Hi Folks

I have created a 500Gb server which I'm intending to use as a mail server. I have suddenly realised that the unit has defaulted to a 50Gb "/" partition or volume and a 480Gb "/home" partition or volume (sorry not sure on the terminology).

I began rsyncing the data from my original mail server (Zimbra) and after a couple of Gb had been transferred I realised that it was all being copied to the "/" partition which at 50Gb is WAY too small.

Is there a way to tell the server to reverse the partitions or actually delete the "/home" volume and only have the one volume, i.e. the "/' volume?

Or is the only way around this issue to destroy the whole thing and rebuild from scratch?

Many thanks in anticipation of some help with this.
Avatar of Scott Silva
Scott Silva
Flag of United States of America image

You should be able to find a partition resizing utility on CD and boot from it... Then you can shrink the /home partition, move it to the end of the drive, and enlarge the root...
copy /home/* to a new temporary directory

unmount /home

mount /opt on the same partition that was formerly /home

rename temp directory to /home

Finally modify /etc/fstab so that /opt mounts to the 480Gb partition.

You can now rebuild your zimbra server.
IF you can unmount /home on a running system... Sometimes you can't...
Avatar of Chris Kenward


Hi Scott and Sanga

Thanks for your quick response - wow - that was fast. Couple of things:

Although I'm pretty much OK at a lot of the admin tasks I need to do on the server(s) I run, there are limits to my ability.
The server is a VPS running on VMware Esxi and I do everything via ssh using terminal on a Mac so running a CD utility is a problem for me I think.
I'm not sure how to unmount a drive and don't know whether this is possible while the CentOS unit is running?
Not sure where the "/opt" came from in Sanga's reply.

All the best
I have access to the Gnome GUI because I haven't disabled it yet. This means I can access the Disk Utility. I tried unmounting the "/" but it said cannot because it's busy. I tried and succeeded in unmounting the "/home" partition....

Does this help?

All the best
Provided /home is on a different partition, you can ssh login as root and unmount it to perform maintenance tasks. The way I accomplish this is by using an X11 capable ssh client.

On the centos Server, enable sshd X11 forwarding. This will allow you to open graphical utilities like gparted that will make life a lot simpler.

yum install gparted
yum install xauth  dejavu-lgc-sans-fonts

enable X11 forwarding in the /etc/ssh/sshd_config file:

# grep X11 /etc/ssh/sshd_config
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

Finally in an ssh client such as MobaXterm

ssh -X -Y root@ipaddress

once logged in, you can run gparted from the command line and the gui will open giving you access to drive and partition management tools like unmount and resize.

You can attempt to resize the home partition, but i do not think you will be able to resize the root partition.

/opt partition:
Since this is a zimbra server and the default install directory is /opt/zimbra I always make /opt a mount point on a seperate partition or drive. This way if the zimbra mail store outgrows the partition, your entire server does not come to a halt due to no space on root.
The best setup i have found for /opt is a logical volume. Reason being when full you can just add another partition or drive to your virtual machine and then combine that new space with the existing logical volume allowing you to grow your server.
This can all be done while the server is live and users would never know.

User generated image
Avatar of Sanga Collins
Sanga Collins
Flag of United States of America image

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

Sadly this didn't work for me - perhaps I typed something wrong... I ended up with the /opt partition but the zimbra folder is gone. No matter - I'll rebuild the server from scratch. It's probably what I should have done in the first place.

Thanks both for your suggestions. Much appreciate the time you've spent on this for me.

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

Thanks again - although we didn't resolve it I really do appreciate your help with this.

I've blown the unit away and am now in the process of rebuilding. All the best to you.

So appreciate the input from the experts!