20

I have a weird problem with the Android emulator. I have created a virtual device through Android AVD manager (newly created emulator with platform 2.1 and API level 7). I have tried with standard settings and with added hardware parameter for larger (256 MB) device RAM size but nothing changed.

I need to come files to the system partition to test a project (called haggle), but for some reason the system partition has no space from start.

aa a@aaa /home/haggle-0.2-android
$ adb -s emulator-5554 shell

 # df
df
/dev: 47084K total, 0K used, 47084K available (block size 4096)
/sqlite_stmt_journals: 4096K total, 0K used, 4096K available (block size 4096)
/system: 73600K total, 73600K used, 0K available (block size 4096)
/data: 65536K total, 18464K used, 47072K available (block size 4096)
/cache: 65536K total, 1156K used, 64380K available (block size 4096)

As you can see the system partition has 0K space available. When a connect a non-rooted HTC Nexus One and do the same I get these values:

/dev: 108896K total, 0K used, 108896K available (block size 4096)
/sqlite_stmt_journals: 4096K total, 0K used, 4096K available (block size 4096)
/system: 148480K total, 116364K used, 32116K available (block size 4096)
/data: 200960K total, 22296K used, 178664K available (block size 4096)
/cache: 97280K total, 1852K used, 95428K available (block size 4096)
/sdcard: 3864064K total, 118496K used, 3745568K available (block size 32768)

Why does the system partition on the emulator have 0K free space from beginning, and what can I do to change that? Even if I make the partition write-able with mount/remount I get the same 0K values.

Any tips?

5 Answers 5

29

Found the answer :)

When starting the emulator you can specify the partition size by -partition-size x emulator_name.

done through the terminal that is. Example:

emulator -partition-size 125 @AVD1

OR

emulator -partition-size 125 -avd AVD1

Note that the size must be bigger than your current system partition size. For the Android4.0.3 emulator the default size is already 168 so set your new partition-size to something bigger like 256

2
  • 6
    any way to do this through the AVD Manager?
    – vanevery
    Aug 15, 2011 at 18:38
  • Alt syntax: emulator -partition-size 125 -avd AVD1 Nov 9, 2011 at 6:07
12

Nowadays, -partition-size changes the /system/data partition, but not the /system partition space.

If you want to install the full GApps, for example, you will need more space.

The general procedure to do so in Unix is documented at https://unix.stackexchange.com/questions/104790/how-to-setup-a-growable-loopback-device

In short:

  1. Make a copy of system.img so that you don't modify the original one in the SDK (cp system.img system-extended.img)
  2. Grow your system-extended.img to your desired size (e.g., truncate system-extended.img -s 2G)
  3. Resize the inner ext4 filesystem (resizefs system-extended.img OR resize2fs system-extended.img)
  4. Use the new img file when calling the emulator via the -system <path/to/system-extended.img> parameter. The -writable-system parameter may also come in handy for you.
1
  • 1
    This answer should be the ACCEPTED answer, as it's the only one that allows to increase the '/sytem' partition size.
    – Pascal
    Apr 5, 2019 at 14:44
1

I had problem trying @ssice's answer on Android Q (Android TV if that matters).

Apparently the system.img is now a GPT partitioned disk image.

You can confirm this by running file system.img:

system.img: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x87,130,59), startsector 1, 2177023 sectors, extended partition table (last)

If this is also the case for you, here's what you can do on Linux:

  1. Resize system.img: truncate -s 3G system.img
  2. Recreate the partition table and create a partition that spans across it:
    • fdisk system.img
    • g for new GPT partition table
    • n for a new partition. choose partition number 1; accept defaults for a partition that will span the entire disk
    • w for saving the changes
$ fdisk system.img

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): g
Created a new GPT disklabel (GUID: 2E6B87B6-5492-47E0-A164-A148E24445A0).

Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-6291422, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-6291422, default 6291422):

Created a new partition 1 of type 'Linux filesystem' and of size 3 GiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.
  1. Mount system.img as a loopback device
    • losetup -fP system.img
    • grab allocated /dev/loopN (for example, /dev/loop1) from losetup -a | grep system.img
  2. Resize filesystem: resize2fs /dev/loop1p1 (/dev/loop1 partition 1)
1

For Android 10 emulator built from sources the following solutions works well:

$ emulator -partition-size 8192 -writable-system

If an emulator has been launched before it is necessary to clear out and rebuild it again:

$ make installclean
$ rm out/target/product/generic_x86_64/*qcow2
$ make
$ emulator -partition-size 8192 -writable-system

Successfully tested on the aosp_car_x86_64 target.

0

I found the problem. The SDK_MANAGER folder was inside a NON-STANDARD characters directory in my D disk (D:/ასერ/?dwe + joan/SKD_MANAGER) and thats why it couldnt get the correct partition size. I moved **SDK_MANAGER* to D:/**SDK_MANAGER* and problem solved!

( so, who has the error messages like "Invalid system partition size" or "panick: could not open avd1", this post might help)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.