Skip to content

Latest commit

 

History

History
executable file
·
163 lines (116 loc) · 6 KB

File metadata and controls

executable file
·
163 lines (116 loc) · 6 KB

Install VirtualBox

VirtualBox installation depends on your OS, i.e. on your physical computer, which is called host:

  1. Download the VirtualBox package for Ubuntu 24.04 from the official VirtualBox website: virtualbox/Downloads go to Download VirtualBox for Linux Hosts

  2. Install it

cd ~/Downloads
sudo dpkg -i virtualbox*.deb
  1. If there are any dependency issues, run:
sudo apt-get install -f
sudo dpkg -i virtualbox*.deb # again
virtualbox --help # check version

Alternative installation using Oracle’s repository at itsfoss.

Official docs and quick wiki for Ubuntu/Debian.

Install Ubuntu in a Virtual Machine

  1. Download an Ubuntu ISO file from https://ubuntu.com/download/desktop

  2. Open Virtual Box. Click on Machine/New

  3. Set name, ISO image location (of step 1), OS, memory, CPUs,...Example:

  • General:
    • Name: U24.04_150Gb
    • Operating System: Ubuntu (64-bit)
    • Settings File Location: /home/<user>/VirtualBox VMs/U24.04_150Gb
  • System:
    • Base Memory: 12000 MB
    • Processors: 10
  • Storage:
    • Create a Virtual Hard Disk (vdi): 150 GB
  • ...
  1. Do check the Skip Unattended Installation checkbox. Screenshot. This way you will see a detailed step-by-step installation process.

  2. Click Finish

  3. Wait for installation to finish. Fill user, password, keyboard, timezone,...

Guest Additions

Install Guest Additions

After installation of VM, install guest additions. See details and screenshots in linuxtechi.com.

Install Required Packages. Start the VM, open a terminal and run

sudo apt update
sudo apt install -y build-essential dkms linux-headers-$(uname -r)

In VirtualBox interface:

  1. Go to Devices menu at the top of the virtual machine window
  2. Select Insert Guest Additions CD Image. This action virtually mount the Guest Additions CD image into your virtual machine.

In VM terminal install the additions

cd /media/$(whoami)/VBox_GAs_*
sudo ./VBoxLinuxAdditions.run && sudo reboot

After reboot verify installation

  1. Check VM termianl output
lsmod | grep vbox
  1. Check automatic screen resizing and seamless mouse integration. Screen Resize Post VirtualBox Guest Addition

GIF sourced from linuxtechi.com

Enable Clipboard

  1. Click on Machine/Settings/General/Advanced and set:
  • Shared Clipboard as Bidirectional
  • Drag'n'Drop as Disabled is my personal preference
  1. Start the VM. Try to copy text from host and paste into VM, then vice versa

Set Screen Resolution

During installation of VM you might not be able to change the resolution size.

After installation of Guest Additions set the highest resolution in the menu View/Virtual Screeen

Shared Folder

  1. Create in host a shared folder and paste there any file

In host run

dir01="/home/$(whoami)/VirtualBox VMs/U24.04_150Gb__sharedDir/"
mkdir "$dir01"
cp -v /usr/share/backgrounds/ubuntu-wallpaper* "$dir01"
  1. VirtualBox select the desired VM, go to menu Settings/Shared Folders
  • Click on Add new shared folder (at right)
  • Set folderpath (replace user with your username): /home/user/VirtualBox VMs/U24.04_150Gb__sharedDir/
  • Set mount point: /media/host_VM_sharedDir
  • Set automount and make permanent
  1. Start the VM. Open a terminal and run:
sudo usermod -aG vboxsf $USER
sudo reboot

Check that the shared folder should automatically be mount at /media/host_VM_sharedDir/:

xdg-open /usr/share/backgrounds/ubuntu-wallpaper*.png

If not working, then manually mount it:

sudo mount -t vboxsf U24.04_150Gb__sharedDir /media/host_VM_sharedDir

# To make the mount persistent across reboots, add this line to /etc/fstab:
echo "U24.04_150Gb__sharedDir /media/host_VM_sharedDir vboxsf defaults 0 0" >> /etc/fstab

# Set appropriate permissions:
sudo chown $USER:$USER /media/host_VM_sharedDir
sudo chmod 755 /media/host_VM_sharedDir

Still troubles? See virtualbox-docs concerning:

Bonus - How to Use Snapshots

Excellent Corey Schafer video.