Expand Logical Volume
Important: The details provided below apply only when you need to increase the
hard disk space of your virtual machine for the hardware component that you want to upgrade with the
requirements mentioned in SevOne NMS Installation Guide - Virtual Appliance > section
Hardware Requirements.
If you have low storage space and need to increase the capacity of your virtual machine's partitions, the steps below will help extend the storage by using Logical Volume Manager (LVM).
Important: For documentation purposes, in the steps below, it is assumed the customer
domain is on VMware vSphere Client. Follow similar steps if your environment is on
OpenStack/KVM, AWS, Azure, etc.
Customer Domain
- Open your VMware vSphere Client.Note: Your pages may vary from the screenshots in the steps below.
- Search the virtual machine for the hardware component you want to upgrade. For example, vDNC100_RHEL.
- Right-click on the virtual machine and select Edit Settings.
Example
where,
- Hard disk 1 is your root partition (/) and is set to 50GB.
- Hard disk 2 is your data partition (/data) and is set to 1024GB.
You will see the current settings of your virtual machine.
SevOne Domain
- SSH into your SevOne NMS virtual machine and log in as
support.
ssh support@<virtual machine IP address or hostname>
Example
ssh support@10.168.117.98
- Execute the following commands in the order shown below.
- lsblk command reads the sysfs filesystem and udev db to gather
information.
lsblk Output: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 50G 0 disk ├─sda1 8:1 0 2M 0 part ├─sda2 8:2 0 500M 0 part /boot └─sda3 8:3 0 49.5G 0 part ├─cl-root 253:0 0 45.5G 0 lvm / └─cl-swap 253:1 0 4G 0 lvm [SWAP] sdb 8:16 0 1T 0 disk └─sdb1 8:17 0 1024G 0 part └─data_vg-data_lv 253:2 0 1024G 0 lvm /data sr0 11:0 1 1024M 0 rom
Important: You will see that sda3 is 49.5G. - View the existing partitions and storage
devices.
parted -l | head -12 Output: Model: VMware Virtual disk (scsi) Disk /dev/sda: 53.7GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 3146kB 2097kB primary 2 3146kB 527MB 524MB primary xfs boot 3 527MB 53.7GB 53.2GB primary lvm
Important: Disk /dev/sda currently has 53.7GB. - The pvs command provides physical volume information in a configurable form, displaying
one line per physical volume.
pvs Output: PV VG Fmt Attr PSize PFree /dev/sda3 cl lvm2 a-- <49.51g 0 /dev/sdb1 data_vg lvm2 a-- <1024.00g 0
- The pvdisplay allows you to see the attributes of one or more physical volumes like size,
physical extent size, space used for the volume group descriptor area and so on. In the command
below, physical volume is passed to obtain its. For example,
/dev/sda3.
pvdisplay /dev/sda3 Output: --- Physical volume --- PV Name /dev/sda3 VG Name cl PV Size <49.51 GiB / not usable 0 Allocatable yes (but full) PE Size 4.00 MiB Total PE 12674 Free PE 0 Allocated PE 12674 PV UUID tJa0zz-UQEc-nKHh-mvoo-RfM6-NMM9-fyeaZC
Important: Free PE is 0 for /dev/sda3. - Based on target version's hardware requirements mentioned in SevOne NMS Installation Guide -
Virtual Appliance, if you need to increase your hard disk based on the specifications, go to
your VMware vSphere Client > choose your virtual machine for example, vDNC100_RHEL and
its IP address. Right-click on the virtual machine and select Edit Settings. Increase your
Hard disk 1 from 50GB to 150GB and click OK in the lower-right
corner.Important: Hard disk 1 change from 50GB to 150GB will only take effect after the logical volume is extended by executing the lvextend command as shown below.
- The vgs command provides volume group information in a configurable form, displaying one
line per volume group.
vgs Output: VG #PV #LV #SN Attr VSize VFree cl 1 2 0 wz--n- <49.51g 0 data_vg 1 1 0 wz--n- <1024.00g 0
- The vgdisplay commanddisplays volume group properties (such as size, extents, number of
physical volumes, etc.) in a fixed form. In the command below, VG Name, cl, is passed to
obtain the attributes of this physical volume.
vgdisplay cl Output: --- Volume group --- VG Name cl System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size <49.51 GiB PE Size 4.00 MiB Total PE 12674 Alloc PE / Size 12674 / <49.51 GiB Free PE / Size 0 / 0 VG UUID 7cMstg-INr3-loF0-vT2N-ghpb-IBJx-bzXuv7
Important: VG Size is 49.51 GiB. - Rescan to see that diskhas resized from 53687091200 (50GB) to 161061273600
(150GB).
echo 1>/sys/class/block/sda/device/rescan; dmesg -T | tail -2 Output: [Thu Dec 8 16:44:33 2022] sd 0:0:0:0: [sda] 314572800 512-byte logical blocks: (161 GB /150 GiB) [Thu Dec 8 16:44:33 2022] sda: detected capacity change from 53687091200 to 161061273600
- View the existing partitions and storage devices
again.
parted -l | head -12 Output: Model: VMware Virtual disk (scsi) Disk /dev/sda: 161GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 3146kB 2097kB primary 2 3146kB 527MB 524MB primary xfs boot 3 527MB 53.7GB 53.2GB primary lvm
Important: Disk, /dev/sda, has been resized to 161GB. - Now, resize the disk partition from 50GB to 150GB.
Example
For this example, at the prompts below, you will enter the following in the order listed.
- print - will show you the disk size.
- print free - shows the free space available. In the example below, you will see the
following.
Number Start End Size Type File system Flags 32.3kB 1049kB 1016kB Free Space 1 1049kB 3146kB 2097kB primary 2 3146kB 527MB 524MB primary xfs boot 3 527MB 53.7GB 53.2GB primary lvm 53.7GB 161GB 107GB Free Space
- resizepart - resizes the partition.
- at prompt Partition number?, enter 3 (this is obtainted from the Number column in the example above).
- at prompt End? [53.7GB]?, enter 161GB (this is obtained from the End column in the example above).
- print - verifies the disk size change to 161GB.
-
quit - allows you to quit parted utility.
parted /dev/sda Output: GNU Parted 3.1 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Model: VMware Virtual disk (scsi) Disk /dev/sda: 161GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 3146kB 2097kB primary 2 3146kB 527MB 524MB primary xfs boot 3 527MB 53.7GB 53.2GB primary lvm (parted) print free Model: VMware Virtual disk (scsi) Disk /dev/sda: 161GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 32.3kB 1049kB 1016kB Free Space 1 1049kB 3146kB 2097kB primary 2 3146kB 527MB 524MB primary xfs boot 3 527MB 53.7GB 53.2GB primary lvm 53.7GB 161GB 107GB Free Space (parted) resizepart Partition number? 3 End? [53.7GB]? 161GB (parted) print Model: VMware Virtual disk (scsi) Disk /dev/sda: 161GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 3146kB 2097kB primary 2 3146kB 527MB 524MB primary xfs boot 3 527MB 161GB 160GB primary lvm (parted) quit Information: You may need to update /etc/fstab. $
- Check to see if the disk is resized.
parted -l | head -12 Output: Model: VMware Virtual disk (scsi) Disk /dev/sda: 161GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 3146kB 2097kB primary 2 3146kB 527MB 524MB primary xfs boot 3 527MB 161GB 160GB primary lvm
For partition 3, you will see that the End column now has 161GB.
- Now, you need to resize the physical volume in Logical Volume Manager. The pvs command
provides physical volume information in a configurable form, displaying one line per physical
volume.
pvs Output: PV VG Fmt Attr PSize PFree /dev/sda3 cl lvm2 a-- <49.51g 0 /dev/sdb1 data_vg lvm2 a-- <1024.00g 0
- Display the physical volume is /dev/sda3, for
example.
pvdisplay /dev/sda3 Output: --- Physical volume --- PV Name /dev/sda3 VG Name cl PV Size <49.51 GiB / not usable 0 Allocatable yes (but full) PE Size 4.00 MiB Total PE 12674 Free PE 0 Allocated PE 12674 PV UUID tJa0zz-UQEc-nKHh-mvoo-RfM6-NMM9-fyeaZC
Important: Free PE is still 0 for /dev/sda3. - Resize the Physical Volume.
pvresize /dev/sda3 Output: Physical volume "/dev/sda3" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized
- After resizing the physical volume, display the physical volume is /dev/sda3, for
example, again.
pvdisplay /dev/sda3 Output: --- Physical volume --- PV Name /dev/sda3 VG Name cl PV Size 149.45 GiB / not usable <1.57 MiB Allocatable yes PE Size 4.00 MiB Total PE 38259 Free PE 25585 Allocated PE 12674 PV UUID tJa0zz-UQEc-nKHh-mvoo-RfM6-NMM9-fyeaZC
Free PE is now 25585 for /dev/sda3.
- You are now ready to extend the logical volume and filesystem using lvextend command with all, 100%, of available free space.
- Display information related to file systems about total and available space for root
partition.
df -hT / Output: Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/cl-root xfs 46G 17G 29G 37% /
Size is 46G for 50GB hard disk.
- lvs command provides logical volume information in a configurable form, displaying one
line per logical volume.
lvs Output: LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root cl -wi-ao---- <45.51g swap cl -wi-ao---- 4.00g data_lv data_vg -wi-ao---- <1024.00g
- lvdisplay commanddisplays the properties of LVM logical volumes. For example, logical
volume, cl, in the example below.
lvdisplay cl Output: --- Logical volume --- LV Path /dev/cl/swap LV Name swap VG Name cl LV UUID jj8N64-6UPp-WWQz-UKGj-TAxf-MwXW-HJCu7n LV Write Access read/write LV Creation host, time localhost, 2017-12-07 22:10:11 +0000 LV Status available # open 2 LV Size 4.00 GiB Current LE 1024 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/cl/root LV Name root VG Name cl LV UUID Jqecl2-YErD-8zwd-JHOG-MPZB-lmdI-HdcT8u LV Write Access read/write LV Creation host, time localhost, 2017-12-07 22:10:11 +0000 LV Status available # open 1 LV Size <45.51 GiB Current LE 11650 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
- You are now ready to extend the logical volume using lvextend
command.
lvextend -l+100%FREE -r /dev/cl/root Output: Size of logical volume cl/root changed from <45.51 GiB (11650 extents) to <145.45 GiB (37235 extents). Logical volume cl/root successfully resized. meta-data=/dev/mapper/cl-root isize=512 agcount=4, agsize=2982400 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=11929600, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=5825, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 11929600 to 38128640
- Check the root partition size for
/dev/cl/root.
lvdisplay /dev/cl/root Output: --- Logical volume --- LV Path /dev/cl/root LV Name root VG Name cl LV UUID Jqecl2-YErD-8zwd-JHOG-MPZB-lmdI-HdcT8u LV Write Access read/write LV Creation host, time localhost, 2017-12-07 22:10:11 +0000 LV Status available # open 1 LV Size <145.45 GiB Current LE 37235 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
- Display information related to file systems about total and available space for root
partition.
df -hT / Output: Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/cl-root xfs 146G 17G 129G 12% /
You will see that the root partition has been updated and resized. It is now 146G.
- Exit from Command Line Interface.
exit
- Your virtual machine resource requirements now align with what is required by SevOne NMS' target version. You may now proceed with the steps to perform the upgrade.
- lsblk command reads the sysfs filesystem and udev db to gather
information.