Mobile Development 8 min read

Android Vold (Volume Daemon) Architecture and Operation Principles

Android Vold is a standalone daemon that bridges the kernel and framework, handling storage hot‑plug events such as USB, SD card, and internal partitions by receiving kernel uevents via Netlink, processing them in VolumeManager, and communicating with StorageManager through Binder to mount, encrypt, and manage file systems.

OPPO Kernel Craftsman
OPPO Kernel Craftsman
OPPO Kernel Craftsman
Android Vold (Volume Daemon) Architecture and Operation Principles

This article provides a comprehensive introduction to Android Vold (Volume Daemon), the system daemon responsible for managing storage hot-plug events in Android devices.

Vold Overview: Vold is a volume daemon that handles storage hot-plug events in Android, including: 1) USB MTP/photo transfer disk mounting/unmounting when connected to PC; 2) Storage device partition mounting/unmounting during device boot and shutdown; 3) File system mounting/unmounting during SD card insertion and removal. It also controls disk data encryption (FDE/FBE), file node and directory creation, and file system garbage cleanup during mount operations.

Vold Architecture: Vold runs as a standalone daemon process, positioned between the Kernel and Framework layers as a bridge connecting these two levels. It receives Kernel uevent messages through NetLinkManager, which are queued in NetLinkHandler and sent to VolumeManager, ultimately passing messages to the Framework's StorageManager. StorageManager stores the data and notifies registered services and applications.

Vold Startup Process: During Android system startup, the init process parses the init.rc file and executes the "start vold" command. The startup sequence includes: 1) VolumeManager initialization - cleans up folders, constructs internal storage directory (/data/media), creates EmulatedVolume object, sets device state to unmounted, and creates virtual disk at /data/misc/vold/virtual_disk; 2) VoldNativeService initialization - registers AIDL interfaces for communication with StorageManager; 3) NetlinkManager initialization - establishes socket connection to receive all uevent events and starts NetlinkHandler listener.

Vold Operation Principles:

1. Linux Kernel Uevent Mechanism: Uevent is a communication mechanism between kernel space and user space, used for hot-plug events. Uevent events are sent to user space as environment variables (strings). The kobject_uevent_env function performs two main tasks: collects environment variables related to the event (ACTION, DEVPATH, SUBSYSTEM), and sends the event to user space.

2. Vold and Kernel Communication: NetlinkManager starts the listener to monitor Kernel uevent events. NetlinkHandler inherits from NetlinkListener, which inherits from SocketListener. The startListener function begins monitoring messages, starts a thread to execute runListener, which loops to read socket messages and send them to clients. NetlinkListener receives callbacks and processes them further through onDataAvailable, reading data via uevent_kernel_recv, parsing with decode, and dispatching via onEvent. NetlinkHandler then obtains the VolumeManager singleton and calls handleBlockEvent for actual event processing.

3. Vold and StorageManager Communication: Vold communicates with StorageManager via Binder. StorageManager connects to Vold after SystemServer starts it, obtains the IVold interface via Binder, and registers mListener - the Vold AIDL interface corresponding to VoldNativeService. On boot completion, StorageManager performs lockuser/unlockuser operations, adds internal storage, resets Vold (calls VolumeManager reset), and starts user to create corresponding file directories linked to data storage partitions. After StorageManager reset, it re-executes mInternalEmulated->create(), notifies StorageManager, triggers InternalEmulated mount, and finally executes EmulatedVolume's doMount() to complete the actual mount process.

4. SD Card Mounting Example: The article provides a flow diagram illustrating the SD card mounting process based on the above Vold operation principles.

mobile developmentAndroidVoldSystem InternalsHot PlugKernel UeventStorage ManagementVolume Daemon
OPPO Kernel Craftsman
Written by

OPPO Kernel Craftsman

Sharing Linux kernel-related cutting-edge technology, technical articles, technical news, and curated tutorials

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.