0

My /var lvm space is full. I have 500 GB space in /dev/sdb filesystem which is already mounted to /mnt/data point and it has data in it. I want to move some space from /dev/sdb to /var lvm without destroying already present data in /mnt/data. Please guide.

lsblk Screenshot

df -h screenshot

2
  • Please use copy and paste to post the text. Pictures of text are not a substitute.
    – AlexP
    Commented Oct 22, 2019 at 8:52
  • You should park the data currently on /mnt/data somewhere, add /dev/sdb to the volume group used by teh /var lvm, and then increase the size of /var. You can also allocate a separate logical volume for the /mnt/data stuff.
    – wurtel
    Commented Oct 22, 2019 at 9:00

1 Answer 1

0

You can use blocks to convert /dev/sdb into an LVM physical volume, with the data filesystem placed into an LVM logical volume. Once the data filesystem is in an LVM logical volume, you'd be able to shrink it and then allocate the freed space to /var if the /var logical volume does not use contiguous allocation.

Warning: With disk operations such as this, data integrity is never guaranteed. Although the data should not be destroyed by following this procedure, I highly recommend having a backup before proceeding. You just never know what might happen.

  1. Un-mount the data filesystem: umount /mnt/data.
  2. Convert the data partition to an LVM physical volume: blocks to-lvm --join=VOLGROUP /dev/sdb
  3. Run lvs to get the name of the new LV.
  4. Edit /etc/fstab so that /mnt/data is mounted from the new LV.
  5. Shrink the new data LV (using 20GB as an example): lvresize -r -L -20G /dev/VOLGROUP/NAME_OF_NEW_LV
  6. Grow the var LV: lvresize -r -L +20G /dev/VOLGROUP/var
  7. Mount the data filesystem: mount /mnt/data

You must log in to answer this question.

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