Category Archives: Tech

Galaxy Note 4: Spurious Wakes and the Home Button

I love my GN4 phone but it has a problem: it wakes up (screen turns on) randomly while in my pocket. When this happens, the screen is on and contact with the inside of my pocket causes spurious random screen touches which is highly dangerous. Not just the risk of butt-dialing people, but it could also change settings, uninstall apps, etc.

The cause is simple. The home button wakes the phone, and it protrudes slightly, so it’s very easy to trigger while in a case or pocket. The best fix would be a system checkbox enabling users to prevent the home button from waking the phone. When disabled, the only way to wake the phone would be the power button, which is quite firm and never is accidentally pushed.

However, Samsung’s response to this is idiotic: “don’t put it in your pocket”. Because Samsung has their heads in the sand (to be polite) on this, users have come up with their own solutions,

One is to install Xposed. But this is a sledgehammer. It works but I didn’t want to deal with it.

Since my device is rooted, I figured there must be some system config text file I could edit to get what I wanted. I didn’t find exactly what I wanted–simply disable wake on the Home button. But I found something close enough that works: swap the Home and Menu buttons.

On my GN4 running T-Mobile Android 6.0.1, the file to edit was: /system/usr/keylayout/Generic.kl

Change two lines:

key 172 HOME
key 254 APP_SWITCH

So they read:

key 254 HOME
key 172 APP_SWITCH

Reboot.

The App Switch (Menu) button will now be Home button, and vice versa. And the Home button will not wake the phone. Nor will the Menu or any other button. The only way to wake the phone will be to press the power button.

My phone no longer randomly wakes up in my pocket. No more butt-dialing, accidentally rearranged home screens, uninstalled apps, or hot phone. No more wasted battery consumption. It’s a bit strange to get used to swapped Menu & Home buttons, but the benefits are worth it.

Note: I tried editing /system/usr/keylayout/gpio-keys.kl and removing the WAKE_DROPPED indicator. Disabling the home button’s WAKE feature without remapping buttons would be ideal. But this didn’t work; it had no effect. Apparently it worked in prior versions of Android, but Samsung changed the way keys are mapped in 6.0.1.

Ubuntu VLC DAC Audio

I recently got a JDS Labs Element DAC + headphone amp. I drive it from my Ubuntu desktop using VLC as the audio player. It’s plug and play – no drivers needed. However, best results come after applying a few tips:

VLC Audio Device: The DAC has 17 output devices that appear in VLC. Which one to use? Use Pulse Audio if you want to hear a mix of all audio on the computer. Pulse Audio mixes all sources and resamples them if necessary to a common rate. Use JDS Labs Element DAC, USB audio direct hardware device without any conversions if you want to hear the audio track in its native sampling rate & bit depth, and nothing else. I prefer this for best sound quality.

VLC Output Module: use Pulseaudio audio output if you want to hear a mix of all audio on the computer. Use ALSA audio output if you want to bypass Pulseaudio to hear the audio track and nothing else.

VLC occasionally stopped playing and popped up an error saying “Device or resource busy”. If you’re using ALSA, only one app at a time can use the device. For example, if the browser tries to play a video it can steal the device from VLC. Also, VLC seems to have a bug in which it occasionally steals the device from itself when switching tracks. Adding a udev rule made this happen far less often. Add a file called 41-jdslabs-dac.rules to directory /etc/udev/rules.d. Make the contents like this:

# JDS Labs Element DAC
SUBSYSTEM=="usb", ATTR{idVendor}=="262a", MODE="0666", GROUP="plugdev"

This makes the JDS Labs DAC accessible to any Linux user.

Audio Glitches: Occasionally, once every hour or so, the audio will stop for a moment, then resume. I believe this is because the JDS Element uses USB adaptive mode, not async. This makes it compatible with more computers. Some people claim that adaptive move has more jitter and lower sound quality, but measurements belie this claim.

More audio glitches: Occasionally I would hear tics in the music, as if the computer CPU were too busy to deliver audio. Re-nicing the VLC process to -15 fixes this.

Net Neutrality is Misguided

This article in Tech Crunch sums the argument in favor of Net Neutrality:
https://techcrunch.com/2017/05/17/defend-net-neutrality/

Everyone agrees on the end: we want an open internet. But there’s more than one means to that end. We disagree on the means, not the end. The Senate Democrat perspective assumes that ISP companies will infringe the speech of their customers or restrict their traffic flow, unless government regulators prevent this. So they conclude we must grant government this new power.

This perspective is misguided in two ways. First, it assumes new government powers are the only way to prevent ISP companies from restricting content or traffic flow in ways that harm consumers. Second, it ignores the risk and cost of these new government powers.

These assumptions are based on an idealistic perspective of government. This can be seen in some of the comments from proponents of Net Neutrality, like “its [the FTC] effectiveness may be a matter of opinion, but count on it: we’re better off with the FTC than without it”, or “that meant more paperwork to be sure, but consumers were safer”. This idealistic perspective ignores that fact that government agencies are just another type of large corporation, having their own self-perpetuating motives and are often used by entrenched companies to create barriers to competition & service that harm consumers in the name of “protection” and “safety”.

This highlights two nearly opposite alternatives to achieve the common goal of an open internet: regulation versus competition.

Net Neutrality regulation means rules controlling how to handle data content and movement. These rules must go through multiple approvals and public comment. They are necessarily reactionary and lag technology and innovation. They are also detailed and complex by nature. This attracts rent seeking and lobbying for loopholes by big entrenched companies, which makes the rules even more complex and inefficient, weaponizing the rules against competitors and hiding this fact under layers of complexity. This increases the complexity and cost of doing business, which reduces innovation, rewards established companies and deters new providers from entering the market. That means higher prices and less consumer choice.

For one example, consider T-Mobile’s zero-rating video data. Most of their customers loved this service, and the ones who didn’t could opt out at no charge. Yet providing this service got T-Mobile hauled in front of the FCC to explain themselves to regulators. They were exonerated, but this positive outcome was not preordained. It cost them thousands to defend themselves and they could have been subjected to service prohibitions and massive fines. When ISPs get hauled in front of the FCC to testify every time they do something regulators (or their competitors!) didn’t anticipate, say goodbye to innovation.

An example the Senate Democrats use is “fast lanes” vs. “slow lanes”. This is a red herring. Some kinds of traffic, like video, consume far more bandwidth than others. For the internet to function properly, these different kinds of traffic must be handled and routed differently. In short, there already are “fast lanes” and “slow lanes” —  it’s a technical necessity. The question is how we pay for them. Blanket rules like Net Neutrality risk creating a tragedy of the commons, where everyone uses bandwidth but nobody invests in developing it, or forces everyone else to pay the costs of heavy bandwidth users, which encourages over-consumption, reducing quality of service for everyone.

Yet the Senate Democrats do have a certain logic. With only a handful of monolithic ISP companies, there is no real competition thus in its absence some form of regulation like Net Neutrality becomes necessary. However, as citizens and consumers, we should not accept the inevitability of having only a handful of monolithic ISP companies. And we surely should not pass new regulations like Net Neutrality that will promote and lock in this dystopian future. Net Neturality is self-actuating and self-perpetuating. It creates and exacerbates the very problems it intends to prevent, as it purports to solve them.

In short, it is naive to believe:

  • That Net Neutrality regulations will stay ahead of fast-changing technology and creative interpretation by ISP companies.
  • That a big federal bureaucracy will make better decisions about how to allocate bandwidth and handle traffic, than ISPs directly negotiating with each other and seeking customers.
  • That Net Neutrality rules will be immune from rent-seeking, carved-out loopholes and other forms of regulatory capture by the biggest entrenched companies.
  • That these complex rules won’t raise the cost of business, restricting innovation, competition, and consumer choice.

Consider the alternative that the Senate Democrats ignored: competition. With competition, if one provider does something you don’t like, vote with your wallet and switch. You can switch at any time, for any reason: terms, privacy, cost, etc. Your vote hits the ISP where it counts: financially. Complex rules don’t bother them or protect you; their lawyers and lobbyists are better than yours, and are helping draft those rules.

Under competition, the rules we need are simple: prohibit fraud and establish property rights for access. There is no need for complex rules micro-managing data content and movement. This reduces rent-seeking and lobbying and keeps the cost of doing business low. Without complex rules dictating how to run their business, companies are free to innovate in technology and service to differentiate themselves, much like T-Mobile did for telecom.

But this works only under real competition. That means every person has a choice of several providers (not just two, a duopoly is not a market) and can switch between them quickly, easily, and cheaply. Unfortunately, we don’t have this in the USA. Why not? Primarily because multiple layers (local, state, federal) of complex regulations lock in existing ISPs and make it expensive for new companies. The reason some ISPs get away with bad behavior, like famously bad customer service and high prices, is because their customers have no alternative. Over-regulation protects them from competition. Adding even more more layers of regulation (e.g. Net Neutrality) will fix this like throwing gasoline on a fire.

To a large extent, the problem is local, not federal. Many of the restrictions that make it expensive and time-consuming for ISPs to compete are municipal and local rules and regulations about property access. Comcast and phone companies like CenturyLink love this – they’re already in there and the rules block competitors from entering the market. Net Neutrality does nothing to address this. It just adds even more regulation at the federal level.

Far better to address the root cause. Unwind the layers of regulations and municipal property access rules that lock in ISP companies and block competition. ISPs already are too much like utilities. This is the problem, not the solution.

Netflix New Rating System Sucks

In April 2017, Netflix changed their rating system. Instead of rating shows from 1-5, you now have only 2 ratings: up or down. And, the ratings Netflix shows you are NOT what other users have given the show. Instead, the rating Netflix shows you is how much Netflix thinks you’ll like the show.

This sucks. To be more precise, show ratings are now meaningless and useless. This is for 2 reasons:

1. The rating you see is not how others have rated the show. The show might be rated “5” by 90% of viewers, but it shows as “1” for you if Netflix thinks you won’t like it. The reverse is also true. The show could be rated “1” by 90% of viewers but shows as “5” for you if Netflix thinks you’ll like it.

For me personally, Netflix’s algorithm is quite poor. Shows I like often rate as 1, and vice versa. And it makes it impossible to see how others have actually rated a show. This is the underlying arrogance of this rating system: Netflix prevents you from seeing how others actually rated it, instead forces their own algorithm’s ratings on you. It’s like Netflix is saying, “Who are you going to believe: us, or your own lying eyes?

Suggestion to Netflix: Never hide from customers the actual data they want to make decisions, and replace it with your own algorithmic interpretation. Especially if your algorithm sucks.

For example: most action movies have poor acting, cheesy dialog and plots with gaping holes. But there are a few good ones. You watch one good one, and Netflix floods you with abominable cheesy action movies all rated “4” or “5”. Not because they’re good – they’re not. Because Netflix’s stupid algorithm doesn’t know the difference. Humans do know the difference. If you could only see the actual ratings people have made. But Netflix won’t show you that.

2. Binary ratings have no way to differentiate between a show that was tolerable, one that was great, and the best show you’ve ever seen. All you get is up or down. This alone might be bad enough, but there’s more. This forces people to game the system, rating down shows they liked if they don’t want to see more shows like that. In the long term these fake ratings make the entire system worse. The system encourages–almost forces–people to game it with false ratings, which then spirals into a nose dive as those ratings make the recommendations even worse.

I completely understand a fast moving innovative company like Netflix must “move fast and break things”. But a rating system this arrogant and broken should never have rolled to production. However, I won’t cancel my subscription. At least not yet.

The astute reader will claim that Netflix never did show the actual ratings in the 1-5 system. The rating you saw was how Netflix thought you would rate the show. That’s true, but only partially true. The rating you saw was based on both–how others rated it, weighted mix with how they thought you would rate it. The bottom line is, however the old system worked, its ratings were more accurate and useful than the current system, which is completely broken and useless.

Call-out to Netflix: fix this broken ratings system!

LineageOS is Alive!

Last night I installed LineageOS 14.1 on my Galaxy Note 8 tablet.

I’ve been running CM 13 on this tablet for the past year or so and it works great – stability, performance, battery life. But the last build was Christmas Eve 2016, then Cyanogenmod died. I’ve been watching CM relaunch as LineageOS. They now have a home site and are running weekly builds for many devices. The Galaxy Note 8 happens to be one of these devices – with more to come.

The installation procedure is the same as CM. First, install TWRP recovery. You should do this no matter what build you’re running, even stock, because it has great features like full backup & restore. There are plenty of install guides. I had it installed already. Then, install LineageOS:

  • LineageOS Zip
  • Open Gapps Zip – use version 7.1 for LineageOS 14.1.
  • SuperSU Zip (if you want root)

The root ZIP provided by LineageOS did not work – TWRP had an error trying to install it. I used SuperSU instead, and it worked perfectly.

I’m still restoring backups & such, but first impression is that LineageOS 14.1 seems solid and fast. I’ll report back later after I get some time to use it.

Thoughts on the Dark Forest

I recently read Cixin Liu’s Three Body Problem and Dark Forest. This blog entry is a spoiler, so you may want to stop reading this if you plan to read these books.

Fermi’s Paradox is a key concept and plot element, particularly one explanation for it called the Dark Forest, tied to character Luo Ji’s axioms of life in the universe:

  1. Life’s goal is to survive
  2. Resources (matter & energy) in the universe are finite
  3. We can never be sure of alien life’s true intentions
  4. Distances between stars impair communication

Conclusion: (3) and (4) create a chain of suspicion making conflict inevitable.

I am not convinced. This is fixed-mindset, zero-sum thinking, similar to the flawed economic thinking behind Malthusian doomsday predictions and protectionist trade policies here on Earth. The above rules are not unique to outer space. The same could be said of different cultures here on Earth – every man presents a threat to all others as they must compete to secure the limited means of survival, leading to inevitable conflict. During some historical periods – primarily in pre-agricultural tribal societies – this was true. Yet today it is false. We have Human societies of size, complexity and interdependency that would be unimaginable to prior generations. Why?

Two key factors. First, the increased productivity of division of labor. Second (and a part of the first), Ricardo’s theory of Comparative Advantage. It was not love or enlightenment that caused Humans to stop fighting each other over the limited resources Nature provided (as animals do), and instead cooperate to create new resources making everyone better off. It was recognition of these fundamental economic facts.

The same applies to space exploration, even more so. Cixin Liu misses this point entirely and falls for the simplistic zero-sum thinking that has duped many before him. Items 1-4 are true, yet the conclusion does not necessarily follow. He’s missing an important 5th axiom: The potential benefits of cooperating with alien life are so tremendous they cannot be measured. When balanced against risks (3) and (4), conflict is no longer inevitable. The result may end in conflict or cooperation, depending on the situation.

Infinite Numbers

ℵ0 (Aleph zero, null or naught) is the smallest infinity, the size of the natural numbers. It is countably infinite, which means there exists some method of counting that will eventually reach each item in the set.

The rational numbers – all fractions of the form p/q where p and q are natural numbers, is also of size ℵ0. One way to prove this is to demonstrate a method for pairing each natural number with a rational number, and show that every rational number will have a pair. The classic proof draws a table of rational numbers and walks through it starting in a corner and marching along diagonals.

So we have the intuitive result that you can pair off the elements of 2 sets with each other, if and only if the sets are the same size.

To me it seems counterintuitive that the rational numbers are the same size as the natural numbers, even though this fact follows logically from the very simple and intuitive above proposition. It seems like there are a lot more rational numbers. However, what follows seems even stranger to me.

The irrational numbers – π, e, and myriad others, are more numerous. Their size is a bigger infinity called ℵ1. They are uncountable – which means there doesn’t exist any method of counting that will reach all of them. Every method you come up with will skip some. There is no way to pair them off with the rational or natural numbers – no matter how you do it, there will always be irrational numbers left over without a pair.

Despite being countable, the rational numbers are infinitely dense. Between any two of them lie infinitely many more. The irrational numbers are also infinitely dense. What is more, between any two rational numbers lie infinitely many irrational numbers. But we’d expect that, given there are more irrational numbers. Furthermore, and most strangely, between any 2 irrational numbers lie infinitely many rational numbers. How can that be, if irrationals outnumber rationals?

The proof is simple. Pick any two irrational numbers, n1 and n2. Take the absolute value of their difference, d = | n1 – n2 |. There are infinitely many irrational numbers smaller than d. If that’s not obvious, pick some natural number ε greater than both d and 1/d. Then 1/ε is a rational number smaller than d.

It seems strange that 2 sets, each infinitely dense, both in itself and in each other, can be of different sizes. But they’re both infinite,so this is probably just a manifestation of the intuitive difficulty conceptualizing different sizes of infinity.

Cyanogenmod Camera Bug and Fix

Good news: you’re running Cyanogenmod, the most popular open source version of Android. Pure Android, no bloatware crapplets from the carrier or manufacturer, and better device performance and battery life.

Bad news: Cyanogenmod has a bug in the camera driver. This is a well known bug; if you Google “cyanogenmod camera bug” you will find lots of info on it. Occasionally the camera won’t work and you have to reboot the phone to get it working again. There is no real fix to this bug.

Good news: there is a simple workaround that fixes it in a few seconds, no reboot needed.

Explanation

Android has a background process called mediaserver. It is always running and one of the many things it does is control access to the camera. This process has a bug in which it locks or hangs the camera driver, making the camera inaccessible.

This mediaserver process is part of Android and starts automatically during boot. The neat thing is, if mediaserver is ever killed, Android detects this and immediately starts a new instance. When this happens, it clears the camera lock and the camera works again.

So, to fix this problem all you have to do is kill the mediaserver process. Android is Linux, so you could simply open a terminal and run the command killall mediaserver. But it’s not quite that simple. Since mediaserver is a system process, you must have root privileges to kill it. Fortunately, that’s easy with Cyanogenmod.

Enabling Root

Rooting Cyanogenmod is easy – root is already built in, you only need to enable it.

Go to Settings, About Tablet, and tap Build Number repeatedly. A toast will pop up saying, “X more presses to enable developer mode”. Keep tapping until Developer mode is enabled.

Hit back (to Settings) and you’ll see a new option: Developer options. Tap it. Scroll down to Root access, and enable it.

Reset in a Terminal

Now you can open a terminal and run the command su (to become root). A popup will appear asking whether grant root access to the terminal. Allow it – you’ll only have to do this the first time. Then (back at the terminal command prompt) run the command killall mediaserver. Alternately, you can do it all in a single command: su – c “killall mediaserver”. If the camera was stuck, it’s now working again. It only takes Android a couple of seconds to detect that mediaserver has been killed and restart it.

NOTE: if the terminal doesn’t have a killall command, install BusyBox. It installs a bunch of standard Linux command line tools, including killall and many others.

Reset the Easy Way

Opening a terminal and entering a couple of commands only takes a few seconds, but you might want an even quicker and easier way to reset the camera driver. How about an app that you simply touch, and it instantly kills mediaserver in the background? There are several versions of this app available if you google for them. I built one myself using Tasker. It runs standalone on any Cyanogenmod device – doesn’t need Tasker to run.

This app is an APK that you will be side loading. For security reasons, side loading is disabled by default in Cyanogenmod. To install this app (or any other APK) you need to go to Settings, Security, and enable Unknown Sources.

Now download this APK file and copy it to your device, for example in the “Downloads” folder. Just like you would for any other file like a JPG photo or MP3 song. Use the Cyanogenmod file manager to navigate to the Downloads folder and touch the APK file. This will install it.

After you’ve installed it, if you want to you can disable Unknown Sources. The app will continue working since it’s already installed.

The first time you run this app it will ask for root privileges (needed to kill the system mediaserver process). Grant them. It won’t ask again. When the app runs it will pop up a message saying “Camera Reset”, which will disappear in about 1 second.

NOTE: I built and shared this APK only to help Cyanogenmod users – it has no ads, no telemetry, no viruses, and is legal and free. However, it has no warranty. Know what you’re doing and don’t blame me if it doesn’t work, breaks your device, or makes your hair fall out. If you don’t trust me or this source, use a different app from somewhere else or write your own.

Galaxy Note 4

My Galaxy Note 2 is a fantastic phone; I’ve had it for 5 1/2 years. T-Mobile abandoned it years ago to Android 4.3, so I replaced the bootloader & ROM with TWRP and Cyanogenmod, going through versions 11, 12 and 13. I would keep using this phone, but for 1 problem. It doesn’t support 700 MHz Band 12 for LTE, which T-Mobile has been using to expand their coverage. Because of this, my 4G/LTE data coverage on this phone is not that great. It’s not bad, but it could be a lot better. That’s hardware, so to fix it I had to get a different phone.

But what I’d like in a phone isn’t readily available:

  • Support for all T-Mobile 4G/LTE bands (especially Band 12)
  • 5.5″ screen (+/- 0.25″)
  • Extra long battery life
  • SD card
  • Removable battery
  • Supported by LineageOS (aka Cyanogenmod)

Some phones came close: Moto X Play, Oneplus 2, Nexus 6P. But none met all requirements – except the Galaxy Note 4. But the Note 4’s CM support was abandoned at 12.1 (Android 5). But since CM died and was reborn as LineageOS, the Note 4 is on the list of devices planned for official support. So I got one on eBay, cost about $240. It’s in near-new condition, appears to be a demo model. There is some slight screen burn-in near the top edge – this is a common problem with the Note 4. In mine, it’s non-obtrusive and I’ve seen worse. I wouldn’t have noticed except for running apps with screen patterns designed to detect it.

I wouldn’t want the Note 5 – battery was not removable. The Note 7 was a disaster. The Note 4 is definitely the peak of the Samsung Note line.

Differences from the Note 2:

  • Better mobile data coverage: supports all T-Mobile bands.
  • Screen: higher res, brighter, wider gamut
  • Speed: at least twice as fast
  • Better camera: dynamic range, color, with image stabilization
  • bug fixed: Evernote pen input
  • bug fixed: MMS texting (multiple people or with attachments)
  • Dimensions & weight: about the same (within a few mm and grams)

Setup:

  • Update: the phone came with Android 5. After 4 updates totalling over 2 GB of downloads, I had the latest 6.0.1.
  • Root: Chainfire has an easy root for the Note 4, works with Samsung’s latest 6.0.1 ROM. Push it to the phone using Odin, reboot and it’s automatic.
  • GMD SPen: Samsung’s built-in pen support sucks. Configuration is a hot mess and it can’t do the things I want. GMD SPen works seamlessly on top of TouchWiz, or can replace it.
  • Titanium Backup: My go-to backup app, does it all as well as letting you freeze or uninstall “unremovable” crapplets.
  • Nova Launcher: Samsung’s home screen is not very configurable. You can’t even set how many rows & columns! Nova Launcher is similar to CM’s Trebuchet launcher with all those options plus more.
  • Stylus Beta: the best handwriting keyboard I have found. Better than Samsung’s built-in or Google’s. Plus an easy clean interface.
  • Solid Explorer: the best file manager, supports root and includes LAN, FTP connections. Not free, but better than Astro or ES File Explorer. It also has a really nice photo viewer (better than the standard Android gallery app) and built-in text editor. If you go to root mode and edit a system file, when you save the file it automatically mounts system read-write, saves it, then remounts read-only.
  • Folder Sync: the best cloud folder sync utility. If you want your Box, Dropbox, etc. accounts to sync to your device like they do on a real computer, and your device has the storage capacity to support it, this is the only way to fly.
  • Tasker: for all those random little tasks you want to do, like run a command at boot, kill/restart the mediaserver process if your camera dies, whatever. This does it all.
  • Jota: Jota+, the best all-around Android text editor. I’ve tried many over the years and this is the one. It also has a root connector.
  • GPS Status: the best GPS status utility, also keeps your AGPS data up-to-date for quick position locks in all apps.
  • Sygic Maps: does much (though not all) of what Google Maps does – search, map, route, dynamic re-routing as you drive. But does it all on-device, in-memory, so it works even in places that have no mobile network.
  • MX Player: the best Android video player. Better than any built-in player or VLC. I love VLC on Linux desktops, but the Android version is not as good.
  • Power Amp: the best Android music player. Better than any built-in player or VLC. VLC doesn’t do gapless playback of MP3 files and it intermittently gets noise in the playback.
  • Office Suite: the best Android office app for viewing & editing MS Office docs. I’ve tried  many office suites over the years; this one is the best.
  • Textra: the best Android SMS/MMS experience. Beautiful and seamless to use, supports several emoji sets – iOS, FB and others. Sure you can hack the iOS emojis into your rooted Android phone by replacing the system ttf file, but with Textra you don’t need to.
  • View Ranger: the best outdoor hiking/biking tracking/routing/navigating GPS app. Doesn’t have Strava’s social features, but it has a ton of far more useful features Strava doesn’t have. Besides, I hate social.

This is not only the best phone I’ve owned, it’s one the best phones available on the market today. It has a brilliant AMOLED screen, not only bright but also with wide, accurate gamut. It’s very fast (even on the stock Touchwiz ROM – LineageOS will be even faster), great camera, lots of storage, excellent battery life, and great mobile data coverage.

VFAT, UUID, SD Cards, Android Mount

Last night I was setting up a new Android tablet to match an old one. Both have SD cards with apps that store data on it. To make things easier, I wanted the SD card to mount to the same point in the filesystem. But Android 6 mounts the SD card to a directory whose name is the card’s serial number (UUID). That is: /storage/XXXX-XXXX. We’re talking about the serial number, not the volume label – so it’s not easy to change – tune2fs can’t do it because it’s fvat, not ext.

Eventually I succeeded but there were a few twists along the way.

Ubuntu help forums online have a procedure to do this with dd commands, but I want to avoid performing block level I/O on the filesystem. I found a simpler, cleaner, safer way to do this:

First, install mtools. It’s in Ubuntu’s standard repos: sudo apt-get install mtools

Next, connect the SD card and check which device it is – in my case /dev/sdc1 but this will vary. Make sure it’s unmounted, but not ejected.

Next use mlabel to set the UUID: sudo mlabel -i /dev/sdc1 -N XXXXXXXX ::VOL-LABEL

NOTE: mlabel’s -i param is undocumented. It’s how you specify the device. You can omit the VOL-LABEL, but leave the :: in place.

NOTE: after doing this if you check the UUID using blkid or other commands, they will report it unchanged – even if you remove and reinstall the SD card. This is incorrect; the UUID did actually change. Apparently, you must reboot before Linux will recognize a changed UUID for a filesystem.