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:
- 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?
- 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?
fuse2fs