1

I have a production server in which I need to move space from /data (3.7 T) to /home (50G) using lvm, I need to move around 200G of space. The solution I'm thinking of is reducing the size of /data and then take the freed space and extend /home with it.

Adding a disk is not an option as I have an abundance of space on /data (3.7 T and only 1% of it used as shown in the df command below)

I have one volume group and one pv with no free space:

pvs:

PV         VG   Fmt  Attr PSize PFree
  /dev/sda4  rhel lvm2 a--  3.64t 4.00m

vgs:

 VG   #PV #LV #SN Attr   VSize VFree
 rhel   1  10   0 wz--n- 3.64t 4.00m

lvs output:

 LV            VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  data          rhel -wi-ao----   2.98t
  home          rhel -wi-ao----  50.00g
  opt           rhel -wi-ao----  30.00g
  root          rhel -wi-ao----  50.00g
  swap          rhel -wi-ao----  30.00g
  tmp           rhel -wi-ao---- 200.00g
  usr           rhel -wi-ao---- 100.00g
  var           rhel -wi-ao---- 200.00g
  var_log       rhel -wi-ao----  10.00g
  var_log_audit rhel -wi-ao----   5.00g

output of df -khT:

/dev/mapper/rhel-usr           ext4       99G  8.7G   85G  10% /usr
/dev/sda2                      ext4      976M  101M  808M  12% /boot
/dev/sda3                      vfat      512M     0  512M   0% /boot/efi
/dev/mapper/rhel-home          ext4       50G   41G  5.7G  88% /home
/dev/mapper/rhel-opt           ext4       30G   11G   18G  39% /opt
/dev/mapper/rhel-tmp           ext4      197G  4.2G  183G   3% /tmp
/dev/mapper/rhel-data          ext4      3.0T   26G  2.8T   1% /data
/dev/sdb1                      ext4      3.6T   79G  3.4T   3% /data/disk01
/dev/sdc1                      ext4      3.6T  758M  3.4T   1% /data/disk02

The output of lsblk shows that /home and /data are both under the same partition sda4, although I don't exactly know how to do this. It seems that it's convenient that both /home and /data are under the same partition:

lsblk:
NAME                   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                      8:0    0  3.7T  0 disk
├─sda1                   8:1    0    1M  0 part
├─sda2                   8:2    0    1G  0 part /boot
├─sda3                   8:3    0  512M  0 part /boot/efi
└─sda4                   8:4    0  3.7T  0 part
  ├─rhel-root          253:0    0   50G  0 lvm  /
  ├─rhel-swap          253:1    0   30G  0 lvm  [SWAP]
  ├─rhel-usr           253:2    0  100G  0 lvm  /usr
  ├─rhel-tmp           253:3    0  200G  0 lvm  /tmp
  ├─rhel-home          253:4    0   50G  0 lvm  /home
  ├─rhel-var           253:5    0  200G  0 lvm  /var
  ├─rhel-var_log_audit 253:6    0    5G  0 lvm  /var/log/audit
  ├─rhel-var_log       253:7    0   10G  0 lvm  /var/log
  ├─rhel-opt           253:8    0   30G  0 lvm  /opt
  └─rhel-data          253:9    0    3T  0 lvm  /data

I need to do this without the loss of any data and preferably without restarting the server.

If this is possible please recommend a solution, if not please explain why.

1 Answer 1

1

ext4 doesn't support on-line shrinking, you have to unmount the filesystem before to unmount it but the operating system can remain up. ext4 and LVM logical volume online resize(increasing the size) instead is supported. I'm reading that you have a RHEL, so you should have access to Red Hat knowledge base Red Hat. This solution https://access.redhat.com/solutions/32530 describe the procedure to shrink a LVM logical volume with ext4 filesystem on it.

3
  • No I don't have access to red hat knowledge base as I am not working directly for the company that owns this server, if it's possible to include the procedure it will be appreciated. May 21, 2019 at 11:00
  • 3
    Giving an answer on serverfault that points to documentation only available to the happy few isn't useful.
    – wurtel
    May 21, 2019 at 11:05
  • RHEL server should be used only having a valid subscription for it. If you have a valid subscription, you have access to the RH Knowledge base and the link reported aboce
    – NoNoNo
    May 21, 2019 at 11:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .