Posts

Showing posts from July, 2017

Utilizing btrfs snapshots to protect Android from malware

Image
Let's continue our ride with btrfs. The snapshot feature is probably the most eye-catching one in btrfs. As the name implies, it allows to revert the filesystem back to an older state. Since btrfs uses CoW, which always append the data instead of updating it in-place, this feature makes a lot of sense. If you're a sane person, first thing that pops to your head should be : BACKUPS ! But keep in mind that snapshots are not the same as backups.  - You don't get any additional redundancy.    If hardware fails, you lose all snapshots.  - Malwares with root permissions can still mess around with snapshots. However, snapshots could be great as a backup solution in Android.  - You really don't need redundancy.    How many NAND failure have you seen on a smartphone( excluding LG, cough cough )?  - Most of the data destructions are owner-made.  - Most of the malwares are also installed by the owner.  - Most...

Experimenting around btrfs on Android

Image
As covered before , btrfs might be an exciting thing to try on Android. Although f2fs is clearly the king of the performance on Android , my inner mouth was keep saying to try it out, so I did. Kernelspace The first step is to enable btrfs kernel module... or is it? The latest phone I had at the time when I started this project was the OnePlus 3, which used a 3.18 kernel. The btrfs in 3.18 kernel claims itself as an unstable filesystem . So before I start experimenting around btrfs, I decided to port a more recent, stable version of btrfs to the OnePlus 3's kernel. I picked the 4.9 kernel's btrfs as the 4.9 kernel is the latest LTS kernel as the time of writing this post. For those who are unfamiliar with Linux kernel development, backporting a kernel module is a hideous process. Not only you have to fix a ton of compilation errors, you have to dig through the entire Git commit history to properly fix API usages. You also have to backport some other commi...

Filesystem story on Android

Filesystem on Linux is always an interesting topic. Since most of the bottleneck on a modern computer is I/O to disk, playing around with filesystems can result in a pretty significant improvement, both in reliability and performance(although those two tends to not go under a same sentence). I personally use the following setup on my Linux desktop :  - xfs on the root partition for best reliability  - f2fs on the home partition for better performance  - ext4 with writeback, nobarrier mode on the build output partition for best " I-don't-care-about-redundancy-level-performance ".  - btrfs with zlib compression on the back-up HDD for efficient space usage and snapshots. While there is about a dozen different popular filesystems on Linux desktop/server setups, filesystem story on Android is somewhat boring. YAFFS2 In the early days(we're talking Galaxy S1 era), most Android devices used yaffs2 filesystem. One thing to note here, is that y...