Moving the .ollama Directory to an External Drive for Ollama Model Management

When working with large language models like .ollama, you might find that these files take up a significant amount of space on your Mac’s internal storage. This tutorial will guide you through moving the .ollama directory to an external drive, enabling you to free up space and easily transfer your work between different computers. This guide is designed for users with limited knowledge of the terminal and aims to ensure data safety throughout the process.

Prerequisites

  • An external drive connected to your Mac.
  • Basic familiarity with navigating Finder.

Step 1: Locate Your .ollama Directory

The .ollama directory might be hidden since it starts with a dot. To view hidden files in Finder:

  1. Open Finder.
  2. Navigate to your home directory (usually your username).
  3. Press Command + Shift + . (period key) to toggle the visibility of hidden files.

Your .ollama directory should now be visible if it exists.

Step 2: Find the Path to Your .ollama Directory and External Drive

Before moving the .ollama directory, we need to know its current location and where you want to move it on your external drive.

  1. Open Terminal (you can find it using Spotlight with Command + Space and typing “Terminal”).
  2. Type cd (note the space after cd), then drag and drop your .ollama directory from Finder into the Terminal window. Press Enter. This changes your current directory to .ollama.
  3. Type pwd and press Enter. This command prints the path to your current directory. It should look something like
    /Users/yourusername/.ollama
    . Note this path.
  4. To find the path to your external drive, type
    cd /Volumes/
    and press Enter, then type ls and press Enter to list all connected drives. Identify your external drive from the list.

Step 3: Backup Your .ollama Directory

Before making any changes, let’s create a backup of your .ollama directory on your external drive. Replace YourExternalDrive with the name of your external drive.

bash
rsync -avh --progress /Users/yourusername/.ollama /Volumes/YourExternalDrive/.ollama_backup

Warning: Ensure you have the correct paths to avoid data loss.

Step 4: Move the .ollama Directory

Now, we will use rsync to safely move the .ollama directory to your external drive. This method allows for resuming if the transfer is interrupted and provides progress updates.

Replace YourExternalDrive with your drive’s name:

bash
rsync -avh --progress /Users/yourusername/.ollama /Volumes/YourExternalDrive/.ollama

Step 5: Verify the Transfer

To ensure all files have been successfully transferred, you can compare the original and new directories:

bash
diff -rq /Users/yourusername/.ollama /Volumes/YourExternalDrive/.ollama

No output means the transfer was successful.

Step 6: Remove the Original .ollama Directory

After verifying the transfer, delete the original directory to free up space:

bash
rm -rf /Users/yourusername/.ollama

Warning: Double-check the path before executing to avoid accidental data loss.

Step 7: Create a Symbolic Link

To maintain access to .ollama as if it were still in its original location, we’ll create a symlink:

bash
ln -s /Volumes/YourExternalDrive/.ollama /Users/yourusername/.ollama

Step 8: Test the Symlink

Ensure the symlink points to the new location correctly:

bash
ls -l /Users/yourusername/.ollama

The output should indicate that it’s linked to your external drive.

				
					ls -l /Users/yourusername/.ollama
				
			
				
					ls -l $HOME/.ollama
				
			

Launch Ollama by navigating to your Applications folder and opening Ollama, or from the terminal with:

<code>ls -l $HOME/.ollama</code>

				
					
ls -l /Users/yourusername/.ollama

				
			
bashCopy code ls -l /Users/yourusername/.ollama The output should indicate that it's linked to your external drive.

Conclusion

You’ve successfully moved your .ollama directory to an external drive and created a symlink for seamless access. This setup allows you to manage large files efficiently and transfer your work between computers easily. Remember to handle terminal commands with care, especially when moving or deleting files, to avoid data loss.

Book an Appointment

Get your first 10 minutes for new customers

FREE

Thank you for filling out the form. We will get back to you as soon as possible. 

For immediate assistance call

Call 250 686 1540