Backing up
Just make a copy of the .vbox
and .vdi
files.
Reducing disk space of dynamic disks.
This doesn’t work for encrypted disks.
On client virtual machine:
- For Windows
- Defragment disk, e.g
defrag c:
- Zero free space, e.g
sdelete -z c:
(sdelete is part of SysInternals)
- Defragment disk, e.g
- For Linux
dd if=/dev/zero of=zeroes bs=1M
until there is no space leftrm zeroes
Followed by on host computer:
VBoxManage.exe modifyhd /path/to/file.vdi --compact
Alternate technique
It may help to defragment and zero free space on existing disk first.
- Create new VDI of smaller size.
- Boot GParted or Clonezilla using ISO image, and clone existing disk to the new smaller sized disk (vdi).
- Change VM settings and boot VM using smaller disk.
Sharing a folder RHEL or CentOS Linux VirtualBox VM
Update VirtualBox Guest Additions modules
Requires gcc and kernel headers installed. If not then run:
yum instal -y gcc kernel-devel-$(uname -r)
Devices > Insert Guest Additions CD image
mount /dev/cdrom /mnt
sh /mnt/VBoxLinuxAdditions.run
umount /mnt
Check module is installed with lsmod | grep vbox
. You should see the vboxsf
module.
Sharing a folder
To attach a folder for sharing:
- Under Device > Shared Folders – Add your desired folder. Select “permanent” if you want this folder shared all the time.
- Mount the drive with:
mount -t vboxsf FOLDERNAME MOUNTPOINT
- When finished,
umount MOUNTPOINT
To make mount point persistent between reboots, add entry in /etc/rc.local
(or /etc/fstab
).