How to mount system.img on android (or linux)? I wanna modify some files in my system partition of phone. It's ext4. I plan to flash it later to my phone. I tried:

mount -w -t ext4 -o loop /storage/sdcard1/system.img /mnt/njz


and got this:


  open backing file failed: Permission denied


Also phone is rooted, and shell says it's root.
I also tried using su command before that command.
Also tried adding additional options after "loop", like

nosuid,nodev,default_permissions,user_id=0,group_id=0,gid=0,uid=0


Why no permissions?
also tried file_mode=0777,dir_mode=0777, and still same result.

I tried mounting this on linux (tinycorelinux), and no problems. I used:
sudo mount -t ext4 -o loop system.img /mnt/
In that case, my system.img was mounted from ntfs partition.
Found a solution! Guess what problem was?! My file was read-only, which i set up in windows. That's problem with "permission denied". For some reason android cannot change this, I had to use windows or symbian os to unmark read-only property. Xplore doesn't show permissions option for any files except if they are on some ext partition. Root Explorer shows, and that's how I first noticed my problem, accidentally. I've seen all other files had different permissions in detailed view in root explorer. I tried changing permissions to 0777 using root explorer or total commander, and although they say it set it up, it didn't. This can't be done on fat32 partition. Of course when I changed it using windows, it showed same permissions as other files. I remember i set this file to read-only a month ago, to avoid accidental modification!

Later I experienced additional problem with mount, that is when i use -o loop only, it says 'device or resource busy'. But when I found where are my loop devices by searching for 'loop' using xplore, I found there are files loop0 to loop7 in '/dev/block/'. So when I used -o loop=/dev/block/loop0 it again said the same problem message. But when I used -o loop=/dev/block/loop1 it finally mounted. I didn't have to use '-w' option to make it writable! Just skipped any letter.

And forgot to say, we can mount it to any folder, but that folder has to exist! So I made folder njz or nijaz or sistem in root of my device using xplore (set in settings superuser + mount writable, so it can make these things) and mounted there. Note that that folder dissappears after reset.

Also umount worked for unmounting.
umount /njz/.

Also that's what caused my original firmware to not work. It always bootlooped. Just because file is read-only. This is huge problem in linux. Need to contact linux, xplore, total commander, root explorer developers. Spflashtool was used to flash files, but problem was in file property!!!