This document explains the sdcard support in Android-x86 2.2 (froyo-x86). If you are using older version of Android-x86, see the Older version section for the differences.
The Android system uses vold as the mount daemon, which detects, mounts and monitors the status of sdcard. The mount daemon needs a configuration file to tell it what the sdcard device is. Before Android 2.1 (included), the file is /etc/vold.conf. Since Android 2.2 (froyo), it ships with a new implementation of vold (aka vold2). The configuration is changed to /etc/vold.fstab and its format is also changed. See system/core/rootdir/etc/vold.fstab in the Android source tree for the detailed explanations of the format.
However, a fixed vold.fstab can only support block device with fixed name. It is not suitable for x86 platforms with variable device names.
The Android-x86 project has extended the functions of the new vold to support auto-mount feature without a configuration file. That is, it can automatically detect any USB mass storage or MMC/SD card and mount it as the sdcard. Besides, if you don't have a real USB disk or SD card, it can simulate a fake sdcard to work smoothly with applications that need sdcard.
The Android-x86 vold works in this way
- If you have the configuration file /etc/vold.fstab, it reads and mounts the device specified in the file, as a normal Android's vold.
- If you don't have /etc/vold.fstab, you can set SDCARD variable in the kernel command line (/proc/cmdline) to control the behavior of vold. See the below section for details.
- Without /etc/vold.fstab and SDCARD variable, it works in auto-mount mode that detects a real external device (sdcard or USB disk) and mounts the first available vfat (dos filesystem) partition as the sdcard.
The SDCARD variable is set via kernel command line and controls which device to be mounted. You can set it in the grub or syslinux/isolinux menu.
The following values are supported in froyo-x86:
- SDCARD=<device node>
Specify a device node to be mounted. For example, SDCARD=sdc1 (or /dev/sdc1, /dev/block/sdc1). You can specify a whole disk (e.g., sdc) or a partition in the disk (e.g., sdc2). If specifying a whole disk, vold will use the first available vfat partition, or the whole disk if no partition table found.
Where <file> is a vfat image that can be mounted as a loopback device. You can create such an image on Android-x86 by the commands :
# dd if=/dev/zero of=/data/sdcard.img bs=1024 count=65536 (64MB image)
# losetup /dev/block/loop7 /data/sdcard.img
# newfs_msdos /dev/block/loop7
You can switch to console 1 by Alt-F1 to do that. Then add SDCARD=/data/sdcard.img to the kernel command line.
Use ramdisk as the sdcard. The ramdisk size is 4MB by default. You can change it by set ramdisk_size=N in the kernel command line. See kernel/Documentation/blockdev/ramdisk.txt for details. Note all data saved in the ramdisk will lose after power off.
Tell vold that /mnt/sdcard is already mounted. By default, vold will bind $SRC/sdcard or /data/sdcard to /mnt/sdcard if one of them exists.
Note not all applications work well with such kind of sdcard. It's only left for backward compatibility and may be removed in the future. Do not use it unless absolutely necessary.
There are several differences between the new vold of froyo-x86 and the vold of older Android-x86 version.
- The old vold uses /etc/vold.conf, and the mount point is /sdcard, while the new vold uses /etc/vold.fstab, and the mount point is /mnt/sdcard. But it also creates a symlink /sdcard -> /mnt/sdcard for compatibility.
- The old vold does not support SDCARD=<file> and SDCARD=ramdisk.
- SDCARD=<device node> is handled by the new vold directly, so it works better with the Android frameworks.
- The old vold supports vfat/ext2/ext3 filesystem, but the new vold only supports vfat filesystem. This is because Android frameworks does not support sdcard mounted on other filesystems. Even we can forcely mount an ext2/ext3 filesystem as the sdcard, it doesn't work well in some situations. So we decide to stop supporting them unless AOSP changes.