Aug 06, 2021 • 2 min read
Setting up ChromeOS Virtual Machine
ChromeOS can create multiple virtual machines to run various software. Creating a new virtual machine allows for software to be tested without ruining your existing setup. It is also great for running programs in an isolated fashion. In this blog post learn how to Create a new virtual machine in ChromeOS.

Introduction
- Create a virtual machine
- Create a Ubuntu container
- Create a user account
- Setup SSH
Create a virtual machine
- In a browser press
CTRL+ALT+Tto open the Chrome OS developer shell (i.e. chrome-untrusted://crosh) - Create a new VM
vmc start sandbox
- Create a new profile A profile enable the default settings to be altered.
lxc profile copy default custom-profile
- Update the profile setting
lxc profile set minikube-profile security.nesting true
lxc profile set minikube-profile security.priviledged false
Create a Ubuntu container
LXC supports a number of images in the following section Ubuntu is used. To see a list of available images:
lxc image list images:
- Create a new container based on Ubuntu 18.04
lxc launch image:ubuntu/bionic sandboxvm --profile custom-profile
- Create a new container based on Ubuntu 18.04
lxc launch image:ubuntu/bionic sandboxvm --profile custom-profile
- Check the status of the container
lxc list
Note: This screen shows the state of the container. The IP used to access the machine can be seen here.
- Run the new Ubuntu container
lxc exec sandboxvm /bin/bash
Create a user account
- Add an account (ie. substitute USERNAME with the account name to be used)
useradd -m [USERNAME]
- Set a password for the account
passwd [USERNAME]
- Add user to sudo group
usermod -aG sudo [USERNAME]
- Note the USERID and GROUPID assigned to the USERNAME
cat /etc/passwd
Setup SSH
If a remote SSH connection is required then this needs to be setup on the local and remote hosts.
- On the local host VM, generate an SSH key
ssh-keygen
- Display the ssh key generated
cat ~/.ssh/id_rsa.pub
- On the remote host set up the SSH user
mkdir -p /home/[USERNAME]/.ssh
chmod 700 /home/[USERNAME]/.ssh
touch /home/[USERNAME]/.ssh/authorized_keys
chmod /home/[USERNAME]/.ssh/authorized_keys
- Paste the generated key into the authorized_keys file e.g.
echo "[SSHKEY]" >> /home/[USERNAME]/.ssh/authorized_keys
Connect via SSH
- Get the IP of the container via the LXC screen
- Connect via SSH
ssh [USERNAME]@[IP]
Connect via LXC
- Login as root
lxc exec sandboxvm /bin/bash && cd
- Login as a specific user and use their home directory
To connect as a specific user:
- USERID
- GROUPID
- USERNAME
lxc exec sandboxvm --user [USERID] --group [GROUPID] --cwd [USERID] --env HOME=/home/[USERNAME] /bin/bash && cd