Steps to expand the disk space used by Versa analytics VM
- To increase an existing qcow2 image size, we can issue following command on the host machine after shutting down the VM.
- # Original disk size is around 80G. Increase by 10G
Step-1:
- sudo qemu-img resize /home/versa/versa-analytics-0e43394-15.2R4.qcow2 +10G
Similar command/step will be available in ESXi host also.
Step-2:
- After restart
- The df command will not show the extra space as it is still not available in the root partition.
- versa@versa-analytics:~$ df -kh
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/system-root 71G 2.8G 65G 5% / à Same as before
- none 4.0K 0 4.0K 0% /sys/fs/cgroup
- udev 3.9G 4.0K 3.9G 1% /dev
- tmpfs 799M 400K 799M 1% /run
- none 5.0M 8.0K 5.0M 1% /run/lock
- none 3.9G 0 3.9G 0% /run/shm
- none 100M 0 100M 0% /run/user
- /dev/vda1 236M 37M 187M 17% /boot
- The lsblk command will show the available block devices.
- versa@versa-analytics:~$ sudo lsblk
- [sudo] password for versa:
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- vda 253:0 0 90G 0 disk -à Shows the extra storage in vda
- |-vda1 253:1 0 243M 0 part /boot
- |-vda2 253:2 0 1K 0 part
- `-vda5 253:5 0 79.8G 0 part
- |-system-root (dm-0) 252:0 0 71.7G 0 lvm /
- `-system-swap_1 (dm-1) 252:1 0 8G 0 lvm [SWAP]
Step-3:
- Create a new Logical partition with entire 10 G. Choose file system type as Linux LVM and then write the partition table to disk and quit. Please Refer the section "How to create NEW Partition".
- Issue the command : sudo cfdisk /dev/vda
- *Note : Partition type may vary from the types of installations like VDA - for IBM , SDA - for SCSI and XVDA - for Xen.
Step-4:
- Reboot the VM
- After reboot, new logical partition will show up (in this case vda6)
- versa@versa-analytics:~$ sudo lsblk
- [sudo] password for versa:
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- vda 253:0 0 90G 0 disk
- |-vda1 253:1 0 243M 0 part /boot
- |-vda2 253:2 0 1K 0 part
- |-vda5 253:5 0 79.8G 0 part
- | |-system-root (dm-0) 252:0 0 71.7G 0 lvm /
- | `-system-swap_1 (dm-1) 252:1 0 8G 0 lvm [SWAP]
- `-vda6 253:6 0 10G 0 part à 10 G shows as new virtual device
Step-5:
- Initialize physical volume for use by LVM : "sudo pvcreate /dev/vda6"
- Get the volume group name
versa@versa-analytics:~$ sudo vgdisplay
--- Volume group ---
VG Name system -à
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 79.76 GiB
PE Size 4.00 MiB
Total PE 20418
Alloc PE / Size 20407 / 79.71 GiB
Free PE / Size 11 / 44.00 MiB
VG UUID rQQ1qy-BBTO-H7TZ-Ua10-Wt11-mo2Y-tjuGyp
Step-6:
To add additional physical volumes to an existing volume group, use the vgextend command. The vgextend command increases a volume group's capacity by adding one or more free physical volumes.
Extends or add /dev/vda6 to system volume group
versa@versa-analytics:~$ sudo vgextend system /dev/vda6
Volume group "system" successfully extended
Step-7:
Extend the logical volume
versa@versa-analytics:~$ sudo lvextend -l+100%FREE /dev/system/root
Extending logical volume root to 81.76 GiB
Logical volume root successfully resized
versa@versa-analytics:~$
Step-8:
Resize the root file system.
versa@versa-analytics:~$ sudo resize2fs /dev/mapper/system-root
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/system-root is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 6
The filesystem on /dev/mapper/system-root is now 21432320 blocks long.
Check by issuing df command
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/system-root 81G 2.8G 74G 4% / à Is increased by 10 G.
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 3.9G 4.0K 3.9G 1% /dev
tmpfs 799M 404K 799M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/vda1 236M 37M 187M 17% /boot
versa@versa-analytics:~$
versa@versa-analytics:~$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 90G 0 disk
|-vda1 253:1 0 243M 0 part /boot
|-vda2 253:2 0 1K 0 part
|-vda5 253:5 0 79.8G 0 part
| |-system-root (dm-0) 252:0 0 81.8G 0 lvm /
| `-system-swap_1 (dm-1) 252:1 0 8G 0 lvm [SWAP]
`-vda6 253:6 0 10G 0 part
`-system-root (dm-0) 252:0 0 81.8G 0 lvm /
How to create NEW Partition:
# Original disk size is around 80G. Increase by 300GB
Step-1 : Command used to view the partitions : sudo fdisk -l
Ex:
[versa@versa-analytics: ~] $ sudo fdisk -l
Disk /dev/vda: 380 GiB, 408021893120 bytes, 796917760 sectors <<< Total Disk Size is 380GB ( 80GB + 300GB Additionally added )
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xaca4508d
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 167770111 167768064 80G 8e Linux LVM <<< Already Existing Parition with 80GB
Step-2 : To create a new Partition you need to go to command mode with the CLI : sud ofdisk /dev/vda
[versa@versa-analytics: ~] $ sudo fdisk /dev/vda
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Step-3 : Use 'p' to print the current partition table to the terminal from within command mode.
Command (m for help): p
Disk /dev/vda: 380 GiB, 408021893120 bytes, 796917760 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
Disklabel type: dos
Disk identifier: 0xaca4508d
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 167770111 167768064 80G 8e Linux LVM
Step-4 : Use the command 'n'to create a new partition. You can create a logical or primary partition (l for logical or p for primary).
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2 <<<<< Depends on the new VDA partition number created.
First sector (167770112-796917759, default 167770112):
Last sector, +sectors or +size{K,M,G,T,P} (167770112-796917759, default 796917759):
Created a new partition 2 of type 'Linux' and of size 300 GiB.
Step-5 : To verify the partitions , use the command 'p'.
Command (m for help): p
Disk /dev/vda: 380 GiB, 408021893120 bytes, 796917760 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
Disklabel type: dos
Disk identifier: 0xaca4508d
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 167770111 167768064 80G 8e Linux LVM
/dev/vda2 167770112 796917759 629147648 300G 83 Linux <<<<< Type needs to be changed to Linux LVM
Step-6 : Use the command 't' to enter the partition type change command. Select the partition number and issue the Hex code '8e' to convert into Linux LVM.
Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): L <<<< To list all the codes.
Hex code (type L to list all codes): 8e <<<< Select 8e for Linux LVM
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): p
Disk /dev/vda: 380 GiB, 408021893120 bytes, 796917760 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
Disklabel type: dos
Disk identifier: 0xaca4508d
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 167770111 167768064 80G 8e Linux LVM
/dev/vda2 167770112 796917759 629147648 300G 8e Linux LVM
Step 7 : Use the command 'w' to write the new partition with defined properties.
Command (m for help): w
The partition table has been altered.
Syncing disks.