0

I have mounted an ISO at /mnt. The ISO is android's system.img. At the root it has a folder etc that is linked to /system/etc:

lrw-r--r--  1 root root    11 Dec 31  2008 etc -> /system/etc

But it seems that my linux system does not identify that this symbolic link actually points to a directory INSIDE /mnt, but not to my system root directory.

In the /system/etc/ folder there's a standard hosts file:

$ cat /mnt/system/etc/hosts
127.0.0.1       localhost
::1             ip6-localhost

I expect cat /mnt/etc/hosts to output the same, but in reality it output:

$ cat /mnt/etc/hosts
cat: /mnt/etc/hosts: No such file or directory

I created a stub file at /system/etc/hosts in my system root and tried again:

$ sudo mkdir /system
$ sudo mkdir /system/etc
$ echo "STUB" | sudo tee /system/etc/hosts
STUB
$ sudo mkdir /system/etc
$ cat /mnt/etc/hosts
STUB

As expected, it printed contents of /system/etc/hosts instead of /mnt/system/etc/hosts, as I wanted.

I want all symbolic links in the mounted folder /mnt to be resolved as if it was mounted at root /, so all symbolic links are resolved correctly. Is there any way I can do that without actually changing anything in the mounted filesystem (redefining symbolic links to point to /mnt{ACTUAL LINK})?

g00dds
  • 43
  • 4
  • 2
    That's how symbolic links with absolute link targets work. It should be `etc -> system/etc` to work as you want. You could use a `chroot` environment. – Bodo Apr 12 '23 at 18:19
  • 1
    I highly doubt that it's actually an ISO. It just doesn't make sense to use the ISO9660 filesystem for Android system image. – gronostaj Apr 12 '23 at 18:24
  • @gronostaj It's probably not. See [the previous question from this user](https://superuser.com/q/1778645/432690). – Kamil Maciorowski Apr 12 '23 at 18:28
  • @Bodo, can I use chroot if there is no executable shell in the mounted folder? The image is android arm32 image, so it has only arm executables, so I get error `chroot: failed to run command ‘/system/bin/sh’: Exec format error` when I try to use chroot – g00dds Apr 12 '23 at 19:12
  • @gronostaj, yeah, sorry, it's not an iso, just a android's .img image file – g00dds Apr 12 '23 at 19:14
  • I don't know if there is a way to solve the shell problem with `chroot`, and you might get other problems because of missing/wrong binaries. An overlay file system would allow to replace files. I suggest to [edit] your question and explain what you want to achieve at the end. – Bodo Apr 13 '23 at 07:30

0 Answers0