- Extend the virtual disk file size
- Open a command prompt and navigate to the VirtualBox installation folder.
- List all virtual hard disks and take note of the Location of the disk you want to resize.
[code]VBoxManage.exe list hdds[/code]
- Resize the disk.
[code]VBoxManage.exe modifymedium disk "C:\Sudhakar\OracleDBAShop_Blog\VirtualBox VMs\RHEL7.5\RHEL6.5.vdi" --resize 40000[/code]
- Verify disk size. [code]VBoxManage.exe list hdds[/code]
Note:To be able to resize a disk it should be created as a dynamically allocated disk. You cannot resize of virtual disk that is created as a fixed size disk.
To convert a fixed disk to dynamic, run
[code]VBoxManage.exe clonemedium disk "C:\Sudhakar\OracleDBAShop_Blog\VirtualBox VMs\RHEL7.5\RHEL6.5.vdi" "C:\Sudhakar\OracleDBAShop_Blog\VirtualBox VMs\RHEL7.5\RHEL6.52.vdi" --variant Standard[/code]
[code]VBoxManage.exe clonemedium disk "C:\Sudhakar\OracleDBAShop_Blog\VirtualBox VMs\RHEL7.5\RHEL6.5.vdi" "C:\Sudhakar\OracleDBAShop_Blog\VirtualBox VMs\RHEL7.5\RHEL6.52.vdi" --variant Standard[/code]
2. Add new Partition
List disk devices and partitions.
[code]fdisk -l[/code]
[code]fdisk -l[/code]
The above output shows there are two partitions on the disk /dev/sda. To add a new partition, run
[code]fdisk /dev/sda[/code]
In the fdisk command prompt,
- Enter n to create a new partition.
- Enter p to create primary partition.
- Press ENTER to accept default for first sector.
- Press ENTER to accept default for Last sector. This will create a partition with all the remaining available space on the disk. Alternatively you could specify the size, in my example 4G will add a partition of size 4GB.
- Enter t to set the type of the new partition to Linux LVM.
- Select partition number 3.
- Enter 8e as the Hex code.
- Finally enter the command w to save the changes to disk and exit fdisk.
[code]fdisk -l[/code]
3. Reboot the Virtual Machine and Initialize LVM (Logical Volume Manager)
To initialize LVM on the newly created partition, run
[code]pvcreate /dev/sda3[/code]
4. Add partition to volume group
To do this, first List physical volumes and note the VG Name from the output.
[code]pvdisplay[/code]
To initialize LVM on the newly created partition, run
[code]pvcreate /dev/sda3[/code]
4. Add partition to volume group
To do this, first List physical volumes and note the VG Name from the output.
[code]pvdisplay[/code]
Extend the root volume group
[code]vgextend rhel /dev/sda3[/code]
5. Extend the root logical volume.
Identify the path for the root logical volume.
[code]lvdisplay[/code]
Extend the logical volume and resize to filesystem.
[code]lvextend --size +3GB --resizefs /dev/rehel/root[/code]
6. Verify the disk size
To verify the size of root volume, run
[code]df -h[/code]




No comments:
Post a Comment