1

I have a RHEL 7.9 virtual machine without GUI, and I would like to make updates via the yum update command but it tells me that the disk is full, especially on the /var folder. I thought I'd take 10GB/20GB from the /home partition and transfer it to /var. It's possible ? If so, what steps should I take so as not to damage the machine?

enter image description here

I have seen this post but it seems to me the ideal solution: Change size of /home partition and move /var/www on new partition

dr_
  • 28,763
  • 21
  • 89
  • 133
Kanuc
  • 31
  • 6
  • 1
    FYI, it helps if you [don't post images of text](https://unix.meta.stackexchange.com/questions/4086/psa-please-dont-post-images-of-text). – doneal24 Sep 23 '22 at 15:28

2 Answers2

1

You have a RHEL 7 VM. Default filesystem in RHEL 7 is XFS, which doesn't support shrinking so you can't reduce the size of /home. Therefore your only possibility is to ask the sysadmin to add a new virtual disk, or increase the size of the existing virtual disk, and then use the appropriate LVM commands.

So the steps are:

  1. Add a new virtual disk to the machine (let's assume is /dev/sdx)
  2. Initialize the Physical Volume: pvcreate /dev/sdx
  3. Add the Physical Volume to the existing Volume Group: vgextend rootvg /dev/sdx

or

  1. Increase the size of the existing virtual disk (let's assume is /dev/sda)
  2. Notify the kernel of the new disk size: partprobe
  3. Accommodate the Physical Volume to the new size: pvresize /dev/sda

Then,

  1. increase the /var Logical Volume: lvresize -r -l+100%FREE /dev/mapper/rootvg-varlv
dr_
  • 28,763
  • 21
  • 89
  • 133
  • thanks you! I'll try to talk to the system administrator and I will also test these steps. – Kanuc Sep 29 '22 at 10:28
-2

I thought I'd take 10GB/20GB from the /home partition and transfer it to /var. It's possible ?

No, it is not. First of all, what you have are not partitions. Those are shares on the server which are defined by the server's admin. To change sizes of these volumes you must talk with your sysadmin.

I have seen this post but it seems to me the ideal solution

Yes you can make symbolic links from one mounted volume to another mounted volume, effectively moving folders. And if the application which uses these folders opens them by regular means - it would work.
Unfortunately, it is not always a case and sometimes the application requires a real folder, or at least a hard link (which does not work across volumes).
And anyway, you have to be very careful what are symlinking in the tree. It is very easy to ruin everything.

So I really discourage you to do this task yourself. Talk with system administrator who made the virtual machine for you.

White Owl
  • 4,511
  • 1
  • 4
  • 15
  • Hi @WhiteOwl , I will follow your advice, thank you very much! One question: how did you understand that they are not partitions? From **/dev/mapper** ? – Kanuc Sep 23 '22 at 13:45
  • 2
    I'm not sure exactly what you mean by calling these shares. These mount points are logical volumes. Each LV does not correspond to a disk partition but the VG containing them is mapped to one of more physical disk partitions. If `/dev/mapper/rootvg` is not completely allocated then `/var` can be resized using `lvextend`. – doneal24 Sep 23 '22 at 14:04
  • @Kanuc From two points: 1. You said, you are using virtual machine. 2. There are both `/dev/sda1` and `/dev/mapper` in your list of mounts, and their combination.
    The easiest and most logical way to make a VM on organization level is to create a sharable drive a
    – White Owl Sep 23 '22 at 16:03
  • ... create a sharable drive (/opt or /usr/bin are good examples), and share that drive as logical volume to all individual users. MUCH easier to maintain and backup/restore if necessary. As a side effect - user can login remotely to the exact same VM as he does in office. Again - much easier to maintain. Logical drive over local physical - possible, but too much hustle for the admin and not much advantage for user - so it could be done, but... – White Owl Sep 23 '22 at 16:11
  • @WhiteOwl , thank you very much! I'll try to talk to the system administrator of this virtual machine. – Kanuc Sep 29 '22 at 10:26