This beginner-friendly guide walks you through enabling the Linux development environment on ChromeOS, adding swap space to support limited memory, and running the gemma:2b AI model locally using Ollama.

> Note: An 8 GB Chromebook can run small local language models, but memory is tight. The swap space created in this guide helps reduce the risk of crashes, although performance may be slower than on a machine with more RAM.

> Intel Chromebooks: Intel processors typically have faster processors and more memory than Chromebooks with AMD processors. This can improve the performance of the Linux development environment and running the gemma:2b model.


Prerequisites

Before you begin, make sure you have:


Phase 1: One-Time Initial Setup

Step 1: Enable the Linux Development Environment

  1. Open your Chromebook’s Settings.
  2. In the left sidebar, click Advanced/About ChromeOS.
  3. Select Developers.
  4. Next to Linux development environment, click Turn On.
  5. When prompted to allocate disk space, assign at least 20 GB.
  6. Follow the on-screen instructions.
  7. Wait for the Linux Terminal to launch automatically.

Step 2: Update Linux and Install Dependencies

In the newly opened Linux terminal, update your package lists and install the zstd compression tool:

bash

sudo apt update && sudo apt install zstd -y


Step 3: Configure Btrfs-Friendly Swap Space

Because 8 GB of RAM is tight for running LLMs, create 4 GB of swap space. Swap space uses storage on your SSD as virtual memory and can help prevent system crashes.

ChromeOS Linux uses the Btrfs file system, so the swap file must be created carefully. In particular, Copy-on-Write must be disabled before allocating the swap file.

Run the following commands in order:

bash

Create an empty swapfile

sudo touch /swapfile

Disable Copy-on-Write (required for Btrfs)

sudo chattr +C /swapfile

Allocate 4GB of space to the file

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

Set secure permissions, format, and activate the swap space

sudo chmod 0600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile

To verify that swap is active, run:

bash

free -h

Look for around 4.0Gi in the Swap column.

> Caution: Swap uses your SSD and is slower than RAM. It is useful on low-memory systems, but it may affect performance while the model is running.


Step 4: Install and Run Ollama

Install Ollama

bash

curl -fsSL https://ollama.com/install.sh | sh

Download and run Gemma 2b

bash

ollama run gemma:2b

Ollama will download the model the first time you run this command. After the download finishes, the model should start in your terminal.


Phase 2: Daily Usage for Future Sessions

ChromeOS deactivates manual swap files whenever the Linux environment shuts down.

Every time you completely close and reopen your Linux Terminal, reactivate your swap space before running the model.


Step 1: Reactivate Swap Space

Run:

bash

sudo chmod 0600 /swapfile

sudo swapon /swapfile

Optionally, verify that swap is active:

bash

free -h


Step 2: Launch the Model

Run:

bash

ollama run gemma:2b

You are now ready to use Gemma 2B locally (no internet required) on your Chromebook.