Installing a Linux system externally and configuring for use with Android via USB

It hasn't even been a week, and you're writing about this again.

Right. I learned a thing so I am writing about it, shut up and read on.

Before you proceed...

  • Read this first for a basic outline of concepts recycled here.
  • Use of XDG stuff is prioritized over linking with ln
  • Keep your physician on speed-dial.
  • Genders are mentioned, prepare to be triggered.

This is mostly an addendum to the article linked above for Android use, because I didn't want to bother with appending onto that. Also, if anyone encounters Android-specific issues, they can leave that here, rather than adding senseless noise in a more general-purpose article.

Provisioning changes for use with an Android system

Android's limited capabilities

If any USB-connected media is attached to an Android device, it is mandatory to have a partition formatted as ExFAT before any files can be deposited onto the attached media. There are however a few problems with this;

  • Mandatory use of ExFAT ruins the idea of using an NTFS partition as overflow space
  • gparted by default doesn't even do ExFAT, no matter what you do (for legal reasons)
  • Not only that, gnome-disks' device map is buggy and renders partitions incorrectly after editing.
  • ExFAT doesn't wear well on Mac OS X, and IT admins would have to provision use of it wherever you happen to use a guest Apple PC.

All of the above makes half of what I wrote earlier invalid, but we can still do something else based on a similar principal with xdg-utils which will be explained later.

Other stuff you'll need

  • An adapter to use SATA-connected media with USB
  • If the host machine uses type-C and a Thunderbolt-compatible host controller, even better
  • A cable to hitch other media via USB, which can be terminated from the adapter to-be-used in one of two ways;
  • If non-replaceable, with a cable which has a type-A socket that terminates with the connector variant of the socket in your phone
  • If non-replaceable, with a type-A coupler, then another type-A cable which terminates with the connector for the socket in your phone
  • If replaceable, a special-purpose cable which terminates at both ends compatible with your adapter and phone
    • The end which goes into your phone can be one of three connections (usually);
      • High-speed type-B
      • Super-speed type-B (Samsung phones until type-C use this, usually)
      • Type C
Expand this to read more about USB.Why so many standards? It's simple to understand, really; USB started off as a host / client connector, using different types; type-A and type-B. Over time, miniaturization of the client connectors yielded mini-B, which is most often used on the cheapest of novelty equipment due to high supply and low demand, because no smartphone manufacturer in their right mind would use it over micro-B for host controller and connector thinness.

USB 1.0 and 1.1 had modest speeds at the time. As there were continued data throughput demands, the consortium behind the USB standard established version 2.0, as well new requirements for cables. If you have a cable with a white substrate for the copper pins, that is an old-style 1.0 / 1.1 cable, while 2.0 had a black substrate. This was not always true, but you could usually validate claims of capability by that alone.

When USB 2.0 was released, and after the proliferation of Android handsets most manufacturers agreed upon USB 2.0 and the high-speed micro-B connector. But not Samsung; Dissatisfied with the performance of USB 2.0, they contracted manufacturers to make what is known as super-speed micro-B. This wider connector is often seen on their products, but other manufacturers purposed the connector for replaceable USB 3.0 cables in more professional-grade products where the cable is treated as something disposable. If this is the case, you can upgrade to USB type-C simply by replacing the cable, but do not expect USB 3.1 speeds.

Speaking of, USB type-C came out with USB 3.1, which to add even more confusion resellers referred each as 3.0 G1 and 3.0 G2, before it was made clear that type-C was expressly for USB 3.1. Type-C was made as a Universal standard that could be plugged in both ways. While USB type-A cables had similar features for some time, it was not common, and USB type-C is suppose to not just embrace both host / client roles, but also be depolarized as a standard feature so that plugging it into your phone and future computers isn't a guessing game.

In short;

  • USB type-C came out with USB 3.1 and works with everything in the USB spectrum
  • Before type-C, type-A is for host devices, while type-B is for client devices
  • Any USB plug can be paired with any host controller, but USB sockets only work best with their intended controllers.

Because I waxed on about partitions and related crap in the previous article I wrote, I won't even bother; read that please and thank you.

Executing provisioned changes

A lot of this is also very similar to the article I referenced above, so I'm glossing over the broader details in favour for explaining how to deal with Android.

Configure your partitions initially with gparted so you have a partition for the system, maybe a partition for /home and some swap space as you would a setup with NTFS as overflow. But rather than using NTFS, ExFAT is going to be used instead. There is a significant issue with that, however...

How to deal with ExFAT

This can be set up before or after system installation, so long there is unallocated space for gnome-disks to do its thing.

gparted can't make it. There are no options anywhere else for it. So what is one to do? Fortunately there are packages to handle this, but after initial configuration (and inclusion of an extended partition if you please), you can ditch gparted because it simply doesn't work. So here's how to make an Extended File Allocation Table partition;

  • sudo apt install exfat-*
  • If that doesn't work because you're not using bash for shell, that'll install exfat-fuse and exfat-utils
  • Open gnome-disks and select the media with unallocated space; select the unallocated space therein and click on the plus symbol
  • Choose to use a custom partition format, specify exfat

:clock9: This has changed with time, and differs slightly but it is easier nowdays to create an ExFAT partition within gnome-disks. Not so sure about the buggy drive map display however.

The device map goes a little screwy after that; Close gnome-disks, unmount everything, disconnect the media and plug it back in (or if using the system already, restart) to resolve how the map displays the available partitions.

Once you confirm in gnome-disks the ExFAT partition exists, you can then select it and have the kernel mount the drive on boot like you would an NTFS partition for the same purpose, but additional changes are necessary to purpose the partition as a general storage area for the stuff in your folder in /home, all which can be done with xdg-user-dirs-update. Modifying my previous script for linking directories into an NTFS partition, the below will instead assign the folders there to reside in the ExFAT partition.

For brevity, I will assume the partition is named Android and is mounted in /mnt but you can call it whatever you please, just modify the script to suit.

# Replace "$USER" with specific usernames if necessary!
### Make new folders in the ExFAT partition
mkdir -p /mnt/Android/Documents
mkdir -p /mnt/Android/Downloads
mkdir -p /mnt/Android/Pictures
mkdir -p /mnt/Android/Music
mkdir -p /mnt/Android/Videos
### Duplicate old contents (if any)
cp -R ~/Documents /mnt/Android/Documents
cp -R ~/Downloads /mnt/Android/Downloads
cp -R ~/Pictures /mnt/Android/Pictures
cp -R ~/Music /mnt/Android/Music
cp -R ~/Videos /mnt/Android/Videos
### Delete folders
rm -rf ~/Documents ~/Downloads ~/Music ~/Pictures ~/Videos
### Create symbolic links to ExFAT partition
### - This is only to make saving things in programs easier
ln -s ~/Documents /mnt/Android/Documents
ln -s ~/Downloads /mnt/Android/Downloads
ln -s ~/Music /mnt/Android/Music
ln -s ~/Pictures /mnt/Android/Pictures
ln -s ~/Videos /mnt/Videos/Documents
### Change XDG's reference for the now-deleted folders
### - This is only if you want XDG to use real directory locations
xdg-user-dirs-update --set DOCUMENTS /mnt/Android/Documents
xdg-user-dirs-update --set DOWNLOAD /mnt/Android/Downloads
xdg-user-dirs-update --set MUSIC /mnt/Android/Music
xdg-user-dirs-update --set PICTURES /mnt/Android/Pictures
xdg-user-dirs-update --set VIDEOS /mnt/Android/Videos

If you use Bluetooth and didn't choose to recreate folders as links from home to the ExFAT partition, blueman-services will complain about Downloads being relocated; fix that by telling it where the new Downloads folder is, and that should resolve the issue.

Conclusion

It's not easy making something that works with Android, but it's also not insurmountable. Whether it's worth it depends on how much you value a hardline connection between your disk and your phone, but because bluetooth-enabled SATA adapters fell out of fashion for the inherit security concerns of anyone being able to find the device and access it, using the USB socket provided with your device is the only way to transfer from a disk to your phone content you wish to use. Being able to plug it into your computer running Windows, and booting a Linux system living alongside it is quite the bonus.

1 Like

That’s all swell. I’ve been using a common sdcard format with linux and android for years. The first partition needs to be primary and can be generated by gparted as a “fat32” partition. Any other partitions can be as you like, on the sdcard i keep in my android phone i have two linux distros and two data partitions, all of which are ext2 (which is just ext4 without the useless logging). The result is that if i take the sdcard out of my android phone and put it in a reader, it is fully bootable on laptop or desktop and i get to choose between several linux distros.

I have no idea why any sane person would want to use NTFS for anything, but i walked away from Windows years ago and have no use for anything coded up by Microsoft.

Have fun.

I have no idea why a sane educational institution would teach Microsoft Office but they do. And what sane video game developer would use DirectX for their game? Guess that’s why the lot of them are crazy-bonkers because not only are they stressed out by “The crunch”, but they’re also coding in antiquated formats billed as for the modern era. Oh well.

My point for all of that rambling is to say for some people, they have to be on Microsoft’s systems (or at least VM them) and having a common format Linux and Windows systems can read is a nice convenience, especially if you can symlink into the Ext4 partition content from an NTFS partition because they share that common goal in mind. ExFAT not being linkable is a bit of bother, but there is the added convenience of using the files you make on either system in Android.

(psst, not to burst your bubble but Microsoft made ExFAT too! What it’s doing on Android and why my firmware doesn’t allow for either Ext4 or NTFS is beyond my comprehension.)

@tiox, you seem to imply that writing to an NTFS partition from linux has advanced through reverse-engineering to the point where it’s actually safe, is that correct, or has MSFT lifted their skirts on the great magickal secrits of their proprietary filesystem NTFS, or whut?

Yah, i know some people are coerced into using Windows, and some use it because they think Apple is the only alternative and they don’t have the cash, and that’s about as unfortunate as the fact that we have to pay money for food and shelter, but it’s the way it is, until people learn better.

imo of course, i’ve been told i know nothing enough times to stop giving a damn what people think, mea culpa.

I never said you didn’t know anything. What I was trying to convey is the necessity of Microsoft and Microsoft’s formats for the kid who wants to go to school and get passing grades. I say that as somebody who has been burned by open-source software not because it sucked; it didn’t, I got along with it but it was still mandatory I save my work in Microsoft formats because the community college I was taking part in wouldn’t even try to use an open-source software. I would drive people up the wall with requests to at least check it out, and see if it’s worth the bother because then their students wouldn’t have to pay for software to do their work, they’d rather keep the kickbacks flowing while showing students software that not even Fortune 500 companies would touch, with a price tag. I didn’t go along with it and got screwed massively.

With that tangent out of the way let’s address the big bug about NTFS you mentioned. I’ve been using NTFS and Ext4 side-by-side for a good long while and I hadn’t got burned by it yet. For the kid who has to use Windows but would rather use Linux the option to not maintain user data between two separate filesystems across two separate partitions is really nice.

I made this thread with the kid who has an Android phone, wants to edit things with their phone and needs to interact with those files on Windows in mind. Because I don’t want every kid who uses Linux to end up like me and be heartbroken about the lack of exposure and appreciation within educational institutions. The harsh, cold reality at present is not everybody accepts freely-available tools as a solution, and when it comes between arguing with a broken system or sucking it up for a certificate, I would rather people not compromise themselves for martyrdom.

Didn’t mean you personally @tiox, sorry to have left that implication open.

Yes, i understand that economic coercion exists; it sucks, but it exists.

If i was a kid with an android phone and needed to touch Windows with a stick, i’d be using dropbox or google-drive for the sharing, and keep the two systems in strict isolation as much as possible.

Mileage varies, people do what they have to… i have to stay as far away from anything Microsoft as possible, i couldn’t even use the later versions of Windows if i so much as read their terms-and-conditions, to me it feels like signing a donor-card when there’s a hot black-market for body-parts, but that’s jmo. Virus shield? Heh, i got enough problems just getting things done without inviting some trojan-horse “gonna protect you for money” app along for the trip.

I would honestly run Windows in a VM and only stick with the Administrator account, since Windows 8 onward admin is a fair bit locked down. The only caveat is certain configuration program can’t be used by Administrator but that’s alright; I already would have my physical system configured how I want at that point. Shame I don’t have the machine to do that yet.

What do you need and where do you need it?

An entirely new machine, to be frank. But I think some time in the future I’m going to just squeeze a modern PC into one of my old desktop cases.

I’m a bit confused. Are you talking about a machine to run windows, or to run linux, or both? Does it need to be a desktop or a laptop? In either case i’m not sure what the actual problem is.

Maybe we live in different realities. In the one where i live, there are many used systems available for cheap. Even new systems are fairly cheap unless you need a hot hardware setup. And given the lag between new hardware coming on the scene and full support in linux, in general the latest and greatest hardware probably ought to be avoided unless you’re going to be writing drivers specifically to support that new hardware.

Clearly i don’t understand what you’re attempting to do, what its benefit is, or what would be necessary in order to do it. Given the flexibility we have with today’s linux, you could probably use an external drive enclosure or even a simple USB stick to get the job done, without devoting a dedicated machine to it.

otoh if two machines are required and you only have one, that could present an issue. if it was my issue i’d just use one of my old laptops, which i keep around for testing purposes or as desperation-backups… and since they are old and slow (intentionally kept because they are old and slow, so i can see where the software needs sped up) maybe i’d need something more modern and dip into craigslist for last year’s model for not much cash outlay.

Apologies if i’ve stepped on a slip-of-the-tongue so to speak, sometimes in the past i’ve made a comment to a friend, about how i couldn’t do this or that, and been offered the tools to do it with, whereupon i’ve realized that i really didn’t want to do it in the first place. Of course me, if it had anything to do with Windows, i definitely wouldn’t want to do it in the first place.

My bad, apologies, me shut up now.

Oh, that; A reasonably powerful setup I can run a Linux system (like Ubuntu MATE) on while being able to VM Windows and play whatever stupid DirextX-only title I can’t run in Wine. And I’d set up Windows just so it executes a shell string that runs only Steam and Task Manager so the Windows VM would just be a games appliance to go with my “Budget” high-end build.

But that’s a pipe dream years away from now.

Is it? I'm not a fan of running virtual machines on linux. But then i last fiddled with virtualbox years ago now, and found it not up to min-spec at that time.

I am getting the feeling, correct or not, that you are a "hardcore" desktop guy, who doesn't fiddle with those laptop toys. :wink:

A really good, really solid, linux distro, the one we've waited for since back when it really was "a pipe dream years away from now" is no longer a pipe dream years away from now, if what i've been reading about 17.10 is more than hype.

I've run across any number of powerful older laptops, especially some of the Dell "professional" series laptops, and some obsoleted-by-Apple macbooks (which reputedly will run linux) that don't seem all that bad. I don't know where you are, whether there is a craigslist or similar site that amounts to an online flea-market, where you live. Some are running multi-core i3 and above processors, nice fast SSD's are fairly cheap, and memory isn't likely to have gotten more expensive than when i last bought some.

Whatever friend @tiox, i've already hosed up my "me shut up now" comment, but i'm getting the feeling that maybe there are other things you'd prefer to be doing instead of whatever you were talking about doing with Windows, and that is by no means a condemnatory or critical comment, just perhaps something to consider.

I've no room to criticize anyone, i have a quite capable xps13 yet here i sit talking instead of writing code, go figure.

I know, right? Also, I am typing this from a laptop, but I am a bit of a desktop nerd and I would so love to have one that doesn’t suck. I have boxes that’ll take an ATX case and they’re 100% opaque so what things look like doesn’t matter. However water-cooling will be more than a little challenge, might end up de-riviting the top and making a block of wood to hold the rad in place.

I want AMD’s Crossfire to beat the pants right off of nVidia’s SLI with their Vega line so freesync can actually mean something with a multi-card setup. If only i had the money… Oh well. It’ll be a single GPU setup anyway which would work with EK Water Blocks’ Fluid Gaming 120G aluminium kit, though it ships with a double rad, would rather a triple if I can find an aluminium triple to go with it. That would limit my compatibility to nVidia cards unless after I am done writing this they’ll had figured out similar solutions for cheaper AMD cards.

To be honest, i haven’t ever seen a computer game that was worth starting up, since Adventure in the 1970s. Hey, i’m old, and i always did run with scissors.

To be honest, i haven’t ever seen a computer game that was worth starting up, since Adventure in the 1970s. Hey, i’m old, and i always did run with scissors.