Run Android on your PC

SD-Card How To

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.

SDCARD Variable

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.

• SDCARD=<file>

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.

• SDCARD=ramdisk

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.

• SDCARD=premount

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.

Older Version

There are several differences between the new vold of froyo-x86 and the vold of older Android-x86 version.