[GH-ISSUE #6037] Make model locations easier and clearer on Linux #29538

Closed
opened 2026-04-22 08:30:57 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @cardchase on GitHub (Jul 29, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6037

It started with wanting to backup downloaded models before reinstalling linux (I wanted to upgrade my CUDA version and a clean install) and then I had no idea where the models were saved and then I had no idea which blob was which!

OS: Ubuntu 22.04 LTS

(base) user@user-TRX50-AERO-D:~$ ollama list
NAME                      	ID          	SIZE  	MODIFIED    
llama3.1:70b-instruct-q8_0	a706db81604c	74 GB 	5 days ago 	
phi3:medium               	1e67dff39209	7.9 GB	12 days ago	
llava:34b                 	3d2d24f46674	20 GB 	2 weeks ago	
gemma2:27b                	371038893ee3	15 GB 	3 weeks ago	
(base) user@user-TRX50-AERO-D:~$ 

(base) user@user-TRX50-AERO-D:~$ sudo ls /usr/share/ollama/.ollama/models
[sudo] password for user: 
blobs  manifests
(base) user@user-TRX50-AERO-D:~$ sudo ls /usr/share/ollama/.ollama/models/blobs
sha256-00c39c2649c078d5ba6f74e6806c2e4ab1bce903e16105409786ef638caf24a1  sha256-854e958d53c3833a2604aa8f557efdaf5e23ffc7a6fe0280f0387f92fc6bd733
sha256-097a36493f718248845233af1d3fefe7a303f864fae13bc31a3a9704229378ca  sha256-8dde1baf1db03d318a2ab076ae363318357dff487bdd8c1703a29886611e581f
sha256-109037bec39c0becc8221222ae23557559bc594290945a2c4221ab4f303b8871  sha256-a35298562e36265ed3f0bff11a4c9bea8513fbabfca59006c9597648a738a13a
sha256-43070e2d4e532684de521b885f385d0841030efa2b1a20bafb76133a5e1379c1  sha256-a47b02e00552cd7022ea700b1abf8c572bb26c9bc8c1a37e01b566f2344df5dc
sha256-518589767ccdbbe44c13aa2d35e0ae86e0c48969f2094750abb183ee8f2370f4  sha256-c266f81b82cdcde845d98e37aa625fc6e6c0e04818edf7b4bf27528a17e67b1c
sha256-542b217f179c7825eeb5bca3c77d2b75ed05bafbd3451d9188891a60a85337c6  sha256-cdbcae7e69d520e3d5a17b4979c31331dfba959f36641a81576349875d682127
sha256-56bb8bd477a519ffa694fc449c2413c6f0e1d3b1c88fa7e3c9d88d3ae49d4dcb  sha256-f02dd72bb2423204352eabc5637b44d79d17f109fdb510a7c51455892aa2d216
sha256-60677c6bf48ba630e7ffe55cb46e6d8c198b5b88b81cd7da510c2b0b3240cf7c  sha256-f1cd752815fcf68c3c2e73b2b00b5396c5dffb9eebe49567573f275f9ec85fcd
sha256-6f1156408d0ad0a5f62682fb808d7b56440691703824c0f4a450c4883326ab43  sha256-fa8235e5b48faca34e3ca98cf4f694ef08bd216d28b58071a1f85b1d50cb814d
sha256-7a3cc4804c645959a6734971b87607bc7eb2a2ed3e3adf3ad221f12b79dadff8  sha256-fbbdec5e5fa1f0f6621e10d74f1651e4806adb892f2681995a8ed99bb261df84
sha256-83720bd8438ccdc910deba5efbdc3340820b29258d94a7a60d1addc9a1b5f095
(base) user@user-TRX50-AERO-D:~$ sudo ls /usr/share/ollama/.ollama/models/manifests
registry.ollama.ai

I have no idea which blob is which model!

Why is it so difficult to maintain these files as they are no small! There has to be an easier way I can copy and save them to another location and then restore them to ollama folder afterwards!

I honestly dont want to spend half a day downloading them.

Devs, can you please look into this request?

Originally created by @cardchase on GitHub (Jul 29, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6037 It started with wanting to backup downloaded models before reinstalling linux (I wanted to upgrade my CUDA version and a clean install) and then I had no idea where the models were saved and then I had no idea which blob was which! OS: Ubuntu 22.04 LTS ``` (base) user@user-TRX50-AERO-D:~$ ollama list NAME ID SIZE MODIFIED llama3.1:70b-instruct-q8_0 a706db81604c 74 GB 5 days ago phi3:medium 1e67dff39209 7.9 GB 12 days ago llava:34b 3d2d24f46674 20 GB 2 weeks ago gemma2:27b 371038893ee3 15 GB 3 weeks ago (base) user@user-TRX50-AERO-D:~$ (base) user@user-TRX50-AERO-D:~$ sudo ls /usr/share/ollama/.ollama/models [sudo] password for user: blobs manifests (base) user@user-TRX50-AERO-D:~$ sudo ls /usr/share/ollama/.ollama/models/blobs sha256-00c39c2649c078d5ba6f74e6806c2e4ab1bce903e16105409786ef638caf24a1 sha256-854e958d53c3833a2604aa8f557efdaf5e23ffc7a6fe0280f0387f92fc6bd733 sha256-097a36493f718248845233af1d3fefe7a303f864fae13bc31a3a9704229378ca sha256-8dde1baf1db03d318a2ab076ae363318357dff487bdd8c1703a29886611e581f sha256-109037bec39c0becc8221222ae23557559bc594290945a2c4221ab4f303b8871 sha256-a35298562e36265ed3f0bff11a4c9bea8513fbabfca59006c9597648a738a13a sha256-43070e2d4e532684de521b885f385d0841030efa2b1a20bafb76133a5e1379c1 sha256-a47b02e00552cd7022ea700b1abf8c572bb26c9bc8c1a37e01b566f2344df5dc sha256-518589767ccdbbe44c13aa2d35e0ae86e0c48969f2094750abb183ee8f2370f4 sha256-c266f81b82cdcde845d98e37aa625fc6e6c0e04818edf7b4bf27528a17e67b1c sha256-542b217f179c7825eeb5bca3c77d2b75ed05bafbd3451d9188891a60a85337c6 sha256-cdbcae7e69d520e3d5a17b4979c31331dfba959f36641a81576349875d682127 sha256-56bb8bd477a519ffa694fc449c2413c6f0e1d3b1c88fa7e3c9d88d3ae49d4dcb sha256-f02dd72bb2423204352eabc5637b44d79d17f109fdb510a7c51455892aa2d216 sha256-60677c6bf48ba630e7ffe55cb46e6d8c198b5b88b81cd7da510c2b0b3240cf7c sha256-f1cd752815fcf68c3c2e73b2b00b5396c5dffb9eebe49567573f275f9ec85fcd sha256-6f1156408d0ad0a5f62682fb808d7b56440691703824c0f4a450c4883326ab43 sha256-fa8235e5b48faca34e3ca98cf4f694ef08bd216d28b58071a1f85b1d50cb814d sha256-7a3cc4804c645959a6734971b87607bc7eb2a2ed3e3adf3ad221f12b79dadff8 sha256-fbbdec5e5fa1f0f6621e10d74f1651e4806adb892f2681995a8ed99bb261df84 sha256-83720bd8438ccdc910deba5efbdc3340820b29258d94a7a60d1addc9a1b5f095 (base) user@user-TRX50-AERO-D:~$ sudo ls /usr/share/ollama/.ollama/models/manifests registry.ollama.ai ``` I have no idea which blob is which model! **Why is it so difficult to maintain these files as they are no small! There has to be an easier way I can copy and save them to another location and then restore them to ollama folder afterwards!** I honestly dont want to spend half a day downloading them. Devs, can you please look into this request?
GiteaMirror added the feature request label 2026-04-22 08:30:57 -05:00
Author
Owner

@DuckyBlender commented on GitHub (Jul 29, 2024):

This. I get that hashing the model files are needed for efficiency but doing it this way makes it much more difficult to manage models without the CLI

<!-- gh-comment-id:2255473914 --> @DuckyBlender commented on GitHub (Jul 29, 2024): This. I get that hashing the model files are needed for efficiency but doing it this way makes it much more difficult to manage models without the CLI
Author
Owner

@rick-github commented on GitHub (Jul 29, 2024):

#!/bin/bash

# Move models around.  Example: create an archive of qwen2.5
# $ oarc qwen2.5:0.5b qwen2.5.model
# Copy the model to a new machine
# $ scp qwen2.5.model remote:/tmp
# Install in remote machine (models dir must already exist)
# $ ssh remote oarc /tmp/qwen2.5.model ~/.ollama/models
# Copy a model from one ollama instance to another
# $ oarc qwen2.5:0.5b ~/.ollama/models

OLLAMA_MODELS=${OLLAMA_MODELS-/usr/share/ollama/.ollama/models}

library=manifests/registry.ollama.ai/library
blobs=blobs

usage() {
    echo "Usage: ${0##*/} model-name ollama-directory"
    echo "         Copy an existing model to a new ollama directory"
    echo "       ${0##*/} model-archive ollama-directory"
    echo "         Extract an archived model to an ollama directory"
    echo "       ${0##*/} model-name model-archive"
    echo "         Archive an existing model to the named file"
    exit 1
}

die() {
  echo "$1" >&2
  exit 2
}

get_files() {
  manifest=$library/$1
  echo "$(echo $manifest ; for blob in $(jq -r '.config.digest,.layers[].digest' "$OLLAMA_MODELS/$manifest") ; do
            echo $blobs/${blob/:/-}
          done)"
}

copy_model_to_directory() {
  files=$(get_files "$1")
  cpio -dump -D "$OLLAMA_MODELS" "$2" <<< "$files" || exit $?
}

copy_archive_to_directory() {
  cpio -D "$2" -dumi < "$1" || exit $?
}

copy_model_to_archive() {
  files=$(get_files "$1")
  cpio -o -D "$OLLAMA_MODELS" --file="$2" <<< "$files" || exit $?
}

model_to_path() {
  namespace=${1%:*}
  tag=latest
  _=$(expr match "$1" ".*:") && tag="${1#*:}"
  [ ! -f "$OLLAMA_MODELS/$library/$namespace/$tag" ] && die "Couldn't find manifest for $1"
  echo "$namespace/$tag"
}

[ "${#@}" -ne 2 ] && usage

[ -f "$1" -a -d "$2" ] && { copy_archive_to_directory "$1" "$2" ; exit 0 ; }

model_path=$(model_to_path $1) || exit $?
dst=$(realpath "$2")

[ -d "$dst" ] && { copy_model_to_directory "$model_path" "$dst" ; exit 0 ; }

[ ! -e "$dst" ] && { copy_model_to_archive "$model_path" "$dst" ; exit 0 ; }

usage
<!-- gh-comment-id:2255540441 --> @rick-github commented on GitHub (Jul 29, 2024): ``` #!/bin/bash # Move models around. Example: create an archive of qwen2.5 # $ oarc qwen2.5:0.5b qwen2.5.model # Copy the model to a new machine # $ scp qwen2.5.model remote:/tmp # Install in remote machine (models dir must already exist) # $ ssh remote oarc /tmp/qwen2.5.model ~/.ollama/models # Copy a model from one ollama instance to another # $ oarc qwen2.5:0.5b ~/.ollama/models OLLAMA_MODELS=${OLLAMA_MODELS-/usr/share/ollama/.ollama/models} library=manifests/registry.ollama.ai/library blobs=blobs usage() { echo "Usage: ${0##*/} model-name ollama-directory" echo " Copy an existing model to a new ollama directory" echo " ${0##*/} model-archive ollama-directory" echo " Extract an archived model to an ollama directory" echo " ${0##*/} model-name model-archive" echo " Archive an existing model to the named file" exit 1 } die() { echo "$1" >&2 exit 2 } get_files() { manifest=$library/$1 echo "$(echo $manifest ; for blob in $(jq -r '.config.digest,.layers[].digest' "$OLLAMA_MODELS/$manifest") ; do echo $blobs/${blob/:/-} done)" } copy_model_to_directory() { files=$(get_files "$1") cpio -dump -D "$OLLAMA_MODELS" "$2" <<< "$files" || exit $? } copy_archive_to_directory() { cpio -D "$2" -dumi < "$1" || exit $? } copy_model_to_archive() { files=$(get_files "$1") cpio -o -D "$OLLAMA_MODELS" --file="$2" <<< "$files" || exit $? } model_to_path() { namespace=${1%:*} tag=latest _=$(expr match "$1" ".*:") && tag="${1#*:}" [ ! -f "$OLLAMA_MODELS/$library/$namespace/$tag" ] && die "Couldn't find manifest for $1" echo "$namespace/$tag" } [ "${#@}" -ne 2 ] && usage [ -f "$1" -a -d "$2" ] && { copy_archive_to_directory "$1" "$2" ; exit 0 ; } model_path=$(model_to_path $1) || exit $? dst=$(realpath "$2") [ -d "$dst" ] && { copy_model_to_directory "$model_path" "$dst" ; exit 0 ; } [ ! -e "$dst" ] && { copy_model_to_archive "$model_path" "$dst" ; exit 0 ; } usage ```
Author
Owner

@goactiongo commented on GitHub (Oct 18, 2024):

I also wanna know which blob file was which model。
Through CLI ollama list shown 10 models, whereas there is more than 10 file in folder /usr/share/ollama/.ollama/models.

Through CLI 'ollama show MODEL_NAMA --modelfile' can get the SHA256...., but this way needs to find the SHA256 one by one...

<!-- gh-comment-id:2421031770 --> @goactiongo commented on GitHub (Oct 18, 2024): I also wanna know which blob file was which model。 Through CLI ```ollama list``` shown 10 models, whereas there is more than 10 file in folder /usr/share/ollama/.ollama/models. Through CLI 'ollama show MODEL_NAMA --modelfile' can get the SHA256...., but this way needs to find the SHA256 one by one...
Author
Owner

@rick-github commented on GitHub (Oct 18, 2024):

#!/bin/bash

OLLAMA_MODELS=${OLLAMA_MODELS:-/usr/share/ollama/.ollama/models}

cd $OLLAMA_MODELS/manifests/registry.ollama.ai/library || exit

for f in $* ; do
  s=${f##*/}
  s=${s#sha256?}
  find . -type f -size -10000c | xargs grep -l "$s" | sed -e 's@^\./@@' -e 's@/@:@' | while read i ; do echo "$f $i" ; done
done

<!-- gh-comment-id:2421086852 --> @rick-github commented on GitHub (Oct 18, 2024): ```sh #!/bin/bash OLLAMA_MODELS=${OLLAMA_MODELS:-/usr/share/ollama/.ollama/models} cd $OLLAMA_MODELS/manifests/registry.ollama.ai/library || exit for f in $* ; do s=${f##*/} s=${s#sha256?} find . -type f -size -10000c | xargs grep -l "$s" | sed -e 's@^\./@@' -e 's@/@:@' | while read i ; do echo "$f $i" ; done done ```
Author
Owner

@goactiongo commented on GitHub (Oct 18, 2024):

great
thanks

---Original---
From: @.>
Date: Fri, Oct 18, 2024 10:07 AM
To: @.
>;
Cc: @.@.>;
Subject: Re: [ollama/ollama] Make model locations easier and clearer on Linux(Issue #6037)

#!/bin/bash OLLAMA_MODELS=${OLLAMA_MODELS:-/usr/share/ollama/.ollama/models} cd $OLLAMA_MODELS/manifests/registry.ollama.ai/library || exit for f in $* ; do s=${f##*/} s=${s#sha256?} find . -type f -size -10000c | xargs grep -l "$s" | sed -e 's@^./@@' -e 's@/@:@' | while read i ; do echo "$f $i" ; done done


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>

<!-- gh-comment-id:2421290047 --> @goactiongo commented on GitHub (Oct 18, 2024): great thanks ---Original--- From: ***@***.***&gt; Date: Fri, Oct 18, 2024 10:07 AM To: ***@***.***&gt;; Cc: ***@***.******@***.***&gt;; Subject: Re: [ollama/ollama] Make model locations easier and clearer on Linux(Issue #6037) #!/bin/bash OLLAMA_MODELS=${OLLAMA_MODELS:-/usr/share/ollama/.ollama/models} cd $OLLAMA_MODELS/manifests/registry.ollama.ai/library || exit for f in $* ; do s=${f##*/} s=${s#sha256?} find . -type f -size -10000c | xargs grep -l "$s" | sed -e 's@^\./@@' -e 's@/@:@' | while read i ; do echo "$f $i" ; done done — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: ***@***.***&gt;
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#29538