Android Studio – No space left on device

I tried to install AVD (Marshmallow x86_64) to Android Studio 2.1 and the result was “An error occurred during installation: No space left on device”. The reason was too small /tmp partition on my Linux Fedora 24 desktop. I didn’t find how to change download path for Android Studio but temporary increased /tmp partition did the trick and virtual device was installed successfully.

First I’ll show complete error message:

To install:
- Google APIs Intel x86 Atom_64 System Image (system-images;android-23;google_apis;x86_64)

Installing Google APIs Intel x86 Atom_64 System Image
Downloading https://dl.google.com/android/repository/sys-img/google_apis/sysimg_x86_64-23_r14.zip
Installing Google APIs Intel x86 Atom_64 System Image in /home/dbunic/Android/Sdk/system-images/android-23/google_apis/x86_64
An error occurred during installation: No space left on device.
Failed to install Google APIs Intel x86 Atom_64 System Image!

Failed packages:
- Google APIs Intel x86 Atom_64 System Image (system-images;android-23;google_apis;x86_64)

My desktop specifications are: 8GB RAM and 2GB /tmp partition. /tmp partition is big enough for all used apps and Android Studio was the first one that complains (only during setting AVD). Other partitions in my PC have plenty of room but I didn’t find the way how to set Android Studio to use them. Instead, the solution in my case was to temporary create bigger tmpfs partition. So, the trick is only to set comment line in fstab file that defines /tmp partition.

UUID=5d2411e9-37a3-4141-a9ce-a11806e9f56c /      ext4  discard,noatime,defaults 1 1
UUID=7245cd57-0f32-4a81-9635-57a11de7c287 /boot  ext4  discard,noatime,defaults 1 2
UUID=0B04-6B6C          /boot/efi                vfat  umask=0077,shortname=winnt 0 2
UUID=6e2b719b-a81c-4ee8-a92c-2cfb0b834dde /home  ext4  defaults 1 2
#UUID=53c98893-160e-4f92-9828-44d4a102d410 /tmp  ext4  defaults 1 2
UUID=1b48d31e-8461-46cf-8c27-59d08a093d63 /var   ext4  defaults 1 2
UUID=5f3a979b-c9b9-4d9e-903b-caa0d952a9d7 swap   swap  defaults 0 0

… and here is result after reboot:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.8G     0  3.8G   0% /dev
tmpfs           3.8G  3.2M  3.8G   1% /dev/shm
tmpfs           3.8G  1.5M  3.8G   1% /run
tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/sda3        29G  5.5G   22G  20% /
tmpfs           3.8G  152K  3.8G   1% /tmp
/dev/sda2       380M  137M  219M  39% /boot
/dev/sda1       100M  8.3M   92M   9% /boot/efi
/dev/sdb4       216G   15G  190G   8% /home
/dev/sdb1       9.8G  3.0G  6.4G  32% /var
tmpfs           767M   16K  767M   1% /run/user/42
tmpfs           767M   32K  767M   1% /run/user/1000

During the boot process under systemd, if there isn’t defined /tmp partition, /tmp will be automatically mounted as a tmpfs and the size will be set to half of total RAM – this sounds like a magic. So, in my case I only commented line in /etc/fstab, reboot PC, installed AVD in Android Studio, return /etc/fstab as it was before and reboot again.

Complete documentation about tmpfs can be read here: https://wiki.archlinux.org/index.php/Tmpfs

Simple as that :)

11 thoughts on “Android Studio – No space left on device”

  1. I just added
    export _JAVA_OPTIONS=-Djava.io.tmpdir=/var/tmp

    at the top of studio.sh and everything works as expected now.

  2. The problem I am having is that I don’t have seperate /tmp and RAM is ~3.8GB so tmpfs becomes ~1.9GB which is not enough. What do I do?

  3. I did what harold and t4sk has recommended here. Still i’m facing the same problem.

  4. “I did what harold and t4sk has recommended here. Still i’m facing the same problem.”

    You can just use $ mount -o remount,size=xG /tmp/ and replace x with whatever Gigabytes you want over what $ df shows and then start Android Studio and it will work

  5. In Android Studio 3.1.1 at least, Harold’s trick doesn’t work – update files still go into /tmp and the update process fails due to insufficient disk space :(

  6. @Ian B
    Using Android 3.2.1 on Arch Linux it works just fine with the help that Harald provided. I would be surprised if this doesn’t work on 3.1.1. The version shouldn’t matter as far as I know.

Leave a Comment