Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
When you have mount point, chmod refers to the filesystem so mounted. When dismounted, the file reference returns to what it was BEFORE the mount.
When you remounted the filesystem, the access modes are from the chmod done when it was originally mounted.
One way to think about this is that the directory file reference (in memory) contains two parts - the name, and its location in the directory tree... The other half is an inode reference containing the connection to the contents of the directory (the inode carries the access mode).
When you mount a filesystem onto a directory, the top half (the one with the name and location in the directory tree) remains unchanged... But the other half is replaced by a reference to the now mounted filesystem, which has the inode of the root directory of that filesystem. And that inode has the access mode for the filesystem, which is now visible due to the mount.
The original access mode is covered up. It is still in the system buffers though, so when you dismount the filesystem the original inode reference is restored, and the original access mode is visible again.
When you change the access mode while a filesystem is mounted, the change is done to the inode from that mounted filesystem. So a dismount restores the visibility of the original mode. The inode from the previously mounted filesystem carries the access mode that was changed.
If you add the mount to /etc/fstab with the option users you can do the mount as the user and it will have the permissions of the user. You can also pass -o users to the mount command as root. Just bear in mind that ext4 is a filesystem who's only default permissions belong to root (aka / + lost+found). So you'd have to mount it, and change the permissions to be written to by the user, before it would be of any use to a user. Also on my system, mkfs.ext4 is not available to userland (debian defaults).
...a reference to the now mounted filesystem, which has the inode of the root directory of that filesystem...
...the change is done to the inode from that mounted filesystem...
OK as far as I understood it, I am restating it in my words.
"The temp/ after mount become root of the mounted filesystem, and hence when I am changing permissions after mount then the permissions are changed for the root of file.img, and not the actual temp/ directory created. Hence comes the two different inodes. The inode of file.img is changed, while the inode of temp/ directory before mount is not."
Please let me know if I have got it correctly (as I do not know much about inodes, except that they are some kind of references to files).
But I was just trying to find out how the changed permissions of root of filesystem was retained in second mount which I think is answered by jpollard if I have been able to understand him/her correctly.
The only error is the "inode of file.img" which isn't involved - the inode being modified by the chmod is from the root inode of the filesystem WITHIN the file.img file. The inode data is stored in the file.
The inode OF the "file.img" is not touched other than when mounting the file to locate where the data for the filesystem being mounted resides.