0

I have a system.img android's image file that has ext4 filesystem in it. I mount it as

sudo mount -o ro system.img /mnt

I have two questions:

  1. Why do I need root access to mount the image file?

Mounting the image file as user gives me the following error:

mount: /mnt: mount failed: Permission denied.

The user has full access to the system.img as it is the owner of file:

ls -l system.img
-rwxr-xr-x 1 user users 4877225984 Apr 12 19:13 system.img

The user doesn't have permission to mount the image file even if the user is the owner of the the directory to which I try to mount the image, like that:

$ mkdir system_mount
$ mount -o ro system.img system_mount
mount: system_mount: mount failed: Permission denied.
$ ls -l
drwxr-xr-x 2 user users       4096 Apr 12 19:38  system_mount 

So why mounting always requires root access?

  1. When mounted, the user still may not have access to some directories/files in the mounted filesystem if in the filesystem itself the permissions are not given to the user.

Access to some directories is not permitted, like init.container.rc file (others have no permissions):

-rwxr-x---  1 root 2000  3583 Dec 31  2008 init.container.rc

Trying to get contents of that file fails:

$ cat /mnt/init.container.rc
cat: /mnt/init.container.rc: Permission denied

I still can access that directory as root. And I could access it as user if I used chmod -R 755 if the system was mounted as writable. But as it's not, I get the following kind of errors when I use chmod command:

chmod: changing permissions of '/mnt/d/tracing': Read-only file system

I want to give the user temporary read permissions to the whole filesystem WITHOUT modifying the system.img file (having it mounted as read-only), without actually changing the permissions in the filesystem.

How can I do that?

5

1 Answer 1

-1

Kamil Maciorowski's solution, to use fuse2fs.

3
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Apr 12, 2023 at 18:09
  • A one liner will probably get deleted. Please edit your post and show us how you used it. And you are allowed to tick your own answer Apr 12, 2023 at 20:20
  • I'm not the one who voted down, but I agree that sole "use fuse2fs" makes a low quality answer. This is why I posted the hint as a comment (I had no time for proper answer at the time). We want answers to be educative. Your answer is there and it can be improved (edited), so I'm not going to post a competing answer. Possible improvements: what fuse2fs is; link to documentation; what FUSE is; security considerations; how to mount; how to unmount. See this answer of mine which is more than "use curlftpfs"; this is what I mean. Apr 13, 2023 at 7:56

You must log in to answer this question.

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