-
Notifications
You must be signed in to change notification settings - Fork 0
Setup Multipass VM
Now that all the software is installed, we need to create and configure the VM. After this step you should be ready to do the assignments.
We have prepared a Cloud-init file that will install and setup everything you need inside the VM. To create the VM run the command:
multipass launch 24.04 --name wasp --cpus 4 --memory 4G --disk 12G --timeout 1800 --cloud-init https://raw.githubusercontent.com/KTH-RPL/wasp_autonomous_systems/ht25/wasp.yamlThis will create a VM using Ubuntu 24.04 as base, with name wasp, 4 CPUs, 4 GB of memory, 12 GB of disk, maximum initialization time of 30 minutes (1800 seconds), and using the Cloud-init wasp.yaml file. You can of course change these values. We recommend at least 12 GB of disk.
It is possible to change number of CPU(s), memory, and disk afterwards as well.
Delete the one you created above:
multipass delete --purge waspInstall "manually" using the commands:
multipass launch 24.04 --name wasp --cpus 4 --memory 4G --disk 12G --timeout 1800
multipass exec wasp -- bash -c "curl -L https://raw.githubusercontent.com/KTH-RPL/wasp_autonomous_systems/ht25/setup.bash | bash"If you get a launch failed message, such as:
launch failed: The following errors occurred:
timed out waiting for initialization to complete
you do not have to worry. This is caused by a shortcoming of how Multipass and Cloud-init can interact. It means that Multipass is done with its part, but the Cloud-init setup is still ongoing. You can run the Cloud-init command inside the wasp VM to wait for it to finish:
multipass exec wasp -- cloud-init status --waitIf the above command failed with the output:
launch failed: The Hyper-V Windows feature is disabled. Please enable by using the following
command in an Administrator Powershell and reboot:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Do as told and then retry above command after the reboot (see more here from Microsoft's guide on how to enable Hyper-V).
Check that Cloud-init has finished by running the command:
multipass exec wasp -- cloud-init status --waitIf you see status: done at the end, then everything is good. Next, you should check that everything has been built and installed by running the command:
multipass exec wasp -- cat setup.logif the output is (disregarding the time furthest to the right on each line):
Created ~/.config directory: PASS ✅ [0 s]
Cloning course repository: PASS ✅ [24.26 s]
Created Python virtual environment: PASS ✅ [2.53 s]
Activated Python virtual environment: PASS ✅ [0 s]
Installed PIP packages: PASS ✅ [70.44 s]
Downloaded and exported YOLO models: PASS ✅ [39.40 s]
Built ROS workspace: PASS ✅ [112.79 s]
Installed course Assignment 1: PASS ✅ [0 s]
Installed course Assignment 2: PASS ✅ [0 s]
Installed course Assignment 3: PASS ✅ [0 s]
Installed course Assignment 4: PASS ✅ [0 s]
Downloaded rosbags: PASS ✅ [0 s]
Verified downloaded rosbags: PASS ✅ [2.73 s]
i.e., all steps have PASS ✅, then everything is as it should and you can continue. If something says WAIT ⚠️, you need to wait for it to finish; however, if you still see WAIT ⚠️ after running the command multipass exec wasp -- cloud-init status and it returns status: done, then something failed during the setup which caused it to not attempt to do all the steps. If you see FAIL ❌, then that means the step failed.
The easiest solution if you see FAIL ❌ or WAIT ⚠️ even after running the command multipass exec wasp -- cloud-init status and it returns status: done, is to retry the process. You can do so by first deleting the VM:
multipass delete --purge waspand then redo the instructions from the start of this page. If it still fails after you have tried three times, please contact a course responsible. Include the output of the command:
multipass exec wasp -- cat setup.logand the two Cloud-init log files (cloud-init.log and cloud-init-output.log) stored inside the VM. You can transfer them from the VM to your host OS by running the command:
multipass transfer wasp:/var/log/cloud-init.log wasp:/var/log/cloud-init-output.log <destination>where <destination> is a directory where you want the files to be placed. So for example, if you want to place it in the folder where you terminal is currently open, you write:
multipass transfer wasp:/var/log/cloud-init.log wasp:/var/log/cloud-init-output.log .where . means current directory.
During the setup of the VM a lot of packages were installed. To ensure all of them work as expect, it is recommended to restart the VM.
To check if a restart is required, run the command:
multipass exec wasp -- sudo DEBIAN_FRONTEND=readline needrestart -r l -q -m u -vThe output of the command will tell you if a restart is required and for what reason. Regardless what the output is, we recommend that you restart the VM.
You can restart the VM by running the commands:
multipass stop wasp
multipass start waspDo not use the multipass restart wasp command as it can cause problems on at least macOS (see: https://github.com/canonical/multipass/issues/3642).
When it has booted up again (should only take 10-20 seconds), you can run (again):
multipass exec wasp -- sudo DEBIAN_FRONTEND=readline needrestart -r l -q -m u -vIf everything is as it should, you should see no output. If you instead see:
exec failed: ssh connection failed: 'Socket error: Connection reset by peer'then it is still starting, so you need to wait a little longer.
You can check the status of the VM by running:
multipass info waspit will say something like this (note State: Starting) when it has not yet started.
Name: wasp
State: Starting
Snapshots: 0
IPv4: 192.168.64.5
Release: Ubuntu 24.04.3 LTS
Image hash: 834af9cd766d (Ubuntu 24.04 LTS)
CPU(s): 4
Load: 0.37 0.11 0.04
Disk usage: 8.8GiB out of 11.5GiB
Memory usage: 402.7MiB out of 3.8GiB
Mounts: --
When it has started state will change to Running.
For some of the communication between the host (your OS) and the guest (the VM) a shared directory is needed. The shared directory will be accessable from both the host (your OS) and the guest (the VM). We will use this directory for Webots communication and to share a couple of Rosbags.
To do this, you first need to enable the Multipass mount command (on Linux and macOS it is enabled by default and on Windows it is disabled by default):
multipass set local.privileged-mounts=YesPlease read and be aware of the security considerations of mounts.
Once mount is enabled, create a directory in your home directory that will be the shared directory (we experienced problems with the mount if the shared directory was not directly in our home directory). We will refer to this directory (the absolute path to it) as <SHARED_DIR>. Second, run the following command to mount the shared directory and make sure to change the <SHARED_DIR> with the path to the directory that you just created:
multipass mount --type classic "<SHARED_DIR>" wasp:/home/ubuntu/sharedmake sure to keep the quotes (i.e., the '"' characters) if your path contains whitespace(s).
An example could be to do
cd ~
mkdir wasp_shared
multipass mount --type classic "wasp_shared" wasp:/home/ubuntu/sharedRun the command:
multipass info waspand make sure you see the mounted shared directory after Mounts:. It can look something like this:
Name: wasp
State: Running
Snapshots: 0
IPv4: 10.219.89.116
Release: Ubuntu 24.04.3 LTS
Image hash: 834af9cd766d (Ubuntu 24.04 LTS)
CPU(s): 4
Load: 0.00 0.00 0.03
Disk usage: 8.7GiB out of 11.5GiB
Memory usage: 566.6MiB out of 3.8GiB
Mounts: /home/dduberg/wasp_shared => /home/ubuntu/shared
UID map: 1000:default
GID map: 1000:default
Name: wasp
State: Running
Snapshots: 0
IPv4: 192.168.65.77
Release: Ubuntu 24.04.3 LTS
Image hash: 6177a7958f01 (Ubuntu 24.04 LTS)
CPU(s): 4
Load: 0.07 0.02 0.00
Disk usage: 8.2GiB out of 11.5GiB
Memory usage: 317.0MiB out of 3.8GiB
Mounts: /Users/dduberg/wasp_shared => /home/ubuntu/shared
UID map: 501:default
GID map: 20:default
Name: wasp
State: Running
Snapshots: 0
IPv4: 172.29.34.222
Release: Ubuntu 24.04.3 LTS
Image hash: 834af9cd766d (Ubuntu 24.04 LTS)
CPU(s): 4
Load: 0.30 0.15 0.05
Disk usage: 8.7GiB out of 11.5GiB
Memory usage: 464.5MiB out of 3.8GiB
Mounts: C:\Users\Daniel Duberg\wasp_shared => /home/ubuntu/shared
UID map: -2:default
GID map: -2:default
To ensure the mount is working correctly you should restart the VM by running:
multipass stop wasp
multipass start waspIf you get the error:
Removing mount "/home/ubuntu/shared" from 'wasp': ssh connection failed: 'Socket error: Connection reset by peer'
The cause of this is most likely that the shared directory is not directly in your home directory. Unmount the shared directory and remove the shared directory from the VM, by running the commands:
multipass unmount wasp
multipass exec wasp -- rm -r sharedand then redo this part with a directory directly inside your home directory.
During the setup of the VM, rosbags were downloaded in compressed form in the background. To be able to use them in the assignments, you need to extract them to the shared directory (this requires around 4.5 GB of disk space on the host). We have supplied a script that will extract the files and verify them using checksums. To run it:
multipass exec wasp -- /home/ubuntu/extract_rosbags.bashThe output should be something like:
Extracting rosbags
1.69GiB 0:00:35 [48.0MiB/s] [================================>] 100%
Verifying checksums
./real_robot/metadata.yaml: OK
./real_robot/real_robot_0.mcap: OK
./real_robot/real_robot_1.mcap: OK
./real_robot/real_robot_2.mcap: OK
./real_robot/real_robot_3.mcap: OK
./kitti/metadata.yaml: OK
./kitti/kitti_0.mcap: OK
./kitti/kitti_1.mcap: OK
./kitti/kitti_2.mcap: OK
./kitti/kitti_3.mcap: OK
./kitti/kitti_4.mcap: OK
✅ Successfully extracted the rosbags! ✅
The last line should hence read ✅ Completed extraction of rosbags! ✅.
If you look in your shared directory (on the host OS and in the guest VM) you should now find a directory named rosbags with two directories inside, kitti and real_robot.
If you see the output:
┏━━━━━━━━━━━━━━━━━ PLEASE NOTE ━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Cannot find shared directory. ┃
┃ Please mount shared directory. ┃
┃ ┃
┃ Link to Wiki for instructions ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
it means that it cannot find the shared directory that you (should have) mounted earlier. Please redo the Create and Mount Shared Directory step and make sure to follow the instructions closely. After that, try extracting the rosbags again.
If you see output with the last line reading ❌ Failed to extract the rosbags! ❌, for example:
Extracting rosbags
tar: rosbags/kitti/kitti_0.mcap: Cannot write: Input/output error===> ] 91% ETA 0:00:08
1.68GiB 0:01:50 [15.6MiB/s] [===========================================>] 100%
tar: rosbags/kitti/kitti_0.mcap: Cannot close: Input/output error
tar: Exiting with failure status due to previous errors
Verifying checksums
./real_robot/metadata.yaml: OK
./real_robot/real_robot_0.mcap: OK
./real_robot/real_robot_1.mcap: OK
./real_robot/real_robot_2.mcap: OK
./real_robot/real_robot_3.mcap: OK
./kitti/metadata.yaml: OK
./kitti/kitti_0.mcap: FAILED
./kitti/kitti_1.mcap: OK
./kitti/kitti_2.mcap: OK
./kitti/kitti_3.mcap: OK
./kitti/kitti_4.mcap: OK
md5sum: WARNING: 1 computed checksum did NOT match
❌ Failed to extract the rosbags! ❌
then retry the extraction. If it still fails after three tries, contact a course responsible with the output of the command.
You will (most likely) need SSH access to the VM in order to write the code for the assignments. You have two options for how to enable SSH access.
Enabling SSH password authentication inside the VM means you will be able to SSH to it using a password. This makes it easy and convenient; however, it is not as secure as using an SSH key (option 2). To enable SSH password authentication run:
multipass exec wasp -- sh -c "sudo find /etc/ssh/sshd_config* -type f -exec sed -i -E 's/^PasswordAuthentication(\s+)no/PasswordAuthentication\1yes/g' {} \; && sudo systemctl restart ssh.service && sudo systemctl daemon-reload"To set a password, run:
multipass exec wasp sudo passwd ubuntuand enter your desired password.
Now test that you can SSH into the VM using the password.
ssh ubuntu@<VM_IP>when prompted enter the password. Change <VM_IP> to the IP of the VM, you can find it using:
multipass info waspGenerate your SSH public key (you need to find this information for your OS on your own, I can recommend looking at the Github instructions) and add it to the VM by running:
multipass exec wasp -- bash -c "echo `cat <KEY_ON_HOST>.pub` >> ~/.ssh/authorized_keys"remember to replace <KEY_ON_HOST>.pub with your key.
Now test that you can SSH into the VM using the SSH key.
ssh ubuntu@<VM_IP>you should not be prompted to enter a password. Change <VM_IP> to the IP of the VM, you can find it using:
multipass info wasp