0

from the lsblk I have the following output

NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0                2:0    1    4K  0 disk 
sda                8:0    0  300G  0 disk 
├─sda1             8:1    0  500M  0 part /boot
└─sda2             8:2    0 99.5G  0 part 
  ├─vgd-lv_root 253:0    0   50G  0 lvm  /
  ├─vgd-lv_swap 253:1    0 15.6G  0 lvm  [SWAP]
  ├─vgd-lv_var  253:2    0   30G  0 lvm  /var
  └─vgd-zero    253:3    0  3.9G  0 lvm  
sr0               11:0    1 1024M  0 rom  

we want to increase the /var , but Pfree is 0

  PV         VG   Fmt  Attr PSize  PFree
  /dev/sda2  vgd lvm2 a--  99.51g    0 

is any option to increase the /var

because sda is 300G , and maybe we can take the space from sda?

1

Yes, you have 200 GiB of unallocated space in /dev/sda which you could use. There are two approaches you can use, depending on whether you need to keep the system online while this is happening.

  • Without needing to unmount anything or reboot, you can create a third partition in /dev/sda:

    1. create a partition using your favourite partitioning tool;
    2. create a PV on it: pvcreate /dev/sda3;
    3. add it to your volume group: vgextend vgd /dev/sda3.
  • Or with a reboot, extend /dev/sda2:

    1. using your favourite partitioning tool, either extend /dev/sda2 (if this is possible, e.g. with Parted), or delete /dev/sda2 and re-create it with exactly the same starting sector;
    2. reboot;
    3. resize the PV: pvresize /dev/sda2.

You’ll now have nearly 200 GiB available in your VG, and you’ll be able to extend your LV, e.g. using fsadm.

  • ok , but lets we we already did : pvcreate /dev/sda3 and vgextend vgd /dev/sda3 , what is the procedure to fallback ? – yael May 21 at 9:33
  • If no space is yet allocated from the /dev/sda3 LVM PV, just vgreduce vgd /dev/sda3, then either pvremove /dev/sda3 or just overwrite/delete the sda3 partition with whatever you want. If you've already used some of the new space (i.e. in the pvs output, PSize and PFree are no longer equal for sda3), then you'll need to either use pvmove to move the allocations somewhere else, or undo what you did to use the space so that sda3 PV is again fully free before removing it from the VG. – telcoM May 21 at 9:54
  • Why would you want to fall back if you’ve already added /dev/sda3? That’s what I describe in the first approach... – Stephen Kitt May 21 at 11:12
  • when we do pvresize /dev/sda2 , we get Physical volume "/dev/sda2" changed 1 physical volume(s) resized / 0 physical volume(s) not resized – yael May 22 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.