
Ollama stays quiet about disk usage. Then your root volume hits 100%, and things break fast. Model pulls fail, logs stop writing, and SSH can even get flaky.
This guide shows how to move Ollama models to another disk on a VPS. You’ll relocate the model cache to an attached volume. Then you’ll restart services to verify the change and keep a simple rollback path.
The steps below assume Linux on a typical VPS (Ubuntu/Debian with systemd). You’ll need either a second block volume (NVMe/SSD/attached storage) or a larger data partition.
If you run Ollama in production, do this before an outage forces the issue.
Before you start: what you’re moving (and why it fills up)
Ollama stores model blobs on disk. Two or three medium models can chew through tens of gigabytes.
The pile grows quickly if you test multiple quantizations and variants.
On a VPS with a 40–80GB root disk, that’s often enough to trigger:
- Failed model pulls with “no space left on device”.
- Slow or failing updates because package managers can’t write temp files.
- Broken services when logs can’t append.
The fix is simple: put the model directory on a bigger filesystem.
Then keep Ollama using the same path so nothing else needs to change.
Resource and infrastructure checklist (VPS-friendly)
- OS: Ubuntu 22.04/24.04 or Debian 12 are common choices for VPS deployments.
- Disk: a second volume or partition with enough free space for your model set (plan at least 2–3× your current model footprint).
- Downtime: a short stop while copying data (minutes to longer depending on size and IOPS).
- Permissions: root access.
If you host AI services regularly, start with storage headroom. That can mean a HostMyCode VPS with larger NVMe storage.
If your model library and traffic grow, a dedicated server may be a better fit.
Step 1 — Confirm where Ollama stores models right now
First, confirm how Ollama runs on your server. Then find where it writes data.
-
Check whether Ollama runs as a systemd service:
systemctl status ollama --no-pager -
Find the process and its user:
ps aux | grep -E 'ollama( serve)?' | grep -v grep -
Locate the model directory. On many Linux installs, Ollama stores data under one of these paths:
/usr/share/ollama/.ollama/var/lib/ollama/root/.ollama(less ideal, but seen in manual setups)/home/ollama/.ollama(if running as a dedicated user)
If you’re not sure which path is actually consuming space, check filesystem usage first. Then measure the usual suspects:
# See which filesystem is filling up
df -h
# Search likely locations and show sizes
sudo du -h -d 2 /var/lib 2>/dev/null | sort -h | tail -n 20
sudo du -h -d 2 /usr/share/ollama 2>/dev/null | sort -h | tail -n 20
sudo du -h -d 2 /root 2>/dev/null | sort -h | tail -n 20
sudo du -h -d 2 /home 2>/dev/null | sort -h | tail -n 20
Once you find the heavy directory, treat it as your source path.
For the rest of this tutorial, we’ll assume the source is:
/var/lib/ollama
If yours is different, substitute that path in the commands that follow.
Step 2 — Attach and mount the new disk (safe, persistent mount)
If you already have a disk mounted (for example /mnt/data), skip to Step 3.
Otherwise, mount the new volume using a UUID. This keeps the mount stable across reboots.
-
List disks and partitions:
lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINTS,UUIDAssume your new disk is
/dev/vdbwith no partition yet. -
Create a partition (GPT) and format it. This example creates one partition spanning the disk:
sudo parted -s /dev/vdb mklabel gpt sudo parted -s /dev/vdb mkpart primary ext4 0% 100% # Format it sudo mkfs.ext4 -F /dev/vdb1 -
Create a mount point and mount it:
sudo mkdir -p /mnt/ollama-models sudo mount /dev/vdb1 /mnt/ollama-models -
Make the mount persistent across reboots using UUID:
sudo blkid /dev/vdb1Copy the UUID, then add an entry to
/etc/fstab:sudo nano /etc/fstab# Add a line like this (replace UUID=...) UUID=YOUR-UUID-HERE /mnt/ollama-models ext4 defaults,noatime 0 2Test it without rebooting:
sudo umount /mnt/ollama-models sudo mount -a # Confirm df -h | grep -E 'ollama-models|Filesystem'
Also watch disk pressure so it doesn’t surprise you again. Netdata makes trends obvious.
If you haven’t installed it, see Install Netdata on Ubuntu VPS for real-time monitoring.
Step 3 — Choose your relocation method (bind mount vs symlink)
You have two realistic options. Both work well on a VPS.
-
Bind mount (recommended): keep the original path (for example,
/var/lib/ollama), but mount the new disk directory there. This is predictable with systemd and upgrades. -
Symlink: move the directory and replace it with a symlink. This can work, but some hardening policies and service configs are less forgiving with symlinks in system paths.
This tutorial uses a bind mount. From Ollama’s point of view, nothing changes.
Only the underlying filesystem changes.
Step 4 — Stop Ollama cleanly (and confirm it’s not writing)
Stop the service before copying anything. Copying live model files can leave partial blobs behind.
Those errors are frustrating to diagnose later.
sudo systemctl stop ollama
sudo systemctl status ollama --no-pager
Then confirm no Ollama process is still running:
pgrep -a ollama || echo "No ollama process found"
Step 5 — Copy the current model store to the new disk (preserve ownership)
Create a destination directory on the new disk. An explicit folder makes verification and rollback easier.
sudo mkdir -p /mnt/ollama-models/var-lib-ollama
Copy the data with rsync so ownership, symlinks, and timestamps carry over:
sudo rsync -aHAX --info=progress2 /var/lib/ollama/ /mnt/ollama-models/var-lib-ollama/
Do a quick size check. It doesn’t need to match byte-for-byte, but it should be close:
sudo du -sh /var/lib/ollama
sudo du -sh /mnt/ollama-models/var-lib-ollama
This is usually the slowest step.
On a low-IOPS volume, copying 50–150GB can take a while.
Step 6 — Swap in the bind mount (with a rollback path)
Now you’ll make /var/lib/ollama point to the data on the new disk.
Don’t delete anything yet. Keep the original directory until Ollama runs normally.
-
Rename the original directory (backup):
sudo mv /var/lib/ollama /var/lib/ollama.bak -
Create a new empty mount point at the original path:
sudo mkdir -p /var/lib/ollama -
Bind mount the new location to the old path:
sudo mount --bind /mnt/ollama-models/var-lib-ollama /var/lib/ollama -
Confirm it’s mounted:
mount | grep '/var/lib/ollama' df -h /var/lib/ollama
/var/lib/ollama should now report the filesystem of your new disk.
Step 7 — Make the bind mount persistent with /etc/fstab
If you skip this step, the bind mount disappears after a reboot.
Ollama may then recreate a fresh directory on the root disk.
Add the bind mount entry:
sudo nano /etc/fstab
# Bind mount Ollama data directory
/mnt/ollama-models/var-lib-ollama /var/lib/ollama none bind 0 0
Test it immediately:
sudo umount /var/lib/ollama
sudo mount -a
# Check again
df -h /var/lib/ollama
mount | grep '/var/lib/ollama'
Step 8 — Start Ollama and verify models are visible
Start the service again:
sudo systemctl start ollama
sudo systemctl status ollama --no-pager
Now list local models. Depending on how the server is set up, one of these will work:
ollama list
If the ollama CLI isn’t in your PATH for your current user, try:
sudo -u ollama ollama list 2>/dev/null || sudo ollama list
Finally, run a small test to confirm blobs load correctly:
ollama run llama3.1 "Say 'ok' and nothing else."
If you don’t have that model installed, swap in one you do.
Step 9 — Remove the backup once you’re confident (optional, but recommended)
After a few successful runs (and ideally a reboot test), reclaim the space used by the backup directory:
# Double-check the bind mount still points at the new disk
df -h /var/lib/ollama
# Then remove backup
sudo rm -rf /var/lib/ollama.bak
If you want extra safety, keep the backup for a day.
The bind mount keeps the active data on the new disk either way.
Rollback plan (get back to the old path in 2 minutes)
If Ollama won’t start or can’t see your models, roll back to the original directory.
-
Stop Ollama:
sudo systemctl stop ollama -
Remove the bind mount and fstab entry:
sudo umount /var/lib/ollama # Edit /etc/fstab and remove the bind line sudo nano /etc/fstab # Re-apply remaining mounts sudo mount -a -
Restore the old directory:
sudo rm -rf /var/lib/ollama sudo mv /var/lib/ollama.bak /var/lib/ollama -
Start Ollama:
sudo systemctl start ollama
This works because you never destroyed the original data.
Everything stayed intact until you chose to remove it.
Common pitfalls (and how to diagnose them fast)
-
Ollama starts but “models disappeared”: you bind-mounted an empty directory. Check
df -h /var/lib/ollamaand confirm it’s on the new disk. Then confirm you copied the correct source path. -
Permission errors reading blobs: the copy didn’t preserve ownership. Re-run rsync with
-aHAX, then inspect ownership:sudo ls -ld /var/lib/ollama sudo find /var/lib/ollama -maxdepth 2 -type d -printf '%u:%g %p\n' | head -
Bind mount lost after reboot: the bind entry is missing from
/etc/fstab, or the underlying disk didn’t mount. Checksystemctl status local-fs.target, and confirm the disk’s fstab UUID entry is correct. -
Disk still fills up: Ollama may not be the culprit. Logs, package caches, or Docker overlays often win.
Find what’s actually large:
sudo du -x -h -d 2 / | sort -h | tail -n 30If Docker is installed, inspect
/var/lib/dockerseparately.
Hardening tip: don’t expose Ollama while you’re fixing storage
Storage problems show up often on internet-facing servers. It’s tempting to leave an AI endpoint open “for testing.” Don’t.
Put Ollama behind HTTPS and authentication early. Keep the API private where you can.
If you need external access, follow Run Ollama Behind Caddy With HTTPS on a VPS.
Also lock down SSH before you expose anything new. If you haven’t done it yet, use SSH keys and password-login disable.
Optional: validate with a reboot test (the step people skip)
If it only works until the next reboot, it’s not finished.
Reboot during a safe window:
sudo reboot
After the server comes back:
df -h /var/lib/ollama
mount | grep '/var/lib/ollama'
systemctl status ollama --no-pager
ollama list
If all four checks look right, the migration is stable.
When a bigger disk isn’t enough: practical capacity planning
Relocating the cache fixes the root-disk crisis. It does not change the reality that models are large.
If you experiment, your library will grow quickly.
- Keep fewer models installed on production servers. Pull only what you serve.
- Separate “lab” and “prod” if you test frequently. A small dev VPS for trials keeps production clean.
- Monitor disk and inode usage. Set alerts so you hear about trouble before 90%.
If you expect regular growth, start with headroom. It’s cleaner than repeated emergency moves.
A managed VPS hosting setup can also prevent classic fstab-and-reboot surprises.
Need a stable place to run private AI tools without playing storage roulette? Run Ollama on a HostMyCode VPS with dedicated NVMe storage, or pick managed VPS hosting if you want the OS and service wiring handled for you.
FAQ: moving Ollama model storage safely
Do I need to change Ollama configuration to move the cache?
Not if you use a bind mount. Ollama continues to read /var/lib/ollama (or your existing path), but that path now resolves to the new disk.
Is a symlink okay instead of a bind mount?
Often, yes. A bind mount is usually more predictable across hardening, updates, and permission checks.
If you do use a symlink, stop Ollama first, move the directory, then symlink it back.
How do I confirm I really freed space on root?
Run df -h and compare root filesystem usage before and after. Also confirm df -h /var/lib/ollama shows the new disk.
Can I do this on a production server with minimal downtime?
Yes, but you still need a stop-and-copy window. If your model store is large, schedule it.
Copy speed depends heavily on disk IOPS and CPU encryption overhead (if any).
What if I’m also running Open WebUI or other containers?
They don’t care where Ollama stores blobs, as long as the API stays reachable and Ollama can load models.
If you use Open WebUI, keep the storage persistent and consistent; see Run Open WebUI with persistent storage on a VPS.
Summary
You moved Ollama’s model cache off the root disk. You did it by copying data to a mounted volume, swapping in a bind mount at the original path, and validating the result with restarts and a reboot test.
That’s a dependable way to move Ollama models to another disk without rewriting configs or hunting for files later.
If you plan to run more models, add Open WebUI, or expose an endpoint behind HTTPS, start with enough storage and predictable performance.
A HostMyCode VPS with adequate NVMe capacity helps you avoid emergency migrations later.