-1

I have a server using Centos 7, and with the storage capacity allocated as such:

My free space and mounts

What I would like to do is take some of the space from the /dev/mapper/centos-home file system and give it to /dev/mapper/centos-root.

Now, I am aware I have to unmount the /home and remount it somehow at a smaller size. Then reallocate the free space. But, will this cause issues, as in being able to login and such?

I know you won't be able to unmount /home on el7 without turning off some services, like cups.

Also, if it is a XFS filesystem I know you cannot shrink it. So, how would I go about it for a XFS system?

As per Sven's request the command blkid /dev/mapper/centos-home returned nothing.

2 Answers2

1

Try to analyze, what takes such space using du command:

du -h --max-depth=1 /

If you realize that e.g. /var/log/apache is too large, you can stop apache, move /var/log/apache to /home/log/apache and create link:

ln -s /home/log/apache /var/log/apache

Then you can start apache.

0

You said the FS is XFS. In this case, you can't reduce it's size (this is an inherent limitation of XFS).

  • Make and test a backup. This is important!
  • If you can't unmount /home, boot into a rescue system, umount it otherwise.
  • Delete the logical volume for home
  • Create a new one with a smaller size
  • Create a new FS on it and mount it.
  • Extend the logical volume for /.
  • Grow the root filesystem, e.g. with xfs_growfs (XFS) or resize2fs (ext4).
Sven
  • 97,248
  • 13
  • 177
  • 225
  • can I backup to my local computer or say bitbucket ? – Vaishal Patel Aug 16 '18 at 12:58
  • The idea of a backup in this case is that the data is safe in case you do something wrong. Having a backup in your local system will be counterproductive for this use case. – Sven Aug 16 '18 at 13:32
  • Sven my root won't be able to possibly have backup saved on there, not enough space – Vaishal Patel Aug 16 '18 at 14:21
  • 1
    A backup on the machine is useless anyway, as anything that goes wrong with your machine goes also wrong with the backup. If your data is at all important, you *need* an external backup, not only for this file system modification. – Sven Aug 16 '18 at 14:23
  • Indeed. Also, Sven if I bought a new SSD am I able to transfer the data from old smaller drive to the new one? – Vaishal Patel Aug 16 '18 at 14:28
  • 1
    Sven's answer assumes you have no additional disks and you need to use backup restore. (You need a backup of anything important anyway.) Certainly if you had another disk you could move things there. It is possible to `vgextend`, `pvmove`, and `vgsplit` and end up with multiple VGs. – John Mahowald Aug 18 '18 at 12:04
  • @JohnMahowald: I would never do something like this with an "backup" that is mounted live to the system. Too many ways to shoot yourself in the knee when touching partitions, file systems and the like. – Sven Aug 18 '18 at 12:13
  • I meant proper offline backup, so that any mistake would not lose data. As of now, the answer destroys the home LV, so that first step of backing it up is important if that data is valuable. – John Mahowald Aug 18 '18 at 12:23
  • @Ah, sorry, I didn't get the full intent of your post. You are right of course. – Sven Aug 18 '18 at 12:25
  • What would be the best way to create a proper offline backup? – Vaishal Patel Aug 29 '18 at 12:44