Need help with resizing root filesystem

General support questions
Post Reply
sravi123
Posts: 2
Joined: 2017/05/26 08:30:47

Need help with resizing root filesystem

Post by sravi123 » 2017/05/26 09:33:21

Hello,

I am new here. We have a Centos 6.4 installation, on a 2 TB disk. The root partition is 50 GB, and the other partition is 1.95 TB. We have an application freeswitch that resides in /usr/local/ which is in the root partition. Because we have files written on a regular basis, we run over the 50GB limit on regular basis. The /usr/local/freeswitch folder resides in the root partition.

Can I extend the size of the root partition ?

or, how do I go about using the other partition.

fdisk -lu /dev/sd[a-z]
[root@bfree-server ravi]# fdisk -lu /dev/sd[a-z]

Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0006af3f

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 1026048 3907028991 1953001472 8e Linux LVM
pvs
[root@bfree-server ravi]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_bfreeserver lvm2 a-- 1.82t 0
lvs
[root@bfree-server ravi]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
lv_home vg_bfreeserver -wi-ao--- 1.76t
lv_root vg_bfreeserver -wi-ao--- 50.00g
lv_swap vg_bfreeserver -wi-ao--- 7.64g
vgs
[root@bfree-server ravi]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_bfreeserver 1 3 0 wz--n- 1.82t 0
to avoid over running the space on root partition, we either have to extend the root partition or be able to write the files on the other home partition. Any help is appreciated.

Thanks.
Ravi

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Need help with resizing root filesystem

Post by TrevorH » 2017/05/26 10:22:17

First of all you really really need to yum update on that system and get off 6.4. That release came out in early 2013 so you are more than 4 years behind on security fixes and maintenance. It's not safe to run 6.4 anywhere. CentOS 6.9 is the current minor version in the 6.x range and is just a yum update away.

What filesystem is in use on both your lv_root and lv_home filesystems? If it's ext3 or 4 then you can shrink /home though it will need to be unmounted before you can do so. That may need to be done in single user mode though I have been able to do so in the past without that if I am the only user on the system and cd /tmp (or anywhere except /home) before using sudo to become root.

You want to use something like lvresize -r -LyyG /dev/vg_bfreeserver/lv_home after umounting /home to resize it to yyGB (for some value of yy that is larger than the amount of space currently used on /home). That will shrink your /home filesystem to yyGB then resize the LV that it resides on to yyGB as well. After that you will have freespace in the VG that you can use for other purposes. Don't forget it has to be not mounted to shrink it though.

You can then either lvresize your lv_root LV using the same command - if you use -L+32G it will add 32GB to the current size or you can specify an exact amount if you prefer - or you could also create a new LV completely, make a filesystem on it using mkfs and then recursively copy your entire /usr/local directory onto the new filesystem and mount it on /usr/local thus giving freeswitch its own filesystem to play with. You can resize the root filesystem and make the LV larger with lvresize while it is still mounted - it's only shrinking that requires it to be unmounted.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

sravi123
Posts: 2
Joined: 2017/05/26 08:30:47

Re: Need help with resizing root filesystem

Post by sravi123 » 2017/05/26 10:50:20

Thanks TrevorH.

I will update the OS to 6.9, shortly.

I also checked the file system type.
It is ext4.

Thanks again.

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: Need help with resizing root filesystem

Post by MartinR » 2017/05/26 13:59:26

One other option to consider is linking either /usr/local or /usr/local/freeswitch to a directory on /home:

Code: Select all

# mv /opt/local/freeswitch /home/freeswitch
# ln -s /home/freeswitch  /opt/local/freeswitch
(assuming that /home/freeswitch doesn't already exist).

You may run into SELinux problems though, if so come back here and ask the experts (ie not me).

Post Reply