Debugging Vagrant 2.4.3 Installation Failures on Ubuntu 22.04 Jammy Jellyfish with VirtualBox 7.14

Vagrant and VirtualBox on Mac M2 Max are a no-no for now because of the arm architecture, which is not fully available yet. So, I decided to install it on my Ubuntu 22. I came across a few hurdles, so I am going to discuss how I managed to fix them.

Error: VirtualBox USB enumeration

The reason the error exists is because according to this blog https://www.techrepublic.com/article/fix-virtualbox-usb-error/, the Virtual Box must be a member of the vboxusers.

To fix this, run the command:

Bash
sudo usermod -aG vboxusers $USER

Close the VirtualBox and restart the computer.

Error: Kernel driver not installed

Console Output
The VirtualBox Linux kernel driver is either not loaded or not set up correctly. Please try setting it up again by executing
'/sbin/vboxconfig'

as root.

I tried doing sudo /sbin/vboxconfig but it didnt work and the error says:

Console Output
Look at /var/log/vbox-setup.log to find out what went wrong.

I found this:

Console Output
gcc-12: not found

To fix this, install gcc https://www.dedoimedo.com/computers/virtualbox-kernel-driver-gcc-12.html

Run the command again:

Bash
sudo /sbin/vboxconfig

Error: Vagrant box hashicorp/bionic64 not working

I tried adding the box but it failed. The error says Unrecognized archive format.

Bash
vagrant box add hashicorp/bionic64

I downloaded the box here: https://portal.cloud.hashicorp.com/vagrant/discover/ubuntu/bionic64 and tried adding the box manually.

Bash
vagrant box add --name ubuntu/bionic64 bionic-server-cloudimg-amd64-vagrant.box
Bash
vagrant init ubuntu/bionic64
Bash
vagrant up

Check the VM.

Check the vagrant status.

That’s it!

Upgrading Docker from version 25 to version 27 in Amazon Linux 2023.6.20241212

I have this Jenkins server that I haven’t touched for a year, and when I started it, I was greeted with two upgrades. One is from Jenkins, and the other one is from AWS. I did an upgrade of AWS to 2023.6.20241212. Everything went fine until suddenly I checked my Docker, and I have an outdated version 25 which I believe is correct based on this information from AWS https://docs.aws.amazon.com/linux/al2023/release-notes/all-packages-AL2023.6.html

The latest version of Docker is now on version 27 based on the time of writing. I checked the details of the installed AWS Linux and it is based on Fedora https://aws.amazon.com/linux/amazon-linux-2023/faqs/

Let’s verify.

I did a google and found this command:

Bash
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

I got an error:

Console Output
Docker CE Stable - x86_64                                         693  B/s | 417  B     00:00   
Errors during downloading metadata for repository 'docker-ce-stable':
 - Status code: 404 for https://download.docker.com/linux/fedora/2023.6.20241212/x86_64/stable/repodata/repomd.xml (IP: 0.0.0.0)
Error: Failed to download metadata for repo 'docker-ce-stable': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: docker-ce-stable
Last metadata expiration check: 1:07:15 ago on Tue Jan  7 14:23:13 2025.
No match for argument: docker-ce
No match for argument: docker-ce-cli
No match for argument: containerd.io
No match for argument: docker-buildx-plugin
No match for argument: docker-compose-plugin
Error: Unable to find a match: docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

I followed this link just to see what it shows https://download.docker.com/linux/fedora/2023.6.20241212/x86_64/stable/repodata/repomd.xml

Looks like the package is unavailable.

So I decided to install it using Binaries or Manual Installation. You can check it here https://docs.docker.com/engine/install/binaries/

Or you can follow what i did (it’s just the same actually 😀):

Check the version you need at https://download.docker.com/linux/static/stable/

As of this writing the version is 27.4.1

Bash
// Download 
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-27.4.1.tgz -o docker.tgz

// Extract
tar xzvf docker.tgz

// Move the files
sudo mv docker/* /usr/bin/

// Starts the daemon, runs it in the background
sudo dockerd &

// Check docker version 
docker --version

// Check if it is correctly installed
Docker run hello-world

That’s it!

Automate Background Tasks with Linux Service and Timer

What is a Linux Service? It is a program that runs in the background without user interaction. It usually stays running even after a computer reboot. An example is daily backing up a database from a production server. You run a task in the background that dumps the whole database and saves it to a computer.

For example, I will empty the trash on an Ubuntu desktop every minute.

Create a bash script to empty the trash, name it empty-trash.sh, save it in /opt.

Bash
#!/bin/bash

rm -rf /home/<username>/.local/share/Trash/*

Make it executable.

Bash
sudo chmod +x /opt/empty-trash.sh

Create the service file empty-trash.service in /etc/systemd/system as root.

Bash
sudo touch /etc/systemd/system/empty-trash.service

Next is to copy and paste this to the empty-trash.service file.

[Unit]
Description=Empty trash every minute

[Service]
ExecStart=bash /opt/empty-trash.sh
User=<username>

[Install]
WantedBy=multi-user.target
  • The [Unit] section holds the description of the service file.
  • The [Service] section tells how the service should run
    • ExecStart directive is where we specify the command that we want to run which is the bash /opt/empty-trash.sh.
    • The User directive specifies the account under which the script will execute.
  • The [Install] section defines how systemd should manage the service during system startup or when it is enabled.
    • WantedBy with a value of multi-user.target means it will be linked to the system’s boot process.

Create a timer file empty-trash.timer in /etc/systemd/system as root.

Bash
sudo touch /etc/systemd/system/empty-trash.timer

Next is to copy and paste this to the empty-trash.timer file.

[Unit]
Description=Run empty-trash service every minute

[Timer]
OnUnitActiveSec=1min
Persistent=true

[Install]
WantedBy=timers.target
  • The [Unit] section holds the description of the timer file.
  • The [Timer] section holds the configuration of the scheduling of the timer
    • OnUnitActiveSec directive means that the timer will trigger on the scheduled time
    • Persistent=true means the timer will compensate for the missed schedule if the system is powered off.
  • The [Install] section specifies how the timer will connect to the system
    • WantedBy=timers.target means the timer will be added to timers.target. timers.target organizes and starts all timers.

To modify the time, change the value of OnUnitActiveSec.

Run the command below to let the system know of a new service:

Bash
sudo systemctl daemon-reload

Run the commands below to start the services:

Bash
sudo systemctl start empty-trash.service
sudo systemctl start empty-trash.timer

Run the commands below if you want it to enable the service at startup:

Bash
sudo systemctl enable empty-trash.service
sudo systemctl enable empty-trash.timer

Run the commands below if you want to check the status:

Bash
sudo systemctl status empty-trash.service
sudo systemctl status empty-trash.timer

Run the commands below if you want to stop the services:

Bash
sudo systemctl stop empty-trash.service
sudo systemctl stop empty-trash.timer

Now, you can check the trash from time to time to see if it empties.

Github Gist: https://gist.github.com/rinavillaruz/eb4b5230d5bb0fbded2e916ad0ca189c