Moving Portage temporary build directory to an external disk
Recently, I ran into an issue where Portage required more temporary disk space than was available on my 120 GB SSD. To solve this, I moved Portage’s temporary build directory to a 16 TB external USB 3.0 drive.
This approach is clean, safe, and recommended for building very large packages such as Android Studio.
This is what we want to avoid with a small ssd drive

Prepare the directory (correct ownership and permissions)
Verify that the directory exists
Ensure the disk is always mounted
If the disk is mounted via /etc/fstab, ensure it is not marked as noauto.
If the disk is not mounted, emerge will fail hard — which is good protection against incomplete or broken builds.
Configure PORTAGE_TMPDIR
Now configure Portage to use the new temporary directory.
Clean up old temporary files (optional but recommended)
This frees up disk space on my 120 GB ssd drive
Test with a small package first
- Before building very large packages, it
is recommendedto test the setup using a small and fast package.
You should see a portage/ directory appear while the build is running, confirming that portage is using the external disk for temporary build files.
Result
- After this setup:
- Portage no longer consumes large amounts of space on the root filesystem
- Large packages (e.g.
Android Studio) build reliably - Disk space warnings and build freezes caused by insufficient temporary storage are eliminated
- This configuration is best practice for Gentoo systems with limited root disk space and large secondary storage.