We have a RHEL 7 server with 2 disks (sda and sdb). Our /, /var/log and swap are on sda, /var is on sdb. We use LVM and XFS.sda is too big (160 GB) and we would like to shrink it to 40 GB. We can then use the free 120 GB to extend sdb.[root@foo ~]# pvs  PV         VG        Fmt  Attr PSize   PFree  /dev/sda2  rhel      lvm2 a--  134.77g 9.77g  /dev/sdb1  vg_var    lvm2 a--  200.00g    0[root@foo ~]# lvs  LV        VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert  root      rhel      -wi-ao---- 117.19g  swap      rhel      -wi-ao----   3.91g  var_log   rhel      -wi-ao----   3.91g  lv_var    vg_var    -wi-ao---- 200.00g[root@foo ~]# fdisk -lDisk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk label type: dosDisk identifier: 0x3235298e   Device Boot      Start         End      Blocks   Id  System/dev/sdb1            2048   419430399   209714176   8e  Linux LVMDisk /dev/sda: 161.1 GB, 161061273600 bytes, 314572800 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk label type: dosDisk identifier: 0x0009b153   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048     1026047      512000   83  Linux/dev/sda2         1026048   283656191   141315072   8e  Linux LVMDisk /dev/mapper/rhel-root: 125.8 GB, 125829120000 bytes, 245760000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk /dev/mapper/rhel-swap: 4194 MB, 4194304000 bytes, 8192000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk /dev/mapper/vg_var-lv_var: 214.7 GB, 214744170496 bytes, 419422208 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk /dev/mapper/rhel-var_log: 4194 MB, 4194304000 bytes, 8192000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesHow can we safely achieve this? I have tried this with a test machine, but it failed:Add a new diskCreate an LVM partition, pvcreate and add a new LV on it.Boot with rescue diskMount sda to /mnt/sysimage and mount the LV of the new disk to /mnt/sdbcp -ax /mnt/sysimage/* /mnt/sdbUpdate /mnt/sysimage/etc/fstab to use /dev/mapper/rhel-lv_rootFinally the reboot fails due to INT18 boot failure
How to shrink a XFS filesystem?
rhel;lvm;disk