The scope of this article is to extend the ‘/var’ on my LVM.
* You have already extended the harddisk in ESXi
fdisk -l fdisk /dev/sda
In fdisk perform the following
p (to show the partition information) Command (m for help): p Disk /dev/sda: 36.7 GB, 36679188480 bytes 255 heads, 63 sectors/track, 4459 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000f1113 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 1849 14334976 8e Linux LVM
Leave the the fdisk utility and start vgdisplay
[root@locke ~]# vgdisplay --- Volume group --- VG Name vg_locke System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 6 VG Access read/write VG Status resizable MAX LV 0 Cur LV 5 Open LV 5 Max PV 0 Cur PV 1 Act PV 1 VG Size 13.66 GiB PE Size 32.00 MiB Total PE 437 Alloc PE / Size 437 / 13.66 GiB Free PE / Size 0 / 0 VG UUID EryR1g-t5lD-ZVnE-lZcB-cb0z-3vig-5UWUS8
Watch the Free PE / Size. It is zero now. So no room to extend. However we will now add an extra disk.
fdisk /dev/sda n (new partition) p (primary table) Select partition: 3 --> follow the suggested steps. t (change label) 8e (Linux LVM) w (write to table and exit)
Now create a physical volume
[root@locke ~]# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created [root@locke ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name vg_locke PV Size 13.67 GiB / not usable 15.00 MiB Allocatable yes (but full) PE Size 32.00 MiB Total PE 437 Free PE 0 Allocated PE 437 PV UUID GAJzPC-8XLV-z7xD-GzU7-ss7u-IIVb-bHcpBR "/dev/sda3" is a new physical volume of "20.00 GiB" --- NEW Physical volume --- PV Name /dev/sda3 VG Name PV Size 20.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID 0SMW7L-1JyG-04Zx-UIlx-XUzf-i2Qw-2yGhIv [root@locke ~]# vgdisplay --- Volume group --- VG Name vg_locke System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 6 VG Access read/write VG Status resizable MAX LV 0 Cur LV 5 Open LV 5 Max PV 0 Cur PV 1 Act PV 1 VG Size 13.66 GiB PE Size 32.00 MiB Total PE 437 Alloc PE / Size 437 / 13.66 GiB Free PE / Size 0 / 0 VG UUID EryR1g-t5lD-ZVnE-lZcB-cb0z-3vig-5UWUS8
Extend the volumegroup “vg_locke” with the new physical volume /dev/sda3:
[root@locke ~]# vgextend vg_locke /dev/sda3 Volume group "vg_locke" successfully extended [root@locke ~]# vgdisplay --- Volume group --- VG Name vg_locke System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 5 Open LV 5 Max PV 0 Cur PV 2 Act PV 2 VG Size 33.62 GiB PE Size 32.00 MiB Total PE 1076 Alloc PE / Size 437 / 13.66 GiB Free PE / Size 639 / 19.97 GiB VG UUID EryR1g-t5lD-ZVnE-lZcB-cb0z-3vig-5UWUS8
In the next step we will extend VAR with the free amount of PE:
[root@locke ~]# lvextend -l 639 /dev/mapper/vg_locke-var Extending logical volume var to 19.97 GiB Logical volume var successfully resized [root@locke ~]# vgdisplay --- Volume group --- VG Name vg_locke System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 8 VG Access read/write VG Status resizable MAX LV 0 Cur LV 5 Open LV 5 Max PV 0 Cur PV 2 Act PV 2 VG Size 33.62 GiB PE Size 32.00 MiB Total PE 1076 Alloc PE / Size 919 / 28.72 GiB Free PE / Size 157 / 4.91 GiB VG UUID EryR1g-t5lD-ZVnE-lZcB-cb0z-3vig-5UWUS8
Final check to see if everything succeeded. It seems so. However the extra space cannot be used yet. A resize has to performed in order to be able to make use of the new space.
[root@locke ~]# fdisk -l Disk /dev/sda: 36.7 GB, 36679188480 bytes 255 heads, 63 sectors/track, 4459 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000f1113 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 1849 14334976 8e Linux LVM /dev/sda3 1849 4459 20968917+ 8e Linux LVM Disk /dev/mapper/vg_locke-swap: 939 MB, 939524096 bytes 255 heads, 63 sectors/track, 114 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_locke-root: 5268 MB, 5268045824 bytes 255 heads, 63 sectors/track, 640 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_locke-opt: 2113 MB, 2113929216 bytes 255 heads, 63 sectors/track, 257 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_locke-temp: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_locke-var: 21.4 GB, 21441282048 bytes 255 heads, 63 sectors/track, 2606 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
Perform the following command:
resize2fs /dev/mapper/vg_locke-var
The volume will extend now and the space is useable on VAR:
[root@locke ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_locke-root 4.9G 2.3G 2.4G 49% / tmpfs 499M 0 499M 0% /dev/shm /dev/sda1 485M 57M 403M 13% /boot /dev/mapper/vg_locke-opt 2.0G 35M 1.9G 2% /opt /dev/mapper/vg_locke-temp 1008M 34M 924M 4% /tmp /dev/mapper/vg_locke-var 20G 4.6G 15G 25% /var