2

Nowadays, phones don't have SD cards anymore, but some have a ton of storage. So, I was thinking of creating a fake external SD card using an extra partition to be able to store all of your zip flashable files, pictures, and music and have it stay when you inevitably format user data when flashing a ROM or whatever.

My question is: How to properly mount a partition as an SD card so that Android thinks you have an external SD? (you see it in a file manager, can store pictures on it directly, etc.)

What I've done already :

  • I have created an extra partition on my OnePlus 6 with parted, it's sda17
  • I have successfully mounted this partition to be able to use it normally (mount -t ext4 -o rw /dev/block/sda17 /external_sd) This command allows you to navigate to /external_sd and see your files, but Android doesn't think that you have an external SD card.

I'm thinking of using a Magisk module to mount everything properly at every boot (if this is even possible)

2
  • Its not true that phones dont have sdcards anymore. I still have them in the latest Samsung phones. Whats the purpose in making internal storage into sdcard ? It makes no sense to me. For me, the main advantage of an sdcard is that you can just transfer it to your new phone. How will this help ? Commented Jul 24, 2023 at 11:24
  • 1
    Every time you flash a custom rom the entire userdata partition is formatted (for a clean flash). If i were to buy a Redmi note 12 turbo with 1TB of storage, I'd like to allocate some of that space to have some form of permanent storage for photos, music, etc... Having it be a fake sd card would just allow apps to recognise it (if it's a directory in the root of the filesystem you can only access it with a rooted explorer, or termux). Also you are right, there are new samsung phones with sd cards, but none are good. They are less powerful that my 150€ Poco X3 Pro with less features. Commented Jul 25, 2023 at 15:54

2 Answers 2

1

It's just not possible, and even if it was, you would need root.

Jbrimbelibap is also right, every time you factory reset, it'll wipe ALL user data including newly created partitions.

1
  • Of course you need root to do that kind of black magic ;) ! Keep in mind I've already gotten an extra partition mounted and I have file on it on my test phone. It's already useful to store my app bakcups and zips for TWRP and Magisk as a permanent storage, so that part is confirmed. Really what I don't know is if "fooling android into displaying that partition as if it were an sdcard" is possible. Commented Jul 28, 2023 at 9:57
0

I like your idea, I have it too, and made it real.

Anyway, I have an SD card with 2 parts formatted as NTFS and a second partition formatted as NTFS too. Why NTFS? mount.ntfs mount it as u:object_r:vfat:s0, we need that for fewer bugs. When an app creates a folder in an ext4 partition, other apps can't access it because ext4 keeps uid, perms, etc.

mount.ntfs -o rw,dirsync,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1023,mask=7 /dev/block/sda36 /mnt/media_rw/[SDSERIAL]
mount -t sdcardfs -o rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6 /mnt/media_rw/[SDSERIAL] /mnt/runtime/default/[SDSERIAL]
mount -t sdcardfs -o rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18 /mnt/media_rw/[SDSERIAL] /mnt/runtime/full/[SDSERIAL]
mount -t sdcardfs -o ro,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18 /mnt/media_rw/[SDSERIAL] /mnt/runtime/read/[SDSERIAL]
mount -t sdcardfs -o rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=18 /mnt/media_rw/[SDSERIAL] /mnt/runtime/write/[SDSERIAL]
mount -t sdcardfs -o rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=9997,mask=7 /mnt/media_rw/[SDSERIAL] /mnt/pass_through/0/[SDSERIAL]
mount -o rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6 /mnt/media_rw/[SDSERIAL] /mnt/androidwritable/0/[SDSERIAL]
mount -o rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6 /mnt/media_rw/[SDSERIAL] /mnt/installer/0/[SDSERIAL]
mount -o rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6 /mnt/media_rw/[SDSERIAL] /mnt/user/0/[SDSERIAL]
mount -o rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,mask=6 /mnt/media_rw/[SDSERIAL] /storage/[SDSERIAL]

Automated and improved these commands via the Automate app using a second disk as a normal SD card (SD card mount under /mnt in a folder named its serial number and you can use 'mount --longopts' for learning mount options)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .