2

Is it possible to edit the fstab to mount /data, /cache etc. from a different partition on the a.internal memory? b.external sdcard?

Details: The default partition for /data and /cache are too small for my needs and I can manage to format the (internal) /sdcard in ext4.

Edit: My question may superficially seem to be like other questions asking for a way to increase size of /data, but it's not. Here's why:

(1) I need to do it specifically by editing fstab, which is the usual way of doing the same thing on a GNU/Linux desktop. (2) The other questions don't ask about /cache and other partitions.

12
  • Thanks for the downvote. It'd have been better if you could point out what this question was missing.
    – rinfinity
    Nov 9, 2015 at 10:29
  • 1
    Wasn't me, but the "Related" section of this question suggests you didn't check for existing solutions, and "downvote" stands for "doesn't show any research effort". Two clicks brought me to: Mount a folder from external sd as /data – which perfectly fits your question and answers it.
    – Izzy
    Nov 9, 2015 at 11:29
  • @lzzy I'm aware of the link. My question is specifically about editing the 'fstab' (which is the proper 'linux way' to do this) achieve it.
    – rinfinity
    Nov 9, 2015 at 13:22
  • For Linux, yes. But we're talking Android here: modifiying fstab (if it exists on your device) might require modifying the boot image. While based on Linux, some aspects on Android work differently. Quoting from What's the Android equivalent of /etc/fstab?: Android has no /etc/fstab. Also check these questions/answers. // Moreover, this is an XY problem: Better try solving your issue, not stick to your "assumed solution" ;)
    – Izzy
    Nov 9, 2015 at 13:26
  • @lzzy I knew the 'XY problem' would be quoted ;) (been on SE for quite long.) Your previous reply itself speaks "for" the relevance of the question, because I specifically want to know if it is possible to do this by editing fstab. As you might appreciate, people from GNU/linux land might want to know why in Dalvik/Linux the usual 'edit the fstab' doesn't work.
    – rinfinity
    Nov 9, 2015 at 13:39

1 Answer 1

4

As you already expected, the way your question is phrased it looks like an XY problem: There are different ways to achieve your goal (mounting /data, /cache etc. from a different partition), while your question focuses on "editing fstab".

For a working solution, see e.g. Mount a folder from external sd as /data: What's described there should work on all devices/ROMs – while "editing fstab" bears some problems:

  • While that's of course the way it works on Linux, we're talking Android here – which uses a Linux kernel, but a very different setup (see: What's the Android equivalent of /etc/fstab?)
  • An fstab file is not present on many/most Android installations (see How to list all major partitions with their labels? for details)
  • If an fstab file is present, it's usually part of the boot image (see initrd for details). This means, your edits to the file would be in vain: on the next boot where you'd expect them to be processed, instead the file would be overwritten from the boot image and then processed – without your changes

Verdict: Even if your device has an fstab file, you cannot simply edit it and be done. You'd have to rebuild the boot image instead – a task that goes beyond the scope of this site (which is end-user orientated, and creating/rebuilding a boot image rather is in the domain of developers). It might not be straight "off-topic", but at least border-line/gray-zone.

3
  • I don’t know how that answer can work. It creates a symlink which gets removed after boot. No ? Aug 6 at 21:57
  • That comment belongs to the linked question/answer. And to shortly detail on that: It can be done via an init script that is called on boot, or via some Magisk or Xposed module. The entire thing needs root access anyway.
    – Izzy
    Aug 8 at 8:21
  • I am using Moto e2 android 5.0, rooted. I am facing two main problem, 1. Can’t copy /data to 2nd partition, not with uid, gid, selinux context. I am also mounting sdcard through init script. So how do I check when to create symlink, it has to be after sdcard partition gets mounted no ? Aug 8 at 15:00

You must log in to answer this question.

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