LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 04-19-2009, 03:18 AM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Rep: Reputation: 70
Cool How to make root file system be read-only?


Hi all,

I may be nuts, or paranoid, but it's not as if I have the reputation of a "guru" to lay on the line here. :-)

I have been trying to edit my fstab file so as to mount my main, system partition read-only by default. So far, however, I have failed to achieve this seemingly simple objective. I have exhausted the advice given to me here by others; nothing has worked. Now I need some independent third party/parties to double check my findings for themselves and report back here.

I have tried this on two different bang-up-to-date distros with the same results. Their kernels aren't the same, but the results are. I will post the kernel details on request if necessary, but please try this for yourselves first to ensure I haven't made some STOOPID mistake!

Here's what to do:

Edit your fstab in any way to please to make it so your main, system partition is mounted read-only on boot-up.

Check with "mount" after re-booting that this has taken effect.

Now try to write/save something to the filesystem on this partition.

Please let me know what happens!

NB, very latest kernels only, please.
 
Old 04-19-2009, 03:27 AM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by Completely Clueless View Post
Hi all,

I may be nuts, or paranoid, but it's not as if I have the reputation of a "guru" to lay on the line here. :-)

I have been trying to edit my fstab file so as to mount my main, system partition read-only by default. So far, however, I have failed to achieve this seemingly simple objective. I have exhausted the advice given to me here by others; nothing has worked. Now I need some independent third party/parties to double check my findings for themselves and report back here.

I have tried this on two different bang-up-to-date distros with the same results. Their kernels aren't the same, but the results are. I will post the kernel details on request if necessary, but please try this for yourselves first to ensure I haven't made some STOOPID mistake!

Here's what to do:

Edit your fstab in any way to please to make it so your main, system partition is mounted read-only on boot-up.

Check with "mount" after re-booting that this has taken effect.

Now try to write/save something to the filesystem on this partition.

Please let me know what happens!

NB, very latest kernels only, please.
It's not gonna be as simple as saying "mount / read-only". You're gonna need to do additional work, such as creating links to writeable file systems for files that need to be, well, writeable. Your best bet might be to download a live distro that runs with its root file system on the CD-ROM and see how they do it. One example of such a distro is Devil-Linux. Also, keep in mind that making your root file system be read-only doesn't really accomplish much with regards to security. If your box is rooted, the attacker simply needs to remount the file system read-write. I guess what I'm saying is, make sure you understand that a read-only file system is not the same as read-only media.

EDIT: BTW, I've edited the thread title to something a bit more sensible.

Last edited by win32sux; 04-19-2009 at 03:46 AM.
 
Old 04-19-2009, 04:20 AM   #3
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by win32sux View Post
It's not gonna be as simple as saying "mount / read-only".
Well there's still some part of the puzzle missing. I'm simply inviting people to perform this test for themselves and report back their findings. Better to scare a few people unnecessarily-temporarily than to have them genuinely exposed to severe risk through saying nowt.
 
Old 04-19-2009, 04:59 AM   #4
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
I feel I should also point out that when a user specifies that the partition he wants to mount be mounted as READ-ONLY, and the operating system confirms that this HAS INDEED BEEN DONE - that he should be able to RELY on this confirmation, without subsequently finding out to his horror - as I have - that the bloody thing remains writable!!!
 
Old 04-19-2009, 05:04 AM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
If I mount a partition using fstab on my system ro, then it is ro, impossible to write to it.


repo@cannabis:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux unstable (sid)
Release: unstable
Codename: sid
repo@cannabis:~$ uname -a
Linux cannabis 2.6.26-2-686 #1 SMP Thu Mar 26 01:08:11 UTC 2009 i686 GNU/Linux
repo@cannabis:~$
 
Old 04-19-2009, 05:08 AM   #6
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by repo View Post
If I mount a partition using fstab on my system ro, then it is ro, impossible to write to it.
Thanks, Repo. Good 'ol Debian!
Btw, the two distros I refer to where I have been unable to make read-only sticky, are PCLinuxOS and Linpus. I haven't tried this with any others; although I have tried these distros with other machines and got the same failure.

Actually, I think I'll just install Ubuntu 8.1 (Debian based) and see if I still have the same problem.....

Last edited by Completely Clueless; 04-19-2009 at 05:10 AM.
 
Old 04-19-2009, 05:31 AM   #7
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by repo View Post
If I mount a partition using fstab on my system ro, then it is ro, impossible to write to it.
Keep in mind the OP is referring to the root partition specifically.
 
Old 04-19-2009, 05:31 AM   #8
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
Keep in mind the OP is referring to the root partition specifically.
I have mounted / ro
 
Old 04-19-2009, 05:34 AM   #9
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by repo View Post
I have mounted / ro
Cool. Can you post your mount/fstab output? Also, how did you handle /tmp and /var?
 
Old 04-19-2009, 05:40 AM   #10
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
/tmp and /var are seperate partitions
mount however kept giving mounted rw, but it was ro

Code:
/dev/sdb5       /               ext3    noatime,nodiratime,ro,errors=remount-ro 0       1
 
Old 04-19-2009, 06:00 AM   #11
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by repo View Post
/tmp and /var are seperate partitions
I suspected that.

Quote:
mount however kept giving mounted rw, but it was ro
My guess is that is due to /etc/mtab not being able to be updated, since at that point the file system is read-only. If that's the case, then replacing /etc/mtab (after backing it up) with a link to /proc/mounts should do the trick me thinks.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
make bootable CD from hard disk image and mount root file system as ramfs Mr.J Linux - Embedded & Single-board computer 1 08-19-2008 07:29 AM
Upgraded Kernel, Kernel Panic, Can't read root file system. Romanus81 Slackware 25 05-04-2008 10:45 PM
Read-only file system after enabling/disabling root benn333 Ubuntu 2 02-25-2007 12:42 PM
read only root file system santhosh.bachu Linux - Software 2 08-22-2006 06:41 AM
Change from Read only to Read Write File System? justiceisblind Linux - Newbie 3 03-03-2002 07:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:18 PM.

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