Setting Up a VM on a Mac (ARM chips) ==================================== .. danger:: Perform these steps only if you have a Macbook with a ARM (m{1-4}) chip. Otherwise use `VirtualBox `_ instead. Download the reference VM image ------------------------------- Download the reference VM image from `this link `_. We use this image for the course. TAs might not be able to help if you use other VM images prepared by yourself. The image contains Ubuntu 24.04.1 LTS 64 bit. The default user of the VM image is ``student``. The password for the user is also ``student``. Installing the VM on Mac ------------------------ If you have a Mac with a modern chip, VirtualBox will not work as the underlying architecture is different (ARM vs x86_64). To overcome this problem you will have to use another hypervisor which is `qemu `_. Note that qemu is used as an emulator (it emulates another architecture) therefore it **will be slower** than using VirtualBox for x86. First, you must install ``brew`` and ``qemu``. Open a terminal and run the following command: .. code-block:: bash $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" Once ``brew`` is installed, run the following command in the same terminal:: $ brew install qemu .. note:: Do not copy the dollar sign. It is a convention to indicate that the command should be run in a terminal. Go to the folder which contains the "ubuntu.zip" and run the following commands:: $ unzip ubuntu.zip $ qemu-img convert -f vdi -O qcow2 ubuntu-server.vdi ubuntu-server.qcow2 .. warning:: You can delete the .vdi file but be careful do not to delete the .qcow2 image! Finally, run the following command:: $ qemu-system-x86_64 ubuntu-server.qcow2 -m 2G -netdev user,id=mynet0,hostfwd=tcp::6543-:22 -device e1000,netdev=mynet0 You have to wait a few **seconds/minutes** before the machine boots completely. Once fully booted, you must enter your credentials (the password is "student"). Once you have logged on to the system, you need to run the following commands: .. code-block:: bash $ sudo loadkeys be # Change the keyboard layout to Belgian $ ip addr show # Do not execute the next commands, if you see a valid IP address assigned to your interface $ sudo dhclient -v ens3 $ sudo apt update # To check if network is working, this command will be explained later If you do not see any errors, everything is working on your side and you can move on to the next step. Connect to the VM by ssh ------------------------ Then open a terminal and enter the following commands:: $ ssh student@127.0.0.1 -p 6543 The VM will ask your password. Use the "student" credentials. Note that if you are using Windows, you can use PowerShell or CommandPrompt or `putty `_. Update package information -------------------------- Finally, enter the following command on your terminal app after connecting to the VM by ssh:: $ sudo apt update In a nutshell, this command updates the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories. - ``sudo`` means "superuser do" and is used to run commands with administrative privileges. - ``apt`` is the packet manager for some Linux distributions, including Ubuntu. You can see it as the equivalent of the "Google Play Store" or "App Store" for Linux. - ``update`` is the parameter for the ``apt`` command. Note that, ``apt update`` does not actually install new versions of software. After running this command, you can install apps/utilities via the ``apt install`` command:: $ sudo apt install gcc make bison flex libncurses-dev openssh-server git curl wget bc .. danger:: NEVER upgrade the kernel of the VM. The kernel version is 5.8.0-53-generic. If you upgrade the kernel, you may face issues with the project. General usage of the VM ----------------------- Since you do not need one for this course, no graphical interface is installed on the VM. You will have to use the command line interface (CLI) to interact with the VM. The next tutorial (next week) will explain how to use the CLI in more details. This week, you will only learn the basic commands. Here are some tips to help you: - When you will launch a program in the foreground, you won't be able to use the terminal until the program is finished. This can be quite annoying. For example when writing code, you will need to stop your editor each time you want to compile and/or execute your code. Fortunately, you are not limited to a single terminal. You can open as many terminals as you want and open as many ``ssh`` connections as you want. - To kill a program running in the foreground, you can sometimes use ``Ctrl+C``. - To shut down the VM, you can use the following command:: $ sudo shutdown now - If you simply want to exit the ``ssh`` connection without shutting down the VM, you can press ``Ctrl+D`` or type the following command:: $ exit