Access to External SD Card

For access to the external SD card from the Debian system, you need to grant your Debian user the proper permissions and you need to mount the partitions in a location accessible to your Debian user.

First, we will create the mount points in /home/soul/storage (and give the "root" user ownership of those directories).

d$ mkdir -p /home/soul/storage/ext2part

d$ mkdir -p /home/soul/storage/vfatpart

d$ sudo su

d# chown root:root /home/soul/storage/ext2part

d# chown root:root /home/soul/storage/vfatpart

d# chown root:root /home/soul/storage

Next, we return to the Android system to mount the EXT2 partition and bind mount the VFAT partition in directories accessible to "soul"

a# mount -t ext2 /dev/block/vold/179:34 /data/local/mnt/home/soul/storage/ext2part

a# mount -o bind /mnt/media_rw/sdcard1/ /data/local/mnt/home/soul/storage/vfatpart

Having mounted the EXT2 partition, we now return to the Debian system and change ownership of the files in the EXT2 partition to "soul" and set the file permissions so that only "soul" may write to the EXT2 partition.

d# chown soul:soul /home/soul/storage/ext2part

d# chmod 755 /home/soul/storage/ext2part

Functions to mount and unmount external partitions are included in the d4cmdeb script.

note on file permissions

It's important to prevent Android applications from accessing the EXT2 partition. If they do, they will prevent your Debian user from accessing their files because the Android applications will change the file permissions of every file (on the EXT2 partition) that they write to.

When sandboxing applications, the Android system assigns each application to a unique user and runs the application as that user. File permissions problems generally do not arise between Android users/applications because they save user data to a VFAT file system (which has no concept of file permissions).

But the EXT2 partition is aware of users, groups and file permissions, so -- to avoid file permissions problems -- you should only allow your Debian user to save to that partition. You may safely allow Android applications to read from the EXT2 partition, but do not allow them to write to the EXT2 partition.

Applications running in the Debian system can safely read and write to both the VFAT and the EXT2 partitions however, so we only need one rule: "only allow 'soul' to write to the EXT2 partition."

d# chown soul:soul /home/soul/storage/ext2part

d# chmod 755 /home/soul/storage/ext2part

The chown command makes soul the "owner" and "group" of the /home/soul/storage/ext2part/ directory. The chmod command makes the directory readable and writeable to the owner (i.e. soul, our user on the Debian system), but only readable (i.e. not writeable) by other users, thus preventing Android applications from saving to the EXT2 partition.

Copyright © 2014-2024 Eryk Wdowiak