Thursday, July 19, 2018

Extend your logical volume



 // current scenario - get VG, LV and PV information
# vgs;pvs;lvs

// check the free disks available
# cat /proc/partitions

// So , sdc is available free , do a pvcreate
# pvcreate /dev/sdc
  Physical volume "/dev/sdc" successfully created.

// This should show
# lvmdiskscan -l
   /dev/sdc                                                                             [      10.00 GiB] LVM physical volume



// extend the vg which corresponds to the lv - so here rhel_dhcp43_130 is the VG

# vgextend rhel_dhcp43-130 /dev/sdc


// Now extend the lv - here rhel_dhcp43--130-root is the LV

# lvextend -l +100%FREE /dev/mapper/rhel_dhcp43--130-root
  Size of logical volume rhel_dhcp43-130/root changed from 7.00  GiB (1792 extents) to <17.00 GiB (4351 extents).
  Logical volume rhel_dhcp43-130/root successfully resized.


// Check the size  - hmm..size not changed yet :(

# df -h


// resize underlying filesystem

# xfs_growfs -d /

// hooray - size changed :)

# df -h


============================================

Another day. 


--

vgs
lvs

--
// This is make the end size of ubuntu-home 60G.
// earlier it is of larger size say for example 160G

# lvresize -r  -L 60G /dev/fedora_localhost-live/ubuntu-home  
fsck from util-linux 2.38.1
/dev/mapper/fedora_localhost--live-ubuntu--home: 315/10485760 files (2.5% non-contiguous), 939484/41943040 blocks
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mapper/fedora_localhost--live-ubuntu--home to 15728640 (4k) blocks.
The filesystem on /dev/mapper/fedora_localhost--live-ubuntu--home is now 15728640 (4k) blocks long.

  Size of logical volume fedora_localhost-live/ubuntu-home changed from 160.00 GiB (40960 extents) to 60.00 GiB (15360 extents).
  Logical volume fedora_localhost-live/ubuntu-home successfully resized.

--
// check change in lvs and vgs(check free here)
lvs;

vgs;
--

// whatever free we take in the ubuntu-root logical volume

# lvextend -l +100%FREE /dev/mapper/fedora_localhost--live-ubuntu--root  
  Size of logical volume fedora_localhost-live/ubuntu-root changed from 10.00 GiB (2560 extents) to <113.13 GiB (28961 extents).
  Logical volume fedora_localhost-live/ubuntu-root successfully resized.



// mandatory check after lvextend

e2fsck -f   /dev/mapper/fedora_localhost--live-ubuntu--root   
e2fsck 1.46.5 (30-Dec-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/fedora_localhost--live-ubuntu--root: 225489/655360 files (0.1% non-contiguous), 2431025/2621440 blocks
[root@fedora saran]#
[root@fedora saran]# resize2fs  /dev/mapper/fedora_localhost--live-ubuntu--root   

// mandatory for filesystem notification.

resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mapper/fedora_localhost--live-ubuntu--root to 29656064 (4k) blocks.
The filesystem on /dev/mapper/fedora_localhost--live-ubuntu--root is now 29656064 (4k) blocks long.

--
vgs
lvs
--
=========================================


No comments:

Post a Comment