Loading...
Basic Linux

LVM

Process to add lvm space in vmware

First need to create a new partition and then covert new partition in to lvm partition,After that add that partion in to volume group from volume group add that space to logical volume,Next know what type of ile system it is as xfs format or ext4 format.

 fdisk -l 

Output

Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 sectors
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 104857599 51915776 8e Linux LVM
 fdisk /dev/sda 
Welcome to fdisk (util-linux 2.23.2)
Changes will remain in memory only, until you decide to write them.Be careful before using the write command.
Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): 
Using default response p
Partition number (3,4, default 3): 
First sector (104857600-167772159, default 104857600): 
Using default value 104857600
Last sector, +sectors or +size{K,M,G} (104857600-167772159, default 167772159): 
Using default value 167772159
Partition 3 of type Linux and of size 30 GiB is set
Command (m for help): w
The partition table has been altered!
 [root@localhost ~]# fdisk -l 

Output

Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000639da
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   104857599    51915776   8e  Linux LVM
/dev/sda3       104857600   167772159    31457280   83  Linux
[root@localhost ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w 

The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@localhost ~]# partprobe 

Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.

[root@localhost ~]# vgs  (To know volume group path)

Output

  VG     #PV #LV #SN Attr   VSize   VFree 
  centos   1   2   0 wz--n- <49.51g 44.00m
[root@localhost ~]# vgextend centos /dev/sda3
[root@localhost ~]# df -kh (to know logical volume partion)
[root@localhost ~]# lvextend -L +30G /dev/mapper/centos-root
To check file system use below command
[root@localhost ~]# blkid
[root@localhost ~]# xfs_growfs /dev/mapper/centos-root

To make the partition for permanent even after reboot add partition details in to /etc/fstab.

To Extend ext4 file system follow below steps :

[root@localhost ~]# vgextend centos /dev/sda3
[root@localhost ~]# df -kh (to know logical volume partion)
[root@localhost ~]# lvextend -L +30G /dev/mapper/centos-root
TO check file system use below command
[root@localhost ~]# blkid
[root@localhost ~]# resize2fs /dev/mapper/centos-root

Leave a Reply

Your email address will not be published. Required fields are marked *