Skip to content

Instantly share code, notes, and snippets.

@mlgrm
Last active March 24, 2023 23:29
Show Gist options
  • Save mlgrm/cf39624556556876666fc81e0b71da26 to your computer and use it in GitHub Desktop.
Save mlgrm/cf39624556556876666fc81e0b71da26 to your computer and use it in GitHub Desktop.

mlgrm's run ubuntu in crostini

this gist is out of date and remains here only for reference

This is just a modification of this reddit to minimize copying and pasting, make it less interactive, and to allow creation of a username of your choice instead of the default google email address.

# #How to run Ubuntu with full Chrome OS Integration
# Here's a post that shows in detail how to make the default penguin container run Ubuntu instead of Debian:
# [Introduction to Crostini - Part 3: Using Ubuntu by default](https://linuxiumcomau.blogspot.com/2018/08/introduction-to-crostini-part-3-using.html)

# ## Cheat Sheet
# The above post describes how to set up Ubuntu from another computer, and how to run a full desktop environment under Ubuntu.  If you just want to run Ubuntu as your default container on Crostini, with full Chrome OS integration including files and launcher icons, this section is for you.

# This "cheat sheet" contains the relevant info from the above post for installing Ubuntu 18.04 as the default container (penguin) directly on a Chrome OS device which already has Crostini enabled.  The steps are divided into logically related blocks which can be copied and pasted into a terminal window (paste into a terminal window by right-clicking in the window).  After pasting, you may have to press the **enter** key to run the last command in a block.

from crosh:

# ### Create the Ubuntu container

# Start by entering the Chrome shell (crosh) by pressing CTRL+ALT+T, then enter the default termina VM:

vmc start termina

from termina

set -e
# Rename the default penguin container:

lxc stop penguin --force
lxc rename penguin debian

# Create a new Ubuntu container named penguin:

lxc launch ubuntu:18.04 penguin

# Enter the new container (as root):

lxc exec penguin -- bash

from penguin (as root):

set -e
# ### Capture group membership for default **ubuntu** user, then delete user

# Create a little script which we will use later to add your username to all the default Ubuntu groups, then delete the default **ubuntu** user:

groups ubuntu >update-groups
sed -i 'y/ /,/; s/ubuntu,:,ubuntu,/usermod -aG /; s/$/ \$NEW_USER/' update-groups
killall -u ubuntu || 2>&1 echo "killall: no processes killed"
userdel -r ubuntu
sed -i '/^ubuntu/d' /etc/sudoers.d/90-cloud-init-users

# ### Install Crostini packages

# Prepare for installing Google's Crostini specific packages.  First bring Ubuntu up to date:

apt-get update
apt-get -y upgrade < /dev/null

# Now add the Crostini package repository to **apt**.  This repository provides the Linux integration with Chrome OS:

echo "deb https://storage.googleapis.com/cros-packages stretch main" > /etc/apt/sources.list.d/cros.list
if [ -f /dev/.cros_milestone ]; then sudo sed -i "s?packages?packages/$(cat /dev/.cros_milestone)?" /etc/apt/sources.list.d/cros.list; fi
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551
apt-get update 

# A work-around is needed for a **cros-ui-config** package installation conflict.  First, install binutils to get the **ar** command:

apt-get -y install binutils < /dev/null

# Then create the **cros-ui-config** work-around package:

apt-get -y download cros-ui-config < /dev/null # ignore any warning messages
ar x cros-ui-config_0.12_all.deb data.tar.gz
gunzip data.tar.gz
tar f data.tar --delete ./etc/gtk-3.0/settings.ini
gzip data.tar
ar r cros-ui-config_0.12_all.deb data.tar.gz
rm -rf data.tar.gz

# Now install the Crostini packages and the "work-around" package, ignoring any warning messages.  This will take awhile:

apt-get -y install cros-guest-tools ./cros-ui-config_0.12_all.deb < /dev/null

# Delete the "work-around" package:

rm cros-ui-config_0.12_all.deb

# ### Finishing up

# Install the **adwaita-icon-theme-full** package.  Without this package, GUI Linux apps may have a very small cursor:

apt-get -y install adwaita-icon-theme-full < /dev/null

# Now, shut down the container:

shutdown -h now 

Reboot Chrome OS and start the Terminal application from the launcher. If it fails to start the first time, try again and it should work. Once it launches, the default username (your gmail or g suite account name) will be created.

from crosh

Now we need to change the name to our (presumably) shorter desired username.

vmc start termina

from termina

lxc start penguin
lxc exec penguin -- bash

from penguin (as root)

First set the variable NEW_USER to the username you'd like

set -e
NEW_USER=${NEW_USER:-mlgrm}
OLD_USER=$(getent passwd 1000 | cut -d: -f1)
mv /home/$OLD_USER /home/$NEW_USER
pkill -u $OLD_USER
usermod -l $NEW_USER -d /home/$NEW_USER $OLD_USER
groupmod -n $NEW_USER $OLD_USER
source update-groups
rm update-groups
# we need the old user to exist on the system or terminal won't start.
useradd -m $OLD_USER
usermod -aG chronos-access,android-everybody $OLD_USER
shutdown -h now

Now start a terminal again

from penguin (as $NEW_USER)

# Now **touch** a file using the name of the OS.  This can be a reminder of which container you are in if you work with more than one container:

touch ubuntu-18.04

# Launch the **Files** Chrome OS app and look under Linux Files.  You should see the file you touched above.

# ### Keeping the Crostini packages up to date

# Google's Crostini packages are tied to Chrome OS major versions.  When Chrome OS updates to a major new version number, for example from CrOS 73 to CrOS 74, you should run these commands to update the Crostini packages too.  First, update the version number in the **cros.list** package file (after editing, save with ctrl-s and exit with ctrl-x):

sudo nano /etc/apt/sources.list.d/cros.list # update the version number, then save with ctrl-s and exit with ctrl-x

# Then update the Crostini packages:

sudo apt update
sudo apt upgrade

# ### Other releases

# These instructions have been tested to work for Ubuntu 18.10 and 19.04.  Just replace 18.04 with 18.10 or 19.04 in the instructions above.

# That's it!  Many many thanks to [linuxiumcomau](https://linuxiumcomau.blogspot.com), whose awesome [blog post](https://linuxiumcomau.blogspot.com/2018/08/introduction-to-crostini-part-3-using.html) is the basis for this wiki article.
@romanwrites
Copy link

what could I do if on the first step:
vmc command not found?

@mlgrm
Copy link
Author

mlgrm commented May 28, 2020

that looks like a bash error, so you must already be in the terminal. you need to be in crosh to use vmc. just open your browser and press ctrl-alt-T. But this gist needs to be updated. i suggest you follow the source instructions instead: https://www.reddit.com/r/Crostini/wiki/howto/run-ubuntu

@romanwrites
Copy link

romanwrites commented May 28, 2020

it also starts with the same step on the given link.

I wasn't at shell. i run this command while in crosh. And have this error
maybe it's something because of an old chromeOS? It stopped to autoupdate a couple of years ago. the model is acer720

@mlgrm
Copy link
Author

mlgrm commented Jun 9, 2020

oh, yes. that's definitely going to be a problem. crostini is under active development and certainly won't work on very old versions of chromeOS. at the same time, crosh has a different error message than command not found

crosh> vmd
ERROR: unknown command: vmd

@bjmcgill
Copy link

Hi I just bought an asus chromebook the other day, and I would really like to learn how to run ubuntu in crostini. The version of chrome os I am using is 83.0.4103.07, which i think is the most recent.

I managed to get libre office and gnucash working. but i don't think either of them recognises my hp color laser jet cp1514n, which i connected to a usb port. i had no problems printing stuff in google docs (in chrome os). I installed them using sudo apt update, sudo apt dist-upgrade, sudo apt install etc. I had problems with the keyserver, but I eventually sorted that out. I tried googling and installing various tools in crostini to get it to recognise my printer without any luck.

I think if I can get ubuntu installed, the tools that come with it will let me add a printer, no probs. Plus i would really like to mess around with ubuntu.

I am a charity trustee, so getting gnucash, and libreoffice printing would be very useful. I still have a windows laptop I can use for this, but its very slow.

I tried executing the commands at the top of the page, but when i got to

lxc launch ubuntu:18.04

I got the message container name is brief-stallion. then when i tried

lxc exec penguin -- bash

i got the message error not found and it kicked me into crosh. I then tried

vmc start termina
lxc exec brief-stallion

and it seemed to work. so I continued up to

killall -u ubuntu etc..

and I got the message no processes killed. I wasn't sure if the recipe was working at this stage. I continued with

userdel -r ubuntu

and got the message

ubuntu mail spool (/var/mail/ubuntu) not found

I think something must have gone wrong at this point. If you could help me at this point I would be very glad. I'll try and keep my terminal open so I can continue when I get a response. Have patience with me, I'm new to linux

@bjmcgill
Copy link

is there any chance google will offer the option of installing ubuntu at the touch of a button when linux ceases to be a beta option? I can't see how thats going to be any problem for them.

@bjmcgill
Copy link

I've just discovered all my linux apps have disappeared along with a huge chunk of disk space. Forget all the above, I'm just going to turn off linux (beta) and so delete all the containers.

I tried to bite off more than I could chew. I'm going to stick to google docs from now on :)

Brian.

@mlgrm
Copy link
Author

mlgrm commented Jul 1, 2020

yeah, linux on chrome os is still pretty bare bones. i'd suggest sticking with the default debian linux if you don't want to mess around with all the configuration. that's not (as) likely to get broken by an update. but you should always back-up your data on drive or in the downloads directory. i've lost lots through updates.

@DarkevilPT
Copy link

Bro I am trying to do this on FydeOS and I can't get this part to work at all:

apt-get -y download cros-ui-config < /dev/null # ignore any warning messages
ar x cros-ui-config_0.12_all.deb data.tar.gz
gunzip data.tar.gz
tar f data.tar --delete ./etc/gtk-3.0/settings.ini
gzip data.tar
ar r cros-ui-config_0.12_all.deb data.tar.gz
rm -rf data.tar.gz
root@penguin:~# apt-get -y install binutils < /dev/null
Reading package lists... Done
Building dependency tree       
Reading state information... Done
binutils is already the newest version (2.30-21ubuntu1~18.04.8).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@penguin:~# 
root@penguin:~# # Then create the **cros-ui-config** work-around package:
root@penguin:~# 
root@penguin:~# apt-get -y download cros-ui-config < /dev/null # ignore any warning messages
E: **Unable to locate package cros-ui-config**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment