Cyber Deals - Get up to 65% off on CKA, CKAD, CKS, KCNA, KCSA exams and courses!

VirtualBox Notes

1. VirtualBox Guest Addtion on CLI

  • Mount Guest Addtion ISO (from Console Menu)
  • Mount it from OS (/vmboxguestiso is destination mount point)
mount /dev/cdrom /vmboxguestiso/
  • Resolve Dependancies

Install kernel-header

`sudo yum update && sudo yum -y install kernel-headers kernel-devel`

## install other packages
yum install gcc make perl

2. Optimize VirtualBox VM Disk Space

  1. Clean up inside the VM
$ sudo dnf clean all
$ sudo journalctl --vacuum-time=7d
$ sudo rm -rf /var/cache/*
$ sudo rm -rf ~/.cache/*
  1. Zero out the free space
$ sudo dd if=/dev/zero of=/zerofile bs=1M
dd: error writing '/zerofile': No space left on device
107617+0 records in
107616+0 records out
112843751424 bytes (113 GB, 105 GiB) copied, 127.059 s, 888 MB/s

$ sudo rm -f /zerofile
  1. Shutdown the VM
$ sudo shutdown -h now
  1. Run VBoxManage to compact the disk

VirtualBox does not support compacting .vmdk disks directly. Convert your .vmdk disk to .vdi, compact it, and then continue using the compacted disk.

 $  VBoxManage clonehd \
  "/path/to/vm-folder/aap25-rhel92-1/generic-rhel9-virtualbox-disk001.vmdk" \
  "/path/to/vm-folder/aap25-rhel92-1/aap25-compact.vdi" \
  --format VDI
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'VDI'. UUID: 6517df59-9cd0-4393-bb03-c5d182219cc3

Now run the compact vdi command.

$  VBoxManage modifymedium "/home/gmadappa/VirtualBox VMs/aap25-rhel92-1/aap25-compact.vdi" --compact
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

3. Troubleshooing VirtualBox VM

3.1. Unable to mount Shared folders in CLI

Check vboxsf module sudo modprobe vboxsf

Disclaimer: Views expressed in articles are those of the respective authors and do not necessarily reflect the views of their employers or this site. While we aim for accuracy, please verify information before relying on it, and let us know if you spot an error.
Share:

Related Posts

Openshift

OpenShift Installation on GCP with Nested Vrtualization

Warning: This is NOT tested multiple times; refere by your own risk

Openshift

OpenShift Installation Baremetal on AWS

INPG - DO NOT FOLLOW BLINDLY! Other notes: OpenShift - Tools, Learning Guides and References OpenShift and Service Mesh OpenShift Installation Methods …

Openshift

OpenShift Installation Methods - Examples

Installing an OKD 4.x Cluster Install OpenShift 4.x Method I - Setup an OpenShift All-In-One Install required packages Disable Firewall Installing …

Openshift

OCP Origin 3.x Installation - on GCP

Master Server Configuration Step 1 : Update system Step 2 : Install Required Packages Step 3 : Clone the package from github Step 4: Configure your …

Openshift

OpenShift Local (Formerly CodeReady Containers - CRC)

Installing CodeReady Containers Download CRC Package Required software packages Enable sudo for user Setup Cluster Access your Cluster Enable cluster …