VirtualBox is free for private use and simulates a complete PC including its peripherals. Different operating systems can therefore be installed within Linux.
Under Gentoo run emerge virtualbox. It uses /dev/vboxdrv
from the virtualbox-modules package.
The group of the users vboxusers have access. So you might put
yourself to this group usermod -a -G vboxusers <thats me>
and login log out and log in to make the system aware of it.
Since VirtualBox uses kernel modules that do not come with the kernel source they must be loaded. lsmod | grep 'vbox' will show if they are running
There are also some kernel modules coming with the Kernel source so check VBOX
VirtualBox is the command to start it. The configuration is done via a GUI and a wizard.
Some vocabulary to learn:
Guest is the virtual PC
Host is your physical PC
The right Ctrl key is per default the host key. Its function is to toggle the capture of the mouse and keyboard between host and guest. Right Ctrl + C brings the menu back.
The manual: http://www.virtualbox.org/manual/UserManual.html
~/.VirtualBox
holds the configuration. Before working with Virtual box go in the Settings of the VirtualBox Manager and select the default directory where you want to install, this might be important if you want to backup or synchronizing your virtual machines. Be aware that a lot of memory will be occupied since a regular virtual hard disk will have many GBytes.
The guest will see rather simple generic PC hardware, with a low performance graphic card and low
resolution, so it is time to add some more functionalities. The ISO image /usr/share/virtualbox/VBoxGuestAdditions.iso
can be inserted into the virtual boxes CD drive.
For gentoo emerge virtualbox-additions
Since it runs inside the guest machine it just has some impact on the guest machine. If virtualbox gets reinstalled on a new machine and the guest disk is copied to the new machine than the guest additions are already installed and do not need to be reinstalled
Start the virtual machine and run the guest additions:
On Linux mount the ISO image /opt/VirtualBox/additions/VBoxGuestAdditions.iso
. Maybe your guest operating system uses autorun when the iso image is found, there is also a menu item to install it or open the ISO image in the guest Linux and run autorun.sh
When you run Windows as a guest, you have now a CD with the guest additions probably in drive D:. Go there and start it.
For Gentoo there is also virtualbox-guest-additions that is for gentoo guests and comes with an OpenRC service. This is not the iso image. So do not emerge it when not having a gentoo guest.
Run a ISO CD image is easy, create a virtual machine with no operating system and no hard disk. The select the ISO image under CD drives and up to go.
Data between host and guest system can be exchanged using shared folders (guest-additions need to be installed). In Virtual Box set the folder to be shared on the host. Then go to the guest systems:
On a Ubuntu guest system (where no root exist sudo needs to be used) open a terminal and type the
following to mount a folder: sudo mount -t vboxsf<name of the shared folder>
<mounting point on guest>
or to make sure you get access: sudo mount -t vboxsf -o uid=1000 -o gid=1000<name of the shared folder> <mounting point on guest>
and to unmount: sudo umount<mounting point on guest>
Due to cyber-security reasons on old Windows versions disable the Ethernet connection but attach a network drive using the Windows-Explorers pull down menu Extra > Network drive. Alternatively you could use samba to communicate to the host system.
USB support for USB1 goes directly without additional installation. For USB2 and USB3 the extension pack needs to be installed. For gentoo emerge app-emulation/virtualbox-extpack-oracle
Select in VirtualBox the USB devices (not just usb sticks) that you want to make available to the virtual machine.
On the Linux host make sure
the hardware is detected and the necessary permission to access it are set. ls -l /dev/ttyS0 will show the group as uucp (or dialout), usermod -a -G uucp <thats me>
add it to the group and cat /etc/group | grep 'uucp' will verify it.
Then test it with a terminal program. If it fails and sees no port check with lsmod | grep 8250 if the serial port drivers are loaded. If not, check the kernel if the drivers are included in the kernel or select kernel option to create the 8250 driver. In Virtualbox map COM1 to the host device as /dev/ttyS0
.
On older Windows versions when not seeing any COM port, a scan for new installed hardware. Test can be done with hyperterminal.
The virtual PC does not care about USB when having a USB to RS232 adapter. Alternatively map the USB device to the virtual PC, and install there the Windows driver for the USB RS232 cable.
Check http://wiki.freedos.org/wiki/index.php/VirtualBox create the virtual machine and insert the iso Freedos image.
C:\FDOS\DN2\DN is something as mc filemanager
FDIMPLES with the freeDOS image in the CD drive installs programs
Data can be exchanged if FreeDos is not running by mounting its virtual harddisk (if format is supported).
A snap shot of the virtual machines can be made. When after a snap shot the virtual machines installation got damaged (virus, installation of applications) then it can be reverted to the status when the snap shot has taken place.
Snapshots take a lot of disk space, therefore check if there is enough disk space. Snapshots can be deleted using the Virtual Box GUI, this takes time since snapshots are not entire copies. It uses files that need to be merged when deleting a snapshot.
When a disk is created a VDI (Virtual Disk Image) file is created. When a snapshot is created also a vdi file is created, but this file contains just the difference to the base VDI file.
To backup and synchronizing Virtual machines among different computers the internals of Vbox need to be understood.
There are two key files:
An xml file that holds all the settings of the virtual PC. This file has either xml or vbox extension and its file name corresponds to the name of the Vitrual machine.
A file the holds the contents of the hard disk used. It usually has the extension VDI (Virtual Disk Image) but depending on the format chosen it can differ as vmdk (VMWare ).
As with any other program, vbox also gets evolved ant therefor the data and it directory structure might become old an even on day no more supported. Importing and exporting the virtual machines and its hard disks as described below will update them to the newest version.
To backup the virtual machines those files can be directly accessed but the VirtualBox Manager offers also some more safe gui tools for manipulating as:
Virtual media manager that offers commands dealing with the virtual hard disks (copy, modify, release, remove,... ).
Virtual machines can be easily modified by selection the settings tab. They can also be copied selecting clone.
Adding a vbox file will add the virtual machines including its disk to VirtualBox
Finally they can be imported and exported using a single TAR archive. This TAR archive is called Open Virtualization Format Archive or ova format. This archive holds three files:
The disk image is moved to a vmdk file.
The xml file ovf containing the description of the virtual PC
An optional manifest file with the mf extension that holds the checksums.
Be aware that snapshots disappear when importing and exporting
Once a VDI file is created, the size is fixed and can not simply be enlarged.
When creating dynamic VDI file, the actual size of VDI file on the physical hard disk is smaller than the virtual size of the disk. So be a bit optimistic and add larger VDI file size. Be aware that your host computer does not run out of disk size when such disks grow. It is wise to put the VDI files to a separate partition to prevent such crashes.
To expand a a VDI file to 80GB run VBoxManage modifyhd "Windows 10.vdi" --resize 80000 and verify it with VBoxManage showhdinfo "Windows 10.vdi"
However this is not enough. It just makes the disk larger but not the partitions on the disk. The partitions must be made larger in the guest or on a mounted disk.
It might be desirable to mount the virtual harddisks under the real PC. When done, then also the restricted directories (as android has) can be read and backup gets easy. Be aware that this topic might be quite experimental and in general it should be avoided when the virtual PC accesses this hard disk. Depending on the file format of the virtual hard disk there are some options.
For vdi it is quite experimental and not mentioned in the VirtualBox documentation. The forum https://forums.virtualbox.org/viewtopic.php?t=52 says:
use a fixed size vdi file
make sure it does not contain a snapshot
have just one primary partition
don't have VirtualBox running and accessing this file
The vdi file contains the disk, but also additional information, therefore the offset has to be know that separates the additional information from the file system. The offset can be found by:
vditool DUMP<my>
.vdi
or by using a HEX editor and finding the string MSDOS in the file, then subtract 3 from its address or use the od (object dump) command:
Knowing the offset the vdi file can be mounted as
mount -o loop,offset=34304,umask=000<path and name of the vdi file>
/mnt/vdifs
The the vdi file can be mounted with a script like this:
Example 16.1. Mount vdi
#!/bin/bash VDI=mydisk.vdi OFFSET=$(./vditool DUMP $VDI|perl -ne 'print 32256+$1 if m/offData=(\d+)/') sudo mount -o ro,noatime,noexec,loop,offset=$OFFSET $VDI loopmnt/
To mount the first partition type:
./mount_vdi.sh /home/lindegur/.VirtualBox/HardDisks/FreeDos.vdi /home/lindegur/VM/FreeDos/ 1
For vmdk there is the command vmware-mount that mounts them easily under Linux. http://www.vmware.com/pdf/VMwareDiskMount.pdf shows the details. After emerge vmware-workstation the command can be found under /opt/vmware/bin/vmware-mount
/opt/vmware/bin/vmware-mount -p <path to vmdk file>
shows its partitions
/opt/vmware/bin/vmware-mount <path to vmdk file>
/mnt/vmware/ mounts
/opt/vmware/bin/vmware-mount <path to vmdk file>
2 /mnt/vmware/ mounts 2nd partition
/opt/vmware/bin/vmware-mount -x unmounts everything
libguestfs can do it. See http://wiki.freedos.org/wiki/index.php/VirtualBox_-_Chapter_6 to mount guestmount -a FreeDOS_1.2.vhd -m /dev/sda1 /home/username/vhd to unmount guestunmount /home/username/vhd
Networking can be come tricky. There are different options:
Network Address Translation (NAT) is the default setting. It connects the virtual machine to the Internet and needs no special setup. Drawbacks are that the VM can not act as an device connected to to local intra-net.
In this mode the VM acts as a computer on the hosts Ethernet, resulting in a setting to be made, a (or the) host network adapter.
It can do what ever other computers can do as accessing the Internet.
A network is created that connects all VM to the host. The host would have to act as an router to have the VM's acting the Intra-net or Internet. Per default the host gets address 192.168.56.1 and the devices when obtaining their address via virtual-box's dhcp server get addresses starting from 192.168.56.101.
There are some settings to be done on the host to recognize this new network.