Page 1 of 2

resizing /root

Posted: 2021/02/18 02:49:02
by Zosso
Good morning all

The / root (system) partition is almost full and it is possible to modify this partition, if so could you help me.

and the swap is much too big how to decrease it

thank you



screen.png
screen.png (27.47 KiB) Viewed 624 times
screen01.png
screen01.png (21.22 KiB) Viewed 624 times
screen02.png
screen02.png (16.49 KiB) Viewed 618 times

Re: resizing /root

Posted: 2021/02/18 07:26:13
by jlehtone
Show output of lsblk
(Note that copy-pasting text is in many ways better than posting binary blob pictures.)

Re: resizing /root

Posted: 2021/02/18 13:20:05
by Zosso
Thanks jlehtone
[zosso@localhost ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465,8G 0 disk
└─sda1 8:1 0 465,8G 0 part /run/media/zosso/Mini_Externe
sdb 8:16 0 445,2G 0 disk /run/timeshift/backup
sdc 8:32 0 1,8T 0 disk
├─sdc1 8:33 0 1G 0 part /boot
└─sdc2 8:34 0 1,8T 0 part
├─centos-root
253:0 0 50G 0 lvm /
├─centos-swap
253:1 0 31,5G 0 lvm [SWAP]
└─centos-home
253:2 0 1,8T 0 lvm /home
sr0 11:0 1 1024M 0 rom
loop0 7:0 0 140K 1 loop /var/lib/snapd/snap/gtk2-common-themes/13
loop1 7:1 0 23,7M 1 loop /var/lib/snapd/snap/bashtop/199
loop2 7:2 0 230,6M 1 loop /var/lib/snapd/snap/obs-studio/1195

Re: resizing /root

Posted: 2021/02/18 13:26:27
by TrevorH
Post the output from

pvs
vgs
lvs

All run as root.

Re: resizing /root

Posted: 2021/02/18 13:32:12
by Zosso
Thank you and voila
[zosso@localhost etc]$ sudo pvs
[sudo] Mot de passe de zosso : 
PV VG Fmt Attr PSize PFree
/dev/sdc2 centos lvm2 a-- <1,82t 4,00m
[zosso@localhost etc]$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 3 0 wz--n- <1,82t 4,00m
[zosso@localhost etc]$ sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- <1,74t
root centos -wi-ao---- 50,00g
swap centos -wi-ao---- 31,50g

Re: resizing /root

Posted: 2021/02/18 13:46:22
by TrevorH
So you have 1.8TB on the system and your /home is using 1.74TB of that. Since /home is an xfs filesystem you cannot shrink it so you will need to back up all its contents elsewhere if you need to shrink it to reclaim some of its space.

You do have a ~32GB swap LV and you are right that this is probably too large unless you're running an Oracle db. You could use swapoff to remove it from use, lvremove that LV, lvcreate it with the same name but smaller then run mkswap on the new LV and finally run swapon -a to activate it. That last command will error if you got it wrong but it's better to see the error while you are still booted up than to discover it during the next reboot - mount -a will tell you if it fails and that would be a failure you'd see during the next boot and it would enter emergency mode. If some portion of 32GB is enough for your future space requirements then you can probably just get away with that.

If you need to reduce the size of /home then you will need to use fuser -m /home to get a list of the processes using it and then stop those processes to allow you to umount /home. Back it up somewhere safe if it has valuable data on it. Then you can either lvresize it smaller or lvremove/lvcreate it smaller. All of those will destroy the filesystem and all its data and then you can resize the LV, mkfs on it, restore your data and again use mount -a to remount it and test if everything is correct. If /home is in /etc/fstab and listed by UUID or LABEL then mkfs will change those and you will need to amend fstab for the new values. Using mount -a will tell you that it can't find the filesystem until you do that.

Re: resizing /root

Posted: 2021/02/18 13:57:00
by jlehtone
Another approach is to figure out what uses space from centos-root (/).
If the culprit is data of service, like database or website, then it should be possible
to move such subdirectory to centos-home.

For example, /var/lib/mysrv is big. I'd move it to /home/mysrv and bind-mount it back to /var/lib/mysrv.
That way the service, when restarted, would not notice a difference nor need reconfig.

Re: resizing /root

Posted: 2021/02/18 14:02:07
by Zosso
Thank TrevorH
So you have 1.8TB on the system and your /home is using 1.74TB of that. Since /home is an xfs filesystem you cannot shrink it so you will need to back up all its contents elsewhere if you need to shrink it to reclaim some of its space.
Done..
You do have a ~32GB swap LV and you are right that this is probably too large unless you're running an Oracle db. You could use swapoff to remove it from use, lvremove that LV, lvcreate it with the same name but smaller then run mkswap on the new LV and finally run swapon -a to activate it. That last command will error if you got it wrong but it's better to see the error while you are still booted up than to discover it during the next reboot - mount -a will tell you if it fails and that would be a failure you'd see during the next boot and it would enter emergency mode. If some portion of 32GB is enough for your future space requirements then you can probably just get away with that.
Yes 32GB would be perfect for my needs I don't have an Oracle db.

ok if I remove the 32GB from swap how do I resize my (root centos -wi-ao ---- 50.00g) and use its 32GB safely
thank you very much

fstab
/dev/mapper/centos-root / xfs defaults 0 0
UUID=5b7503a7-e9e5-40e8-9979-21e6db2b3498 /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
//192.168.0.161/windows-share /mnt cifs defaults,_netdev 0 0
UUID=e0f18946-4d5b-452b-9340-e19c50422006 /media/data ext4 defaults 0 0

Re: resizing /root

Posted: 2021/02/18 14:20:32
by TrevorH
So, off the top of my head with no real error checking...

swapoff -a
lvremove /dev/mapper/centos-swap
lvcreate -n swap -L2G centos
mkswap -v1 /dev/mapper/centos-swap
swapon -a
# removes, resizes, re-adds swap as 2G not 32G
lvresize -L+30G -r /dev/mapper/centos-root

Re: resizing /root

Posted: 2021/02/18 14:30:38
by Zosso
jlehtone wrote:
2021/02/18 13:57:00
Another approach is to figure out what uses space from centos-root (/).
If the culprit is data of service, like database or website, then it should be possible
to move such subdirectory to centos-home.

For example, /var/lib/mysrv is big. I'd move it to /home/mysrv and bind-mount it back to /var/lib/mysrv.
That way the service, when restarted, would not notice a difference nor need reconfig.
My problem is not so much (centos-root (/)) but rather the partition or folder (/ root) which is located at centos-root (/)

ex: root centos -wi-ao ---- 50.00g in this partition I can not exceed 50GB

I hope I explain myself well

thank you ;)