4

I'd like to install a bootable Linux system on a micro SD card, AND be able to use it as external storage for other devices, such as my Android phone.

The plan: Linux ARM on a Raspberry Pi 4.

If I insert an SD card (with Arch Linux ARM installed) into my phone, Android only detects the first partition of the SD card (the boot partition). The desired outcome is to mount my home partition with my music, and not the boot partition.

I have thought of 2 possible solutions:

  1. Find an Android file manager app that can access the 3rd partition (home)
  2. Make the first partition my home partition, and then the boot partition as the second, root as 3rd.

No luck with the first solution, and I really don't know how to approach the 2nd solution with a successful boot, and I can't install the system via USB, as Raspberry Pi doesn't support it.

Working solution, adding to Philip Couling's insight

I could not get Android to read a 2nd partition, no matter the filesystem (at least unrooted), so I deduced that the only choice I had based on my tests were to expand my boot partition, my first partition.

Android was able to read vFAT, but was not able to boot Linux (Raspberry Pi 4), but your mileage may vary. It was able to boot from FAT32.

I think the best possible file system available to be both read by Android, and to be bootable with a Raspberry Pi 4 is FAT32. Unfortunate, but it will get the job done.

My OSes of choice were either Manjaro or Arch, but their default installations make the boot partition FAT16. I was able to change it to FAT32 with the help of GParted, and remained bootable. It was crucial to make sure making sure the labels were identical for Manjaro to be able to boot (BOOT_MNJRO and ROOT_MNJRO) as it was instructed in "/boot/cmdline.txt"

The MicroSD card can now be used as a bootable system, AND used for extra storage for my Android phone. The goal was to use a 2nd MicroSD card as a backup drive, and still be able to use it as portable storage on my phone!

Appreciate Philip Couling's great insight, and using syslinks has made my home directory feel natural.

TuxForLife
  • 2,789
  • 1
  • 13
  • 19
  • related https://raspberrypi.stackexchange.com/questions/38876/raspberry-boot-from-different-partitions – ctrl-alt-delor Jan 04 '21 at 07:08
  • related https://superuser.com/questions/1518984/how-to-boot-from-selected-partition-in-raspberry-pi-3 – ctrl-alt-delor Jan 04 '21 at 07:10
  • related https://android.stackexchange.com/questions/190820/is-there-any-way-to-recover-data-from-2nd-sd-partition – ctrl-alt-delor Jan 04 '21 at 07:12
  • Hope you get an answer to this seemingly simple problem. Edit the question to make it clear: what have the 2nd and 3rd SD cards got to do with the problem? – ctrl-alt-delor Jan 04 '21 at 07:15
  • Getting mixed answers if I can even boot from a partition other than the first one "The Pi ONLY boots from the first partition on the SD card." – joan Stated on your first link, and I've read it elsewhere so it may not be possible if they are correct, but I'd love to try and confirm. – TuxForLife Jan 04 '21 at 07:27
  • 2nd link makes it seem like it IS possible – TuxForLife Jan 04 '21 at 07:28
  • 1
    And you're right, the 2nd and 3rd SD card part is kinda redundant, I'll remove that, thanks for the speculation and encouragement. – TuxForLife Jan 04 '21 at 07:30

1 Answers1

2

My first thought is that you need to find a filesystem that supports linux AND is accepted by Android. I suspect Android is quietly refusing to mount an ext4 partition.

My thought here is that Android's is deliberately refusing because ext2,3,4 partitions pose a security risk if not dealt with correctly. Unfortunately the features that pose a security risk (device files and unix style user permissions) are necessary to run linux ... i believe. So in short, I think you will have a big problem getting this to work.

What might work

What you are asking for is not unreasonable. You want to access your /home directory from android. Linux might need ext2,3,4 features for the OS but it generally doesn't need them for a user's home. It certainly doesn't need them for your /home/<username>/Music or /home/<username>/Pictures directory.

Rather than trying change your whole OS, you could easily create a FAT32 partition to put your media files on. If Android really doesn't like accessing a second partition, you could even expand /boot to give it enough space.

Once you have a partition that both can see, and is large enough for your media you can mount it to /media/home and move things around:

mkdir /media/home
mount /dev/sda3 /media/home

mv ~/Pictures /media/home
ln -s /media/home/Pictures ~

mv ~/Music /media/home
ln -s /media/home/Music ~

Don't forget to modify /etc/fstab to mount the partition automatically.

Philip Couling
  • 17,591
  • 5
  • 42
  • 82
  • I just realised that the Pi`s boot partition is some sort of FAT. root partition is ext4. So as a hack you could combine the boot and android data into one partition. – ctrl-alt-delor Jan 04 '21 at 12:30
  • @ctrl-alt-delor yes that's what I meant by expanding `/boot` – Philip Couling Jan 04 '21 at 12:34
  • 1
    Sorry for the delayed response, took some time building my new system ;) Updated my post on what exactly I did. Thanks for the reminder of syslinks, they have been useful for my common home directory folders, makes it feel more natural. – TuxForLife Jan 26 '21 at 23:17