I was wondering what file system Android will use when I format my (external) SD Card. Can someone enlighten me?
Is it the one already used or exFAT or FAT32 or manufacturer dependent?
It will format the external micro SD card to FAT32.
TL;DR: Every Android uses FAT32. The Cluster size depends on the release. Existing partitions will be preserved. It will always use quick format.
Long Answer: After some more research here is the process as it was coded in the Android source code:
The Setting App displays a few confirmations then uses the Intent:
in 4.4 KitKat: https://android.googlesource.com/platform/packages/apps/Settings/+/kitkat-release/src/com/android/settings/MediaFormat.java
in 5 Lollipop: https://android.googlesource.com/platform/packages/apps/Settings/+/lollipop-release/src/com/android/settings/MediaFormat.java
in 6 they changed this. I will have to look more into it.
The ExternalStorageFormatter then uses
in 4.4 KitKat: https://android.googlesource.com/platform/frameworks/base.git/+/kitkat-release/core/java/com/android/internal/os/storage/ExternalStorageFormatter.java
in 5 Lollipop: https://android.googlesource.com/platform/frameworks/base.git/+/lollipop-release/core/java/com/android/internal/os/storage/ExternalStorageFormatter.java
This function calls
mConnector = new NativeDaemonConnector(this, "vold", MAX_CONTAINERS * 2, VOLD_TAG, 25); mConnector.execute("volume", "format", path);
in 4.4 KitKat: https://android.googlesource.com/platform/frameworks/base/+/kitkat-release/services/java/com/android/server/MountService.java
in 5 Lollipop: https://android.googlesource.com/platform/frameworks/base/+/lollipop-release/services/core/java/com/android/server/MountService.java
more info about vold: https://source.android.com/devices/storage/config.html
NativeDaemonConnectorfinally calls the native function to format the partition:
Volume::formatVol()This call is without a Volume Label and does not wipe the partition.
see Volume.cpp, VolumeManager.cpp, CommandListener.cpp
in 4.4 KitKat: https://android.googlesource.com/platform/system/vold/+/kitkat-release in 5 Lollipop: https://android.googlesource.com/platform/system/vold/+/lollipop-release
formatVol decides wether to format the partition (if one already exists) or the whole device (see
int Volume::formatVol(bool wipe)). When the latter is the case a new MBR is written. Then
Fat::format(devicePath, 0, wipe)is called. (Interesting sidenote: when mounting a volume Android is deleting autorun.inf if it exists: see
- in Fat::format (in Marshmallow it is named Vfat) the actual formatting is done with:
/system/bin/newfs_msdos. The parameters are different depending on the Android release, number of sectors is always omitted, wipe is always false:
- Lollipop and Marshmallow: -F 32 -O android -c 64 -A
- Kitkat: -F 32 -O android -c 8
- other systems might differ, see: https://android.googlesource.com/platform/system/vold/ /Fat.cpp or Vfat.cpp
Appendix: /system/bin/newfs_msdos syntax from https://android.googlesource.com/platform/system/core/+/lollipop-release/toolbox/newfs_msdos.c :
usage: newfs_msdos [ -options ] special [disktype] where the options are: -@ create file system at specified offset -A Attempt to cluster align root directory -B get bootstrap from file -C create image file with specified size -F FAT type (12, 16, or 32) -I volume ID -L volume label -N don't create file system: just print out parameters -O OEM string -S bytes/sector -a sectors/FAT -b block size -c sectors/cluster -e root directory entries -f standard format -h drive heads -i file system info sector -k backup boot sector -m media descriptor -n number of FATs -o hidden sectors -r reserved sectors -s file system size (sectors) -u sectors/track