LinuxQuestions.org
Help answer threads with 0 replies.
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-09-2004, 08:42 AM   #1
shishimo
Member
 
Registered: Jun 2003
Distribution: Fedora Core 3, so tasty
Posts: 62

Rep: Reputation: 15
Mounting / as read only


I'm using an embedded version of linux called white dwarf, which is based on slackware. I'm trying to mount the / filesystem as read only, but when I use:

mount -o ro,remount /
or
mount -o ro,remount /dev/hda1

I get a "device is busy" error. Also, I've tried going straight to fstab and changing the option from defaults to ro, but also with no success. After rebooting with the new fstab, I type mount and see that / is mount ro, but I can still write to it! I can change it back to rw with

mount -o rw,remount /

but it won't go back to ro at all. How can I mount this drive as read only?

Note: I have external storage that is rw if there are things that the system MUST write.

Thanks!
 
Old 06-09-2004, 09:50 AM   #2
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
you cannot mount / as read only!!
there are certain programs in /bin and /sbin that
need to be executable in order for the system
to boot and run properly.
 
Old 06-10-2004, 08:26 AM   #3
shishimo
Member
 
Registered: Jun 2003
Distribution: Fedora Core 3, so tasty
Posts: 62

Original Poster
Rep: Reputation: 15
Thanks 320mb!

Can't programs still run on a read-only disk if they're not changing at all?? or does read-only mean that strictly? if so, then is there a read/execute mode? It would be nice to have a mode like this because I'm using a flash disk that has a limited number of writes and I'd like to keep it going as long as possible. I have external disk storage which is used for day-to-day stuff that is available for other stuff. Is it worthwhile to make some partitions on the external disk and drop /bin and /sbin on them?
 
Old 06-13-2004, 05:04 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You may want to read the FHS (Filesystem Hierarchy System) as well as the chroot howto's. The /proc, /tmp, /var, and /usr/local partitions need to be writable. The FHS guide goes into detail on which directories can be mounted readonly. The ones that need to be writable need to be mounted on a writable partition.

I don't think you can have the root partition mounted read-only since partitions are mounted under it that need to be writable. However, many of the partitions mounted under it can be. The /usr/local partition needs to be remounted writable when installing new software. You can have a separate partition for /usr/local and include a line in the fstab for it. That way, /usr can remain mounted readonly. The /proc is a pseudo file system, but to be writable by the kernel, the root partition needs to be writable. The /var partition is where the log files are written to, as well as other types of caches.

You may also want to google for 'embedded linux ram-disk'. Normally, during bootup, the partitions are first mounted read-only, with the root partition being the ramdisk 'initrd'. An option may be to retain the ram-disk as the root partition, but you'll need to do this research yourself. The chroot howto may help. I think there is also an embedded linux howto around also.

I'd be interested if you gave more infomation on what system you are using and what it is used for. Sounds like it might be interesting.

Good Luck!

Last edited by jschiwal; 06-13-2004 at 05:17 AM.
 
Old 06-13-2004, 06:26 AM   #5
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
you can mount root as read-only but not on a fully running system. the filesystem is mounted as read-only at boot, if it is ext2, checked to see if it is clean, then if it is, it is remounted read-write. reiserfs cannot be mounted read-only, i think. a lot of software
needs to be able to write to the drive to run.
 
Old 06-14-2004, 03:29 AM   #6
orange400
Member
 
Registered: Mar 2003
Location: Bellevue, WA
Distribution: Arch w/ XFCE
Posts: 834

Rep: Reputation: 30
Don't forget about the logs too ... they need the hd to write to.
 
Old 06-14-2004, 03:20 PM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Since the logs in /var/cache are written to quite frequently, you may want to make sure they are either written to a hd or sent to a logging host rather than written to flash memory. Using a dedicated logging host connected directly to the computer is a security method I read about. The logging host may be connected directly to the computer sending the logs, rather than having a connection on the network switch. This makes it harder for hackers to cover their tracks, and reveals which files where comprimised. Look for the syslog or syslog.conf man page for information. There may be some programs running that can't be configured or able to log events via syslog however.

Since you are using an embedded system, I assume you might be using it as a gateway or router. If that is the case, consider having the root partition, and writable partitions in ramdisk, and the read-only partitions like /bin /usr /sbin /etc on the flash drive.

Last edited by jschiwal; 06-14-2004 at 03:25 PM.
 
Old 06-22-2004, 01:25 PM   #8
shishimo
Member
 
Registered: Jun 2003
Distribution: Fedora Core 3, so tasty
Posts: 62

Original Poster
Rep: Reputation: 15
wow! thanks everyone for all the responses. Right now, I'm using an embedded computer on an autonomous vehicle at Virginia Tech.

http://www.ee.vt.edu/~ascl/

I want to hard drive to be read-only to reserve the onboard flash hard drive as long as possible, which has a limited number of writes. Setting up a ramdisk might not be the easiest option for me, since i have limited amount and i'd like to keep it available for computation, since i need data and control in realtime. right now, im taking a look at FHS. is it universal across all linuces? more importantly, is slackware compliant with it? (since thats what my bare bones version is based on)

i tried moving /sbin /bin /etc to partitions on the external storage, but that did not solve the problem.
 
Old 06-22-2004, 09:57 PM   #9
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
you could look at the knoppix scripts for that. since they run from a cdrom, most of it has to be read-only.
 
Old 06-23-2004, 01:24 AM   #10
wpyh
Member
 
Registered: Jun 2004
Location: Beijing
Distribution: Slackware 9.1 but FUBAR with packages I compile myself, and OpenBSD (not exactly a distro) on QEMU
Posts: 153

Rep: Reputation: 35
Well,
1. read-only doesn't mean no-execute
2. a filesystem can be mounted read-write, under the directory tree of a read-only filesystem (try it )
3. yes, logs can be redirected, or not made at all
4. since you are developing an embedded system, why not take a step further and customize everything you can? No need to stick to FHS

I don't think Slackware is FHS-compliant, but as I said before, you might as well customize everything to get a very small footprint and a realtime system
 
  


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
mounting a drive read only youngstorm Linux - Hardware 3 09-26-2005 10:53 PM
iPod mounting read-only FishieFishie Linux - Hardware 3 06-03-2005 07:32 PM
mounting root fs read-only andrewb758 Linux - Software 6 10-09-2003 12:32 PM
Mounting NTFS read-write fredws Linux - Newbie 19 08-16-2003 04:11 PM
mounting cdrw read only in mandrake 7 zeroability Linux - Newbie 33 12-31-2002 03:49 PM

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

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