I am sorry to have had to split the article up, but it was getting too long. The second part goes into the aspects of using more of the various features of VirtualBox.
There should hopefully be something here that will be useful to everyone.
The first part is located here: https://www.linux.org/threads/virtualbox-explored-part-1.40456/
Access to USB Devices
We should now be able to access USB devices, specifically USB storage devices. Sometimes you need to bring data into or out of a machine. Placing the data onto a USB storage device can help make it more accessible to the machine in VirtualBox and to other systems.
Be aware that the Host system cannot access the USB storage device while it is being used by a virtual machine.
Insert the USB device into the Host System and make sure it is being seen by the Host System. Think about the format of storage devices. Such as if the device is being accessed by Linux systems and Windows systems. You want the device formatted as FAT32 or NTFS. Do not use a format such as EXT and expect to use it on a Windows system unless it has the proper drivers to access the specific format. There are programs out there for Windows to access EXT formatted drives.
Within the Machine on VirtualBox, there is a drop-down menu at the top of the screen. Unless you have changed the View to ‘Full Screen’ or ‘Seamless Mode’, then the menu is at the bottom of the screen. Find the option for ‘Devices’ and then move to ‘USB’. A list of USB devices should appear to the side of the drop-down menu. Select your USB device you just inserted. After a bit, the USB device should appear in the Ubuntu machine.
To remove the USB device, go back to ‘Device’, ‘USB’ and unselect the USB device that you previously added. The device should disappear from the Machine and reappear on the Host System.
Add an Optical Drive/Image
If your system has a CD/DVD/Bluray drive, you can access disks in it from the Machine as if it had the optical drive connected to it and not the Host. It is possible to mount ISO files as an optical drive.
If you have an optical drive, insert your disk. Go to ‘Devices’, ‘Optical Drives’ and you should see a list of options.
Part of the list is mounted images that the system detects as an optical drive. It keeps a list of recent files used. There should also be a list showing your Host’s optical drive. If you choose this option, then the optical drive is mapped to the machine.
There is an option to ‘Choose/Create a disk image…’. Choosing this option lets you connect to a VirtualBox disk image from another machine or one created that is not linked to a machine. You can then copy files to and from the attached disk image.
You can also select ‘Choose a disk file..’. From this option, you can choose various image files:
Once you locate the image file on the Host system, select it and click ‘Open’. It loads the image and adds it as if it were an optical drive.
The last option on the drop-down list is ‘Remove disk from virtual drive…’. This is the same as ejecting the disk drive.
It is possible to share folders between the Host and machine. For some, this may be easier than copying files back and forth between a USB and sharing files in this manner.
Click on ‘Devices’ and move down to ‘Shared Folders’ and over to ‘Shared Folders Settings’.
You should see a window that gives you two options: Machine or Transient. Machine shared folders are permanent folders that remain on the Host drive. A Transient shared folder is created and then removed when you reboot the machine.
First, let’s look at ‘Machine Folders’. Select ‘Machine Folders’ and then click on the folder with the plus sign (+) to the right of the window. For ‘Folder Path’, select the down arrow to select ‘Other’. Select the folder you want to share from the Host System. You can create a new folder to use as well. The folder is not like the USB share, you can access the folder from both the machine and Host system. Click ‘Open’ once you have made your choice.
VirtualBox will fill in the ‘Folder Name’, but you can change it. This is the name that will appear in the machine. You can select to make the shared folder ‘Read-only’ so the machine can only read the files and not write to the folder or delete files. There is also an option to ‘Auto-mount’, so the connection to the shared folder is automatic when the machine starts. You can choose to ‘Make Permanent’ to make the share a permanent setting (which you can remove later). If you do not select ‘Make Permanent’, then the Shared Folder is a Transient Folder.
Open a terminal and run the command ‘sudo apt install virtualbox-guest-utils’. After it installs the packages, open your file manager. Listed in the left pane should be a folder that starts with ‘sf_<name>’. You set the ‘<name>’ when making the Shared Folder. You can see the share, but you do not have permissions yet to access it. To give you permissions, you need to add your user account to the group named ‘vboxsf’. To add your account to the specified group, use the command ‘sudo adduser <name> vboxsf’. Just place in your user name for ‘<name>’. The change will not take effect until you reboot.
Change Disk Drive Size
If you originally specify a disk image size for your machine, you can increase it. To perform this function, you’ll need to power down the machine. Just remember the name of the Virtual Disk Image you created when you first made the machine.
In VirtualBox, go to ‘File’ and then select ‘Virtual Media Manager’. Here is a window that contains all the Virtual disks you have made for your machines. There is also a tab for ‘Optical disks’ that lists all the image files you have mounted as an optical disk.
For changing the disk size, you need to stay on the ‘Hard disks’ tab. Locate your disk image file and click it once to select it. In the ‘Type’, just leave it as ‘Normal’. It also lists the ‘Location’ of the file. Under the box for the ‘Description’, there is a slider bar. You can adjust the slider or type in the new size to the right of the bar. Once you have made the change, click on ‘Apply’ to save the changes and then click ‘Close’.
If you have a Dynamic disk, then this procedure works. If you made a fixed disk, let’s look at getting around this issue.
We need to clone the existing disk; I hope you have the space for this. Make sure you select the image file you want to clone. Click on the ‘Copy’ icon and it gives you the option of what type of image file to create and then you can set the location and name. The default location and name is the same with a ‘_copy’ added to the filename. Click ‘Copy’ to start the cloning. Once it copies the file, it is now a ‘Dynamic’ image and not ‘Fixed’.
Now you can move the slider bar or type in your new file size as you need.
Close the ‘Virtual Media Manager’ and go back to the main VirtualBox Manager window. Select the machine you want to change the file size. Once selected, click on ‘Settings’ and then ‘Storage’. In the right pane you should see the hard drive image that was the old copy. Select it and then click on the hard drive icon in the right side of the window. Select ‘Choose/Create a Virtual Hard Disk’. You should now see a window that lists the images. Find the ‘copy’ that you made and select it. Click ‘Choose’. The ‘copy’ of the original should not be ready to mount by the machine instead of the smaller original file. Clock ‘OK’ and then ‘Start’ to load up the machine.
Once loaded, you need to use ‘GParted’ to resize the partition to include the new increased amount. Right-click on the partition. Notice there is an empty space after the main partition. Change the value of the ‘Free Space following’ to ‘0’ and then tab back. It increases the New size by the free amount. Click ‘Resize’ to make the changes permanent. Click the green check mark to apply the changes. Select ‘Apply’ on the new window that opens. If you get an error about the GPT not using all the space, click ‘Fix’.
You can open the ‘Virtual Media Manager’ to delete the old disk image to free up space in your Host System.
Your disk image is now ‘Dynamic’ and will save you some space.
Now, a snapshot is like taking a picture, or snapshot, of the current machine. Any changes you make, you can undo them with the snapshot. This has similarities to performing a backup of the machine.
If we were going to install updates and we weren’t sure they would work properly, we can take a snapshot and then install the updates. If the updates need to be removed, we just reapply the snapshot and put the machine back to the way it was before we started the update.
In the left pane of the VirtualBox window is your list of machines. At the right end of the machine list is an icon of three horizontal lines with a blue box to the left of each line. If you left-click on this icon, an option list will appear. There are two options: Details and Snapshots. If you select ‘Snapshots’, then you should see a new window containing a list of snapshots for the selected machine.
If no snapshots exist, then you will only see an option for the ‘Current State’.
To make a Snapshot, click on the icon labeled ‘Take’. It gives you a window that will allow you to name the Snapshot and set a Description. Once you have made any changes, click on ‘OK’ to create the Snapshot.
A Snapshot I created was 736 MB in size. The Snapshots are not a complete copy of an image file.
If you were to perform an update or do something that left the OS on the machine in a less usable state, you can restore the Snapshot. Removal of packages or changes that might require you to perform a Restore.
Go back to the Snapshot window, where you first created the Snapshot. Select the snapshot that you want to return to and click on the ‘Restore’ icon.
If you have ‘Snapshots’ you do not need, then select the ‘Snapshot’ and click on the ‘Remove’ icon.
If you have a machine that you want to make a copy of and do things with it, but still want your original machine, you can ‘Clone’ it.
Cloning a machine makes a copy, so you now have two machines.
Simply select your machine to clone in the left pane. Click on the ‘Clone’ icon at the top of the VirtualBox Window. It asks you to provide a new name for the machine, set its path, and set a few other options. Once you set these and click ‘Next’, it asks you whether you want a ‘Full Clone’ or ‘Linked Clone’.
A ‘Full Clone’ makes two machines that are separate from each other.
A ‘Linked Clone’ creates a new machine, but now a new disk image. Both machines use the same disk image as a base. Any changes made to the machine are stored in a separate VDI file for itself. Many Linked Clones can be running at the same time off the same ‘base’ machine.
Make your choice and click on ‘Clone’.
This covers a good portion of VirtualBox.
I hope this can help you understand some capabilities of the program.
VirtualBox can be a very handy tool, so make sure you understand how to use it so you can do more with it.