Android emulator system partition no space from start
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
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:
- Resize system.img:
truncate -s 3G system.img
- Recreate the partition table and create a partition that spans across it:
fdisk system.img
g
for new GPT partition tablen
for a new partition. choose partition number 1; accept defaults for a partition that will span the entire diskw
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.
- Mount
system.img
as a loopback devicelosetup -fP system.img
- grab allocated
/dev/loopN
(for example,/dev/loop1
) fromlosetup -a | grep system.img
- Resize filesystem:
resize2fs /dev/loop1p1
(/dev/loop1
partition 1)
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:
- Make a copy of system.img so that you don't modify the original one in the SDK (
cp system.img system-extended.img
) - Grow your
system-extended.img
to your desired size (e.g.,truncate system-extended.img -s 2G
) - Resize the inner ext4 filesystem (
resizefs system-extended.img
ORresize2fs system-extended.img
) - 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.