Dưới đây là ví dụ về cấu hình bộ nhớ ngoài cho nhiều loại thiết bị. Chỉ bao gồm các phần liên quan của tệp cấu hình.
Do các thay đổi về cấu hình trong Android 6.0 (chẳng hạn như việc xoá lớp phủ tài nguyên storage_list.xml
), các ví dụ về cấu hình được chia thành hai danh mục.
Android 5.x trở xuống
Chỉ thẻ chính vật lý
Đây là cấu hình thông thường cho một thiết bị có một thiết bị lưu trữ ngoài là thẻ SD thực, chẳng hạn như Nexus One.
Trước tiên, bạn phải gắn thiết bị thực tế thô trong /mnt/media_rw
, nơi chỉ hệ thống và trình nền FUSE mới có thể truy cập. Sau đó, vold
sẽ quản lý dịch vụ fuse_sdcard0
khi nội dung nghe nhìn được chèn/xoá.
fstab.hardware
[physical device node] auto vfat defaults voldmanaged=sdcard0:auto,noemulatedsd
init.hardware.rc
on init mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw mkdir /storage/sdcard0 0700 root root export EXTERNAL_STORAGE /storage/sdcard0 service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0 class late_start disabled
storage_list.xml
<storage android:mountPoint="/storage/sdcard0" android:storageDescription="@string/storage_sd_card" android:removable="true" android:primary="true" android:maxFileSize="4096" />
Chỉ mô phỏng chính
Đây là cấu hình thông thường cho một thiết bị có một thiết bị bộ nhớ ngoài được sao lưu bằng bộ nhớ trong trên thiết bị, chẳng hạn như Nexus 4.
init.hardware.rc
on init mkdir /mnt/shell/emulated 0700 shell shell mkdir /storage/emulated 0555 root root export EXTERNAL_STORAGE /storage/emulated/legacy export EMULATED_STORAGE_SOURCE /mnt/shell/emulated export EMULATED_STORAGE_TARGET /storage/emulated on fs setprop ro.crypto.fuse_sdcard true service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated class late_start
storage_list.xml
<storage android:storageDescription="@string/storage_internal" android:emulated="true" android:mtpReserve="100" />
Mô phỏng chính, phụ thực
Đây là cấu hình thông thường cho một thiết bị có nhiều thiết bị lưu trữ ngoài, trong đó thiết bị chính được sao lưu bằng bộ nhớ trong trên thiết bị và thiết bị phụ là thẻ SD thực, chẳng hạn như Xoom.
Trước tiên, bạn phải gắn thiết bị vật lý thô trong /mnt/media_rw
, nơi chỉ hệ thống và trình nền FUSE mới có thể truy cập. Sau đó, vold
sẽ quản lý dịch vụ fuse_sdcard1
khi nội dung nghe nhìn được chèn/xoá.
fstab.hardware
[physical device node] auto vfat defaults voldmanaged=sdcard1:auto
init.hardware.rc
on init mkdir /mnt/shell/emulated 0700 shell shell mkdir /storage/emulated 0555 root root mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw mkdir /storage/sdcard1 0700 root root export EXTERNAL_STORAGE /storage/emulated/legacy export EMULATED_STORAGE_SOURCE /mnt/shell/emulated export EMULATED_STORAGE_TARGET /storage/emulated export SECONDARY_STORAGE /storage/sdcard1 on fs setprop ro.crypto.fuse_sdcard true service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated class late_start service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1 class late_start disabled
storage_list.xml
<storage android:storageDescription="@string/storage_internal" android:emulated="true" android:mtpReserve="100" /> <storage android:mountPoint="/storage/sdcard1" android:storageDescription="@string/storage_sd_card" android:removable="true" android:maxFileSize="4096" />
Android 6.0
Chỉ thẻ chính vật lý
Đây là cấu hình thông thường cho một thiết bị có một thiết bị lưu trữ ngoài là thẻ SD thực, chẳng hạn như Android One ban đầu. Không có bộ nhớ dùng chung phụ và thiết bị không thể hỗ trợ nhiều người dùng.
fstab.device
/devices/platform/mtk-msdc.1/mmc_host* auto auto defaults voldmanaged=sdcard0:auto,encryptable=userdata,noemulatedsd
init.device.rc
on init # By default, primary storage is physical setprop ro.vold.primary_physical 1
Chỉ mô phỏng chính
Đây là cấu hình thông thường cho một thiết bị có một thiết bị bộ nhớ ngoài được hỗ trợ bởi bộ nhớ trong trên thiết bị, chẳng hạn như Nexus 6.
- Bộ nhớ dùng chung chính (
/sdcard
) được mô phỏng trên bộ nhớ trong. - Không có bộ nhớ phụ trên thẻ SD.
- Hỗ trợ thiết bị lưu trữ USB OTG.
- Hỗ trợ nhiều người dùng.
fstab.device
/devices/*/xhci-hcd.0.auto/usb* auto auto defaults voldmanaged=usb:auto
Mô phỏng chính, phụ thực
Đây là cấu hình thông thường cho một thiết bị có nhiều thiết bị lưu trữ ngoài, trong đó thiết bị chính được sao lưu bằng bộ nhớ trong trên thiết bị và thiết bị phụ là thẻ SD thực, chẳng hạn như Xoom.
- Bộ nhớ dùng chung chính (
/sdcard
) được mô phỏng trên bộ nhớ trong. - Bộ nhớ phụ là khe cắm thẻ SD thực tế có thể được sử dụng.
- Hỗ trợ nhiều người dùng.
fstab.device
/devices/platform/mtk-msdc.1/mmc_host* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata