Installing Debian Bullseye and VirtualBox on a Mac Mini

Mac Mini on a black mat on grey carpet, with a small screen attached, displaying the Debian installer

Goal

Get Debian Bullseye and VirtualBox running on an older (2012) Mac Mini.

Installing Debian Bullseye

This was very easy.

As in “plug in the installation medium, boot with Option key held down, select installation medium, and follow the onscreen prompts” easy.

I used the netinst image, and it complained about lack of some firmware. So I fixed it:

As I am using this as a server, I have not tested things like audio or Wi-Fi, as I do not need them. I cannot say whether they work or not, but the installation of the non-free firmware may have done the trick if they were not otherwise working.

When I had it up and running, I did my usual Debian-not-on-a-Raspberry-Pi LUKS setup, with dropbear-ssh.

I also disabled suspend and hibernate, since I do not want these:

systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

One thing on my list still to sort is to have the machine start automatically if there’s a power failure. (Update: done.)

VirtualBox

I know, I know, there are better virtualisation tools than VirtualBox.

But:

So VirtualBox it is. For now.

Installing VirtualBox was a bit of a pain, as I could not use apt. (For now, at least.)

I used the “other Linux” installer instead.

It complained about bindings, so I ran:

apt install python2.7 -y

And then ran the installer again.

That worked.

I had to make a tweak to the .vbox file from the donor machine, to get the correct reference for the ethernet interface. For the first one, I used the GUI, and then copied-and-pasted for the subsequent VMs.

I registered it with VirtualBox with:

VBoxManage registervm /full/path/to/the/.vbox/file

To start VirtualBox on boot, and to start the VMs automatically, I followed this guide. It worked.

The gist is:

Add a systemd config file (below) to /etc/systemd/system/vbox_vm_start@.service, replacing [myusername] with the name of the user account which will run this.

  [Unit]
  Description=VirtualBox VM %I
  After=network.target vboxdrv.service
  Before=runlevel2.target shutdown.target

  [Service]
  User=[myusername]
  Group=vboxusers
  Type=forking
  Restart=no
  TimeoutSec=5min
  IgnoreSIGPIPE=no
  KillMode=process
  GuessMainPID=no
  RemainAfterExit=yes

  ExecStart=/usr/bin/VBoxManage startvm %i --type headless
  ExecStop=/usr/bin/VBoxManage controlvm %i acpipowerbutton

  [Install]
  WantedBy=multi-user.target

Find the name of the vm you want to start automatically:

VBoxManage list vms

This showed nothing for me, which I did not understand, but I knew its name anyway.

Enable it (so that it starts on boot):

systemctl enable vbox_vm_start@[vm_name]

Start it now:

systemctl start vbox_vm_start@[vm_name]

Check it is working:

systemctl start vbox_vm_start@[vm_name]

But haven’t you ruined a perfectly good Mac Mini?

I’m not sure installing Debian on anything counts as “ruining” it.

But, more seriously, no. I have not ruined it, so much as breathed new life into it.

I have a few Mac Minis, all of which have performed admirably. I’ve stuffed them full of RAM, put SSDs in them (or else using SSDs over USB), and they’ve been great.

They all get security updates, for now, but it can only be a matter of time before this changes. None can run the latest macOS.

I’d be more comfortable if, even though they are getting security updates, they had an up to date operating system on them.

And, since I do not need anything specific to macOS, running Debian on some of them instead makes sense to me. (The others will likely be retired for now.)

It also means I can overcome two nuisances:

In any case, I haven’t touched the macOS installation, and instead I’m booting Debian from an SSD over USB.

Outcome

Goal achieved, albeit with more testing needed.

It was a fun, simple project.

The longest part — for which you do not need to be in front of a screen or terminal — is syncing VirtualBox disk images (.vdi files) from one machine to another.