0

Every time I edit a file in /, /sbin, or /system/bin it overwrites on restart (device is rooted and in r/w mode). I assume this is because Android mounts a temporary root? Or maybe it's just a problem on my device?

How do I make a permanent change to root files? Can I do this through adb? Do I need to edit the system image, and if so can anyone point me in the right direction on where to start on this?

  • Give us the details of the whole list of instructions you used to edit a file in /system/bin. As for files in / and /sbin - they are loaded from the kernel on every boot, so it's not worth editing them out if you intend to make changes persist across reboots. What device are you using? – Firelord Jan 12 '16 at 21:26
  • I'm using a rooted LG G Pad 7.0 running 4.4.2. To accomplish what I want, I think I can get away with either replacing /sbin/chargerlogo with a copy of /system/bin/reboot, or replacing the contents of /sbin/chargerlogo with #!/system/bin/sh /system/bin/reboot However it needs to survive a reboot or it is not of any use. As for list of instructions... I was trying to do it through ES File Explorer with root explorer on, system in r/w mode. – Alan Jan 12 '16 at 21:30
0

The root file system (/) and the files therein (plus several more in some sub-directories) are overwritten at boot time from the so-called InitRd ("initial RAM disk", or "boot image"). So if you must change/add stuff there, you will have to modify that image.

If you just want to store some additional binaries/scripts, you should rather do so in /system/xbin (which usually is also contained in the $PATH) – though files in /system/bin should survive a reboot as well (/system is a separate partition usually mounted read-only, and thus not touched except for OS updates).

  • OP says he modifies /system/bin and it gets restored. – SarpSTA Jan 12 '16 at 22:19
  • @SarpSTA I've read that – and somehow (at least partly) doubt it. As to my knowledge, neither shutdown nor boot tamper with /system except to (un)mount the partition (read-only that is). Not sure what's behind that. I've done such manipulations several times on different devices – so I'm pretty sure what sticks and what does not. Though I admit different devices/ROMs might have specifics I've not yet encountered – thinking e.g. of those always replacing /recovery with stock when flashed with something else, as I've read. – Izzy Jan 12 '16 at 23:45
  • @SarpSTA It might not, sorry for the mistake. The files I want to edit are in / and /sbin, the file I want to copy is in /system/bin, so my bad on that. Izzy, thank you for this! Any resources to point in the right direction to modifying the InitRd? – Alan Jan 12 '16 at 23:59
  • @Alan Sorry, that's the part I didn't do yet (modifying the InitRd myself). I've replaced it sometimes, but the replacement was built by someone else. As this would be off-topic here anyway, I'd recommend checking these posts at SO :) – Izzy Jan 13 '16 at 1:25
  • Anytime, Alan. A quick Google search just found this little tutorial: Android boot.img manipulation – which should answer your previous comment. – Izzy Jan 13 '16 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.