Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Ollama Version Upgrade and Migration

Ollama Version Upgrade and Migration

How to safely upgrade Ollama, move the model library to a new disk or machine, and back up and restore custom models.

Do these three things well, and your local model assets truly belong to you, unafraid of any hardware or version changes.


Safe upgrades: strategy before operation

The upgrade itself is simple; the hard part is "not crashing". The recommended three-step upgrade strategy:

Step 1: read the release notes: Release Notes mark new features, fixes, and known issues, especially model support and interface changes.

Step 2: back up key assets: export the recipes of custom models in use (see below for the method) and confirm the model directory location.

Step 3: test before rolling out: first upgrade and verify on a test machine, then roll out fully to production servers.

Platform Upgrade method
macOS / Windows Automatically download updates; click "Restart to update" in the menu bar or tray
Linux (script installation) Re-run the official installation script
Linux (manual installation) Delete the old library directory first, then extract the new package
Docker Pull the new image and rebuild the container; the data volume preserves all models

If compatibility issues require a rollback, or you want to try a pre-release version, use the version variable for precise control; install a specific version (see GitHub Releases for version numbers):



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

Pre-release versions are also installed via version numbers.

Before a manual upgrade on Linux, delete the old library directory (sudo rm -rf /usr/lib/ollama); mixing old and new inference libraries is the number one cause of "weird behavior after upgrading".


Model library migration: changing disks and machines

Models can easily be tens of GB; the essence of migration is one sentence: move the models directory, then tell Ollama where the new location is.

Three steps of migration: export backup, migrate data, verify

Scenario 1: changing disks on the same machine

Example

1. After stopping the service, move the entire model directory to the new disk

sudo

mv

/

usr

/

share

/

ollama

/

.ollama

/

models

/

data

/

ollama-models

2. Point the environment variable to the new location (see the configuration chapter for the three-platform setup method)

OLLAMA_MODELS

=

/

data

/

ollama-models ollama serve

3. For standard Linux installation, transfer ownership to the ollama user

sudo

chown

-R

ollama:ollama

/

data

/

ollama-models

Scenario 2: migrating to a new machine

Example

Old machine: package the entire models directory (including blobs and manifests)

tar

czf models-backup.tar.gz

-C

~

/

.ollama models

New machine: install the same version of Ollama and extract to the corresponding location

mkdir

-p

~

/

.ollama

tar

xzf models-backup.tar.gz

-C

~

/

.ollama

Verify the model manifest is complete

ollama list

Two details determine migration success: the new machine's Ollama version should match the old machine as closely as possible; the blobs and manifests structure under the models directory must be preserved as-is, do not copy only individual model files.


Backup and restore of custom models

Custom models (the product of Modelfile builds) have two backup methods; it is recommended to do both.

Method 1: export the recipe into Git

Example

Export the complete recipe of a model

ollama show

--modelfile

runoob-coder

runoob-coder.modelfile

Note one detail: the FROM line in the exported recipe points to a local blob file path, which cannot be used directly on another machine. When restoring, change FROM back to the base model name (e.g. FROM qwen3.5:9b) and rebuild.

Example

Rebuild after modifying FROM, and the recipe is restored

ollama create runoob-coder

-f

runoob-coder.modelfile

Method 2: push to a model library for cloud backup

Example

Copy to a namespaced name and then push (see the team deployment chapter for private publishing)

ollama

cp

runoob-coder myteam

/

runoob-coder:v1

ollama push myteam

/

runoob-coder:v1

Recommended organization: keep all Modelfiles in one Git repository, paired with a script to rebuild the environment from scratch--hardware changes, systems get reinstalled, but with the recipes in hand, all custom models can be restored in ten minutes.