VMware虚拟机中Android 7.1-rc2模拟器内部存储空间扩容求助
Hey there! I’ve dealt with this exact problem before—expanding the VMware virtual disk doesn’t automatically resize Android’s internal storage because the OS still uses the old partition table. Let’s fix this step by step using the terminal emulator:
Prerequisites
- Confirm you’ve already expanded the VMware virtual disk through its settings (you mentioned you did this, so we’re ready to go)
- Have the Terminal Emulator app installed on your Android emulator, or enable USB Debugging to use
adb shellfrom your host machine - You’ll need root access (most emulators come with root enabled by default; if not, toggle it in the emulator’s settings)
Step 1: Verify Disk & Partition Status
First, let’s make sure Android recognizes the expanded disk:
- Open Terminal Emulator and run
suto gain root privileges (tap "Allow" if a root access prompt pops up) - Check your disk and partitions with:
You’ll see your main disk (usuallycat /proc/partitions/dev/sdaor/dev/mmcblk0) has the new larger capacity, but the/datapartition (where internal storage lives) is still stuck at its old size.
Step 2: Resize the /data Partition
We’ll use fdisk to adjust the partition table. Warning: This can cause data loss if done incorrectly—back up any important files first!
- Run
fdisk /dev/sda(replace/dev/sdawith your disk identifier from Step 1) - Follow these prompts in
fdisk:- Type
dand press Enter to delete the existing/datapartition (enter the partition number when asked—find it fromcat /proc/partitionsorfdisk -l) - Type
nand press Enter to create a new partition:- Choose
pfor primary partition - Use the same partition number as the one you deleted (e.g.,
3) - For the starting sector, enter the exact same value as the original
/datapartition (this is critical to keep your data intact—check this from the earlierfdisk -loutput) - For the ending sector, just press Enter to use the maximum available space
- Choose
- Type
wand press Enter to save the new partition table
- Type
Step 3: Reboot the Emulator
The new partition table won’t take effect until you restart the emulator. Reboot it either through Android’s settings or by running reboot in the terminal.
Step 4: Expand the File System
After rebooting, we need to stretch the file system to fill the new partition:
- Open Terminal Emulator again, run
suto get root - Run the following command (replace
/dev/sda3with your new/datapartition path):
If you get an error about needing to check the file system first, run:resize2fs /dev/sda3
Then trye2fsck -f /dev/sda3resize2fsagain.
Step 5: Verify the Fix
Check if the internal storage has expanded by running:
df -h /data
You should now see the new, larger capacity listed.
Troubleshooting Tips
- If
resize2fsfails because/datais mounted, reboot into recovery mode (hold power + volume up in the emulator) and run theresize2fscommand from recovery’s shell - If you don’t have Terminal Emulator, use
adb shellfrom your host machine: enable USB Debugging in Android’s Developer Options, connect viaadb connect <emulator-ip>, then run the same commands as above
内容的提问来源于stack exchange,提问作者ElMeSaFeR

