Updates
In order to get the machine ready to do virtualisation you need to install a few updates to the Operating System as well as some tools that help to interact with the programming platform. Things are a lot more complicated for Windows users here than for Mac (or Linux) users.
System Updates
Before going any further, please ensure that your computer is fully up-to-date with all Operating System and application updates before following any of the other steps in this brief guide to getting started.
Base Utilities
In order to access the majority of the features that this module uses, you will need to install several ‘base’ utilities:
You need the Xcode Command Line Tools installed on your Mac. In some cases this may have already been installed, but it’s the same process to check as to install:
- Open the
Terminal
application (which can be found underUtilities
in yourApplications
folder). - Type the following:
xcode-select --install
and then hit Enter (⏎)
Unless you get an outright error you can proceed to the next step:
- Although not strictly necessary, you’ll eventually want the Homebrew package manager, which can also be installed directly from the Terminal.
You first need to check that virtualisation is enabled on your computer. This is under Windows Features
where you need to make sure that the following options are ticked:
Virtual Machine Platform
Windows Hypervstor Platform
- If you have to change these settings then you then need to restart your machine.
You then need to install WSL2 but, strangely, you do not actually need to install a full Linux O/S, so as far as we can tell this means you only need to run the following commands in the Windows PowerShell
:
wsl --install
should quickly install the subsystem that we need.
That should be it: Podman (and Docker) should now run without complaint.
- There is good guidance from Microsoft for Windows 11 and more recent ‘builds’ of Windows 10.
- There are also older instructions for Windows 10.
Common installation errors are covered here.
Finally, if you are still being told that you can’t install WSL2 and Linux, then the most likely cause of this issue is a setting in the BIOS of the computer itself. There are a couple of settings that need changing at a very low level to enable Hyper-V virtualisation. I would start by following this MS guide and, if there is still a problem, check this blog post.
Windows Only (Optional)
This next part is completely optional for those who want to go further with Linux and WSL. You do not (normally) need to do all this to just get Podman or Docker running.
If you want to install a full Linux distribution (e.g. because you want to do more than just run Docker) then make sure you set up a new Linux
user and do not end up running everything as root
.
To make full use of WSL2 and Linux (if you want to do more than just use Docker) you will need to familiarise yourself with how having two operating systems that can talk to each other works. That is covered in the next section. This will actually be useful for understanding how Docker works, as it can be profoundly confusing.
The behaviour of the ‘shell’ (command line) is quite confusing because, with WSL2, you effectively end up with two ‘home’ directories: one for your Windows user, and one for your new Ubuntu user. Starting a Linux shell/command line puts you in your Linux home directory (the username may be completely different from your Windows username). Starting a Windows shell/command line puts you in your Windows home directory (again, the username may be completely different from your Linux username).
So the first, and perhaps most important, thing is understanding where ‘data’ is being stored:
- Under Linux the user directory is apparently something like:
\\wsl$\<DistroName>\home\<UserName>\
but you can usually get it by simply typingcd $HOME
and thenpwd
when starting a new Linux shell. - Under Windows the user directory is:
C:\Users\<UserName>\
or/mnt/c/Users/<UserName>/
, and you can often simply typepwd
when opening a new Windows shell.
So these are different locations on your computer’s hard drive, and you will not see your Linux files in your Windows Home Directory and vice versa. To make it easy to switch between the two, I found this page on Microsoft’s web site that goes through some of the post-WSL2 installation steps, but see especially the additional page on Windows Terminal configuration.
Slightly confusingly, you can run Linux commands directly from Windows, usually be adding wsl
in front of the Linux command (e.g. wsl ls *.csv
from Windows, where in Linux the command would be ls *.csv
).
To make it easy to move from the Linux side of your machine to the Windows machine you can also do this:
- Work out where your CASA files are stored on the Windows side (see above:
/mnt/c/Users/<UserName>/My\ Documents/CASA/...
where<UserName>
is your Windows user name). cd
to this location and typepwd
to output the full path to the CASA directory.- Copy this.
- Now start a Linux shell and run the following command once (you do not need to do it ever again):
echo "export WIN_HOME=\"/mnt/c/Users/.../CASA/\"" >> $HOME/.bashrc
. Replace the...
with the rest of the actual path! The\"
is very important, don’t try to change those! - Now run
source .bashrc
and you should see no errors.
Once you have done this you will have added a single line to your .bashrc
file in Linux. This will create a ‘shortcut’ for bash in Linux. From here on out you should be able to type cd $WIN_HOME
and move immediately over to the CASA
directory on the Windows side. This will save having to remember (and type) the Windows path each time.