LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-23-2009, 03:29 AM   #1
ursusca
Member
 
Registered: Sep 2008
Location: Toronto, ON, Canada
Distribution: Gentoo, RHEL (Fedora, CentOS, OEL), Ubuntu, FreeBSD, Solaris 10
Posts: 170

Rep: Reputation: 34
Make the root file system read-only on RHEL 5.3


Hello everyone,

I am interested in making the root file system read-only on RHEL 5.3.
I've moved /var and /tmp file systems to another partitions.
There are two files in the /etc directory that need to be writable. These are:
/etc/mtab
/etc/resolv.conf

I've moved this files to /var and linked it.
I've added command to the /etc/rc.d/rc.local file:
mount -o remount,ro /

That's it.

Are there any other solutions to make the root file system read-only?

Last edited by ursusca; 06-24-2009 at 12:14 PM.
 
Old 06-23-2009, 05:39 AM   #2
jsteel
Member
 
Registered: Mar 2007
Location: England
Distribution: Arch
Posts: 392

Rep: Reputation: 34
You could use the file /etc/fstab to mount / as read-only by adding ro (I believe) to the options (separated with commas).
 
Old 06-23-2009, 05:40 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Due to lack of provided reasons for requiring this and with total disregard for practical application: 0) SELinux MLS-type policy ;-p, 1) recursive chattr, 2) loopmount a FS from a file, 3) use any write-once medium, 4) use a separate harddisk with write switch (I don't think they exist anymore) or 5) some (FUSE-based) FS overlay?
 
Old 06-23-2009, 07:17 AM   #4
ursusca
Member
 
Registered: Sep 2008
Location: Toronto, ON, Canada
Distribution: Gentoo, RHEL (Fedora, CentOS, OEL), Ubuntu, FreeBSD, Solaris 10
Posts: 170

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by jsteel View Post
You could use the file /etc/fstab to mount / as read-only by adding ro (I believe) to the options (separated with commas).
I edited my fstab:
LABEL=/ / ext3 ro,defaults 1 1
But unfortunately it didn't help me. After rebooting I got rw root file system.

Last edited by ursusca; 06-24-2009 at 12:16 PM.
 
Old 06-23-2009, 07:45 AM   #5
jsteel
Member
 
Registered: Mar 2007
Location: England
Distribution: Arch
Posts: 392

Rep: Reputation: 34
Should it not look more like this?

/dev/sda1 / ext3 ro,defaults 0 1

I've not tried this with the root directory before but it works with other devices/partitions.
 
Old 06-23-2009, 08:07 AM   #6
ursusca
Member
 
Registered: Sep 2008
Location: Toronto, ON, Canada
Distribution: Gentoo, RHEL (Fedora, CentOS, OEL), Ubuntu, FreeBSD, Solaris 10
Posts: 170

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by jsteel View Post
Should it not look more like this?

/dev/sda1 / ext3 ro,defaults 0 1

I've not tried this with the root directory before but it works with other devices/partitions.
Thank you, jsteel! But this options don't influence on read/write access.
It's Dump and fsck options. Dump is a backup utility and fsck is a filesystem check utility. Dump checks it and uses the number to decide if a filesystem should be backed up. If it's zero, dump will ignore that filesystem. Fsck looks at the number in the 6th column to determine in which order the filesystems should be checked. If it's zero, fsck won't check the filesystem.
 
Old 06-23-2009, 08:57 AM   #7
jsteel
Member
 
Registered: Mar 2007
Location: England
Distribution: Arch
Posts: 392

Rep: Reputation: 34
Sorry I should have mentioned that it was the first bit of the line that I was querying; I was curious as to why you don't have a device mentioned such as sda1. That's just an example line (similar to what I have on my computer).
 
Old 06-23-2009, 10:51 AM   #8
fpmurphy
Member
 
Registered: Jan 2009
Location: /dev/ph
Distribution: Fedora, Ubuntu, Redhat, Centos
Posts: 299

Rep: Reputation: 62
Quote:
Originally Posted by jsteel View Post
Sorry I should have mentioned that it was the first bit of the line that I was querying; I was curious as to why you don't have a device mentioned such as sda1.
LABEL is the partition label. In this case "/".

See http://wiki.linuxquestions.org/wiki/Fstab

Last edited by fpmurphy; 06-23-2009 at 10:53 AM.
 
Old 06-23-2009, 11:27 AM   #9
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
@ursusca: Can you explain what you're trying to accomplish? (i.e. I'm doing this because...)
 
Old 06-23-2009, 03:43 PM   #10
ursusca
Member
 
Registered: Sep 2008
Location: Toronto, ON, Canada
Distribution: Gentoo, RHEL (Fedora, CentOS, OEL), Ubuntu, FreeBSD, Solaris 10
Posts: 170

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by anomie View Post
@ursusca: Can you explain what you're trying to accomplish? (i.e. I'm doing this because...)
Hi anomie
I am looking for solutions to make the root file system read-only on RHEL 5.3. And I`d like to choose the best solution.
I tried modifying /etc/fstab and adding --read-only to the grub boot options. But it didn't help me. That's why I added remount comand in the /etc/rc.d/rc.local file. But thanks to one guy from CentOS forum I found the /etc/rc.d/rc.sysinit script where the root is remounted rw. I think there are 2 possibilities to make the root file system read-only on RHEL 5:
- adding remount comand to the /etc/rc.d/rc.local file.
- commenting out the line in the /etc/rc.d/rc.sysinit scripts, containing the remount.

Last edited by ursusca; 06-24-2009 at 12:23 PM.
 
Old 06-23-2009, 03:59 PM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Yes, we already know what you want but not why. Knowing why offers members more insights and chance to correct reasoning or approach or offer other methods.
 
Old 06-23-2009, 04:25 PM   #12
ursusca
Member
 
Registered: Sep 2008
Location: Toronto, ON, Canada
Distribution: Gentoo, RHEL (Fedora, CentOS, OEL), Ubuntu, FreeBSD, Solaris 10
Posts: 170

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by unSpawn View Post
Yes, we already know what you want but not why. Knowing why offers members more insights and chance to correct reasoning or approach or offer other methods.
To avoid unforeseen errors.

Last edited by ursusca; 06-23-2009 at 04:31 PM.
 
Old 06-23-2009, 06:59 PM   #13
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by ursusca View Post
To avoid unforeseen errors.
Like what? Please give some examples and be verbose about it.
 
Old 06-24-2009, 01:17 PM   #14
ursusca
Member
 
Registered: Sep 2008
Location: Toronto, ON, Canada
Distribution: Gentoo, RHEL (Fedora, CentOS, OEL), Ubuntu, FreeBSD, Solaris 10
Posts: 170

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by unSpawn View Post
Like what? Please give some examples and be verbose about it.
Probably it's funny. But I need to setup server which will be situated very far from my work office. In this place Internet connection is very poor and unstable and sometimes it's absent at all. Speed of this internet connection is very low. And on this server I will have time only in critical situations. I have to give the root password to administrator whose knowledge of unix/linux is bad. And I don't want him made anything wrong. I am planning to setup server only for getty (mgetty). That's why I think that read-only file system is a solution for me.
 
Old 06-24-2009, 01:30 PM   #15
DJ Shaji
Member
 
Registered: Dec 2004
Location: Yo Momma's house
Distribution: Fedora Rawhide, ArchLinux
Posts: 518
Blog Entries: 15

Rep: Reputation: 106Reputation: 106
Quote:
... recursive chattr ...
Yeah, there's something interesting to do over the weekend on your 500 GB hard drive :

Honey, pack me another sandwich, I'm gonna chatter away the hard drive ...

And, it's very easy to undo too
 
  


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
How to make root file system be read-only? Completely Clueless Linux - Security 10 04-19-2009 06:00 AM
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

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

All times are GMT -5. The time now is 12:33 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