DEV Community

Unpublished Post. This URL is public but secret, so share at your own discretion.

How to Completely Uninstall Ollama and Erase LLM Models on Linux Systems

Ollama is a powerful tool for running large language models (LLMs) locally. However, there may come a time when you need to uninstall it entirely, whether to free up disk space or troubleshoot an issue. This guide walks you through completely removing Ollama and erasing all related files, including any LLM models downloaded on Linux systems.

Why Completely Uninstall Ollama?

There are several reasons you might want to uninstall Ollama and erase its associated data:

  • Freeing Up Disk Space: LLM models can consume significant storage.
  • Starting Fresh: Clean installation to troubleshoot errors.
  • Switching to a Different Tool: Transitioning to another solution.

Steps to Completely Uninstall Ollama

1. Stop and Remove the Docker Container

If you are running Ollama via Docker, stop and remove the container.

Stop the Container

docker stop ollama
Enter fullscreen mode Exit fullscreen mode

Remove the Container

docker rm ollama
Enter fullscreen mode Exit fullscreen mode

Remove the Docker Image

List the images to confirm the ollama/ollama image exists:

docker images
Enter fullscreen mode Exit fullscreen mode

Remove the image:

docker rmi ollama/ollama
Enter fullscreen mode Exit fullscreen mode

2. Uninstall Ollama Installed via Package Manager

If you installed Ollama directly on your Linux system, uninstall it using your package manager.

For Debian/Ubuntu:

sudo apt-get remove --purge ollama
sudo apt-get autoremove
Enter fullscreen mode Exit fullscreen mode

For Fedora/CentOS/RHEL:

sudo dnf remove ollama
Enter fullscreen mode Exit fullscreen mode

For Arch Linux:

sudo pacman -Rns ollama
Enter fullscreen mode Exit fullscreen mode

3. Remove Configuration Files

After uninstalling Ollama, residual configuration files may still exist. Remove them manually to ensure a clean slate.

Common Directories to Check

  1. Home Directory Configurations:
rm -rf ~/.ollama
Enter fullscreen mode Exit fullscreen mode
  1. System-Wide Configurations:
sudo rm -rf /etc/ollama
Enter fullscreen mode Exit fullscreen mode
  1. Log Files: Check for logs and delete them:
sudo rm -rf /var/log/ollama
Enter fullscreen mode Exit fullscreen mode

4. Erase LLM Models

LLM models downloaded by Ollama can take up significant disk space. These models are often stored in specific directories.

Find and Remove LLM Models

Locate the folder storing the models:

sudo find / -type d -name "ollama"
Enter fullscreen mode Exit fullscreen mode

Remove the models:

sudo rm -rf /path/to/ollama
Enter fullscreen mode Exit fullscreen mode

5. Clean Docker Volumes (If Applicable)

If you used Docker to run Ollama, its volumes might still exist, storing model data.

  1. List Volumes
docker volume ls
Enter fullscreen mode Exit fullscreen mode
  1. Remove Ollama Volume
docker volume rm ollama
Enter fullscreen mode Exit fullscreen mode

6. Verify the Uninstallation

To ensure Ollama and its files are entirely removed:

Run the following command to check if any traces remain:

sudo find / -name "ollama" -type f
Enter fullscreen mode Exit fullscreen mode

Confirm no results are returned.

Additional Tips

Check Disk Usage

After uninstalling, verify the reclaimed disk space:

df -h
Enter fullscreen mode Exit fullscreen mode

Reinstall Ollama

If you plan to reinstall Ollama later, follow the official Ollama installation guide.

Conclusion

By following this guide, you can completely uninstall Ollama and erase all LLM models from your Linux system. This process ensures no residual files or data occupy your disk space, leaving your system clean and ready for other tasks. Whether you're troubleshooting, switching tools, or reclaiming space, these steps will help you achieve your goal.

Top comments (0)