Skip to content

Where Does Ollama Store Models? A Simple Guide to Customizing the Storage Location and Freeing Up Your C Drive! (Win/Linux/macOS)

Enjoying Ollama is great, but downloading models one after another, often several gigabytes in size, can be frustrating when your C drive space becomes scarce, right? By default, Ollama tends to store all its treasures (i.e., the downloaded models) on your C drive (or your home directory), which can be a "sweet burden" for your system disk.

Don't worry! This guide is your "C Drive Rescue Manual." We'll walk you through how to find a spacious new home for Ollama's models on the three major operating systems: Windows, Linux, and macOS, completely eliminating the problem of insufficient space!

Why bother with this? There are many benefits:

  • Free Up C Drive Space: Moving several GB or even tens of GB of data away can relieve the burden on your system disk.
  • Smoother Computer Performance: With sufficient space on your C drive, the system runs more smoothly.
  • Clearer Model Management: Having all models neatly organized in one place makes it easier to find and back them up.

Before you start, let's do some preparation:

  1. Choose a "New Home" Address: Find a hard drive partition with enough space (such as D drive, E drive, or another mount point on Linux/macOS).
  2. Create a Dedicated Folder: In the chosen location, create a folder specifically for Ollama models. For example:
    • Windows: D:\OllamaModels or E:\ai_models\ollama
    • Linux/macOS: /data/OllamaModels or /home/your_username/ollama_files
    • Super Important Tip: It's best to use a path that contains only English characters and no spaces; otherwise, you might encounter strange problems!

Ready? Let's see how to do it on different systems!

Finding a New Home for Models: Windows Edition 🏡

Windows users, look here! Ollama stores models in C:\Users\<your_username>\.ollama\models by default. We have three ways to relocate them:

Method 1: Once and For All - Get it Right During Initial Installation (Suitable for Fresh Installations)

If you haven't installed Ollama yet or plan to reinstall it, this is the easiest way!

  1. Download the Installation Package: Download OllamaSetup.exe from the Ollama official website.

  2. Install via Command Line: Open your Command Prompt (CMD) or PowerShell, use the cd command to navigate to the folder where the installation package is located. Then, execute the following command (remember to replace the path with your own!):

    powershell
    .\OllamaSetup.exe /DIR="D:\OllamaModels"

    Here, /DIR= tells the installer: "Install the files to D:\OllamaModels!"

  3. Follow the Installation Prompts: Next, follow the installation wizard. After installation, Ollama will obediently download the models to the location you specified.

This is the most popular and flexible method. By setting an "environment variable," you tell Ollama where new models should be stored.

  1. Find the "Environment Variables" Settings:

    • The quickest way: Press the Win key, search for "environment variables" directly, and select "Edit the system environment variables."
    • In the "System Properties" window that opens, click the "Environment Variables(N)..." button in the lower right corner.
  2. Create a New "System Variable":

    • In the "System variables(S)" area below, click "New(W)...".
    • Variable name: Fill in OLLAMA_MODELS (case is usually not sensitive, but uppercase is recommended).
    • Variable value: Fill in the path to your prepared new home, such as D:\OllamaModels.
    • Click "OK" to save this new variable. Then click "OK" all the way to close all settings windows.
  3. Restart the Ollama Service:

    • Find the Ollama icon in the lower right corner of the taskbar, right-click it, and select "Quit Ollama" to exit.
    • Then restart Ollama (e.g., find it in the Start menu and run it again).
    • Why restart? To allow Ollama to read the new "road sign" (environment variable) you just set.

    What is an "Environment Variable"? Simply put, it's like a global "sticky note" in the computer system. Many programs (including Ollama) will look at these "notes" to decide how to work, such as where to store files. OLLAMA_MODELS is a "sticky note" dedicated to Ollama, telling it where the model repository is.

Method 3: The Great Shift - Migrate Existing Models (Suitable for Moving Existing Models)

If you have already downloaded a lot of models and want to move them, use this method.

  1. Stop Ollama First:
    • Open Command Prompt (CMD) or PowerShell.
    • Completely close the Ollama process (just exiting the taskbar icon may not be enough):
      powershell
      taskkill /F /IM ollama.exe /T
      /F means force close, /IM specifies the program name, /T tries to close child processes. A successful prompt is good.
  2. Move!
    • Open File Explorer and find Ollama's old home: C:\Users\<your_username>\.ollama\models.
    • Copy or cut this entire models folder to your prepared new address, such as D:\OllamaModels.
    • Safety First: Before operating, it is recommended to back up the entire C:\Users\<your_username>\.ollama folder, just in case.
  3. Tell Ollama the New Address: Follow the steps in Method 2 to set the OLLAMA_MODELS environment variable so that its value points to your new folder path (e.g., D:\OllamaModels).
  4. Restart Ollama.
  5. Check: Open the command line and run ollama list. If you can see the list of models you downloaded before, it means the move was successful!

Linux Friends, Look Here 🐧

On Linux systems, Ollama usually stores models in .ollama/models under the user's home directory, which is ~/.ollama/models.

Method 1: Prevention is Better Than Cure - Set the Path Before Installation (Suitable for Fresh Installations)

If you are installing via script or package manager, you can specify it before installation.

  1. Set the Environment Variable: Open your terminal and enter (remember to change it to your path):
    bash
    export OLLAMA_MODELS="/data/OllamaModels"
    The environment variable set by this export command is only valid in the current terminal session.
  2. Execute the Installation Command: In the same terminal window, run your Ollama installation command (e.g., curl ... | sh). This way, the installer can read OLLAMA_MODELS and put the models in the location you specified.

Want to make the setting permanent? Then write it into your shell configuration file.

  1. Edit the Configuration File:
    • Open the terminal. Depending on what shell you are using, edit the corresponding file. Commonly used ones are bash (~/.bashrc) or zsh (~/.zshrc). Open it with your favorite editor, for example:
      bash
      nano ~/.bashrc  # Or nano ~/.zshrc
    • At the end of the file, add a line (remember to change it to your path):
      bash
      export OLLAMA_MODELS="/data/OllamaModels"
    • Save the file and exit (in nano it's Ctrl+X, then press Y, then press Enter).
  2. Make the Configuration Take Effect Immediately:
    • Run:
      bash
      source ~/.bashrc  # Or source ~/.zshrc
    • Alternatively, simply close the current terminal and reopen a new terminal window.
  3. Restart the Ollama Service:
    • If Ollama is running in the background (e.g., started with ollama serve or configured as a systemd service), you need to restart it. An easy way is to first ollama quit (if you have that command), or find the process and kill it, and then restart the service. If it is a systemd service, it might be a command like sudo systemctl restart ollama.

Method 3: Model Relocation - Migrate Existing Models

The steps are similar to Windows:

  1. Make sure Ollama is stopped. (You can use ps aux | grep ollama to find the process, then kill <pid>)
  2. Move the Folder:
    bash
    # First make sure the target directory exists
    mkdir -p /data/OllamaModels
    # Move the contents of the old folder to the new home
    mv ~/.ollama/models/* /data/OllamaModels/
    # You can choose to delete the old empty models directory (or keep it first to confirm that there are no problems)
    # rm -rf ~/.ollama/models
    Reminder Again: Backing up ~/.ollama before operating is always a good habit!
  3. Set the Environment Variable: According to Method 2, make sure OLLAMA_MODELS points to your new path /data/OllamaModels and make the configuration take effect.
  4. Restart the Ollama Service.
  5. Verify: Run ollama list to see if the models are still there.

macOS Friends, Come Here 

On macOS, the default path is also ~/.ollama/models. The modification method is very similar to Linux, mainly through environment variables.

Method 1: Temporary Change - Valid for the Current Session

If you just want to temporarily change the location for downloading models, you can use launchctl.

  1. Open Terminal.
  2. Run (replace the path with yours):
    bash
    launchctl setenv OLLAMA_MODELS "/Volumes/ExternalDrive/OllamaModels"
    This setting is only valid for Ollama applications started from this terminal (or applications started later that need to read this environment variable). It will be lost after restarting the computer.
  3. You can use launchctl getenv OLLAMA_MODELS to view the current settings.
  4. Want to cancel? launchctl unsetenv OLLAMA_MODELS.

As with Linux, it is recommended to modify your shell configuration file. macOS uses zsh by default, so it's usually editing ~/.zshrc.

  1. Edit the Configuration File: Open the terminal and run:
    bash
    nano ~/.zshrc
  2. Add the Environment Variable: Add the following at the end of the file (replace the path with yours):
    bash
    export OLLAMA_MODELS="/Users/your_username/Documents/OllamaModels"
  3. Save and Apply: Save and exit (Ctrl+X, Y, Enter), then run:
    bash
    source ~/.zshrc
    Or just restart the terminal.
  4. Restart the Ollama Application: Make sure to quit the Ollama application (Quit from the menu bar icon), and then reopen it to load the new environment variable.

Method 3: Model Relocation - Migrate Existing Models

The steps are exactly the same as Linux:

  1. Quit the Ollama Application.
  2. Move the Folder: Use Finder or the mv command to move the contents of ~/.ollama/models to the new home.
    bash
    mkdir -p "/Users/your_username/Documents/OllamaModels"
    mv ~/.ollama/models/* "/Users/your_username/Documents/OllamaModels/"
    Backup first!
  3. Set the Environment Variable: Follow Method 2 to make sure OLLAMA_MODELS points to the new path, and make the configuration take effect.
  4. Restart the Ollama Application.
  5. Verify: Run ollama list.

Alright! Now your Ollama models should be obediently staying in their new home, and your C drive can breathe a sigh of relief! Whether you are a user of any of these systems, I hope this guide can help you.