LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-18-2013, 09:36 AM   #1
emanation.grz
LQ Newbie
 
Registered: Jun 2013
Posts: 2

Rep: Reputation: Disabled
“mount -o remount,ro” makes source readonly also


Hello.
I tried to make next solution for making readonly folder by another path:

Code:
mount --bind /source/ /dest/
mount -o remount,ro /dest/
This is work in meaning that /dest/ becomes readonly. But my problem that source also stays readonly. What I do in details:

I have this

Code:
/dev/sdb1 on /mnt/raid3 type ext3 (rw,noatime)
I made folder and mount as bind

Code:
mkdir /mnt/raid3-readonly/
mount --bind /mnt/raid3 /mnt/raid3-readonly/
Now I can

Code:
cp /mnt/raid3-readonly/test.file /mnt/raid3-readonly/test.file2
next

Code:
mount -o remount,ro  /mnt/raid3-readonly/
cp /mnt/raid3-readonly/test.file /mnt/raid3-readonly/test.file3
cp: cannot create regular file `/mnt/raid3-readonly/test.file3': Read-only file system
Looks OK but:

Code:
cp /mnt/raid3/test.file /mnt/raid3/test.file4
cp: cannot create regular file `/mnt/raid3/test.file4': Read-only file system
And this is my problem. After

Code:
mount -o remount,rw  /mnt/raid3-readonly/
I can copy again at source

Code:
cp /mnt/raid3/test.file /mnt/raid3/test.file5
I'm really lost. Please, help. Maybe be it's a bug in kernel.

Code:
uname -a
Linux myserver 2.6.18-194.32.1.el5 #1 SMP Mon Dec 20 10:52:42 EST 2010 x86_64 x86_64 x86_64 GNU/Linux

Last edited by emanation.grz; 06-18-2013 at 10:34 AM.
 
Old 06-19-2013, 01:56 AM   #2
Rumata
LQ Newbie
 
Registered: Feb 2013
Location: USSR
Distribution: gentoo
Posts: 15

Rep: Reputation: 0
Not assuming that you haven't read the man page. still:

Note that behavior of the remount operation depends on the
/etc/mtab file. The first command stores the 'bind' flag to the
/etc/mtab file and the second command reads the flag from the
file. If you have a system without the /etc/mtab file or if you
explicitly define source and target for the remount command
(then mount(8) does not read /etc/mtab), then you have to use
bind flag (or option) for the remount command too. For example:

mount --bind olddir newdir
mount -o remount,ro,bind olddir newdir

Note that remount,ro,bind will create a read-only mountpoint
(VFS entry), but the original filesystem suberblock will be
still writable, it means that the olddir will be writable, but
the newdir will be read-only.
 
Old 06-19-2013, 05:55 AM   #3
emanation.grz
LQ Newbie
 
Registered: Jun 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thank you for reply.
I tried
I think my problem related with /proc/mounts
BTW system does have /etc/mtab and content of it after mount -o remount,ro,bind /mnt/raid3 /mnt/raid3-readonly

Code:
/dev/sdb1 /mnt/raid3 ext3 rw,noatime 0 0
/mnt/raid3 /mnt/raid3-readonly none ro,bind 0 0
but content of /proc/mounts is

Code:
/dev/sdb1 /mnt/raid3 ext3 ro,noatime,data=ordered 0 0
/dev/sdb1 /mnt/raid3-readonly ext3 ro,data=ordered 0 0
and it explains why olddir also read-only.

I assumed that /mnt/raid3 path is overlapping with another mount point and affects on it too. That is why I changed source and mount point to another filesystem

Code:
mkdir /mnt/raid3/testfolder
mkdir /root/readonlyfolder
mount --bind /mnt/raid3/testfolder /root/readonlyfolder
mount -o remount,ro,bind /mnt/raid3/testfolder /root/readonlyfolder
Now /etc/mtab has

Code:
/dev/sdb1 /mnt/raid3 ext3 rw,noatime 0 0
/mnt/raid3/testfolder /root/readonlyfolder none ro,bind 0 0
but /proc/mounts still has both readonly

Code:
/dev/sdb1 /mnt/raid3 ext3 ro,noatime,data=ordered 0 0
/dev/sdb1 /root/readonlyfolder ext3 ro,data=ordered 0 0
So, I can rephrase my question. Why does "mount -o remount,ro" affect on /mnt/raid3 in /proc/mounts file?
Thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remount readonly ntfs drive chriswade007 Linux - Newbie 17 01-27-2013 07:50 AM
NFS mount point mount as readonly on AIX davinders Linux - Server 1 09-25-2011 12:23 PM
[SOLVED] how can i remount root filesystem as read/write after modify readonly-root file jcwkyl Linux - Newbie 3 12-21-2010 10:40 PM
mount -n -o remount,rw / a6speedo Linux - Server 1 03-06-2010 07:26 PM
Can't remount a --bind'd mount zman818 Linux - General 3 09-12-2006 06:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration