LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 03-21-2005, 04:39 AM   #1
faezeh
LQ Newbie
 
Registered: Mar 2005
Posts: 19

Rep: Reputation: 0
understanding file "etc/fstab"


Hello,
I know that when you install linux,the file /etc/fstab is made full with devices that are automatically mounted at boot time,but when I view this file after installation,some lines are as follows:
label/device mountpoint fstype
none /proc proc
none /sys sysfs
none /dev/pts devpts
none /dev/shm tmpfs
I donot understand that why these fs donot have a device name and where are they stored?and why are they automatically mounted?
second what type of information do they contain?
I am having difficulty in understanding the difference of these fs with the
one such as "/(root) fs" for which you define a device at installation and in the file /etc/fstab appears as follows:
LABEL=/ / ext3

I would appreciate if you help me.
 
Old 03-21-2005, 04:50 AM   #2
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 48
Quote:
none /proc proc
none /sys sysfs
none /dev/pts devpts
none /dev/shm tmpfs
These have no device name because they're not devices - they're virtual filesystems. /proc, for instance, lists all sorts of information about your computer's hardware at any given moment - hom much CPU is being used, how much memory, what processes are running, what drives are present, and so on.

Many programs, such as "ps" and "free", are just ways of presenting /proc information in a more user-friendly format.

It's worth taking a look at it sometime. It's got lots of useful information in it. But it doesn't exist in hardware, it's a logical construction.
 
Old 03-21-2005, 05:00 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Re: understanding file "etc/fstab"

Hi,

The most common entries in the /etc/fstab file are links between devices and mountpoints (including some options).
Examples of these are:
Code:
/dev/hda1     swap                     swap      sw,pri=128       0 0
/dev/hda2     /                        ext3      defaults         0 1
/dev/hda3     /boot                    ext2      defaults         1 2
In the above example you see that swap is on device /dev/hda1, / (root fs) is on /dev/hda2 and /boot is on /dev/hda3.

This you probably knew already.

The entries you are revering to are somewhat special (although used a lot)
Code:
none                /proc              proc
none                /sys                sysfs
none                /dev/pts         devpts
none                /dev/shm        tmpfs
/proc
/proc is very special in that it is also a virtual filesystem. It's sometimes referred to as a process information pseudo-file system. It doesn't contain 'real' files but runtime system information (e.g. system memory, devices mounted, hardware configuration, etc). For this reason it can be regarded as a control and information centre for the kernel. In fact, quite a lot of system utilities are simply calls to files in this directory. For example, 'lsmod' is the same as 'cat /proc/modules' while 'lspci' is a synonym for 'cat /proc/pci'. By altering files located in this directory you can even read/change kernel parameters (sysctl) while the system is running.

/dev/pts
This is used for the so called pseudo-ttys. Besides the 'real' tty's, you also need pseudo tty's. If you use X (KDE/gnome etc) and do a ps -ef, you will see (assigned) tty's and pts's.

/dev/shm
The /dev/shm mount point for tmpfs is included to allow enabling POSIX-shared memory. The kernel must have the required support built into it for this to work (more about this is in the next section). Please note that very little software currently uses POSIX-shared memory.

Some of these entries also need kernel support (don't worry, the most common ones are enabled by default).

Hope this clears things up a bit.
 
Old 03-21-2005, 08:35 AM   #4
faezeh
LQ Newbie
 
Registered: Mar 2005
Posts: 19

Original Poster
Rep: Reputation: 0
thanks for your guidance,
but still more questions:
first what do you mean by a virtual fs?
I understood that by mounting file systems,we make the fs on one of our storage devices
accessible to linux kernel from a special directory in the directory tree/structure and because
one of our devices such as /dev/hda2 in your example contains information regarding
operating system,it needs to be mounted before the user begins its work with the
operating system,at boot time,and thus is added to "/etc/fstab" to be automatically mounted
and when we turn the computer off this fs is automatically umounted which means that any
changes made to the mountpoint of that directory are written on the fs.What I undersood by your meaning of virtual filesystem was that these file systems do not exist on a storage device,we make them
mount automatically so that their mountpoints are filled with run time information with a special
format(fstype such as proc,tnpfs,sysfs,devpts),and that when the computer begins working or when it is off these virtual fs donot contain any type of files unlike file systems such as root(/).
Am I right?
 
Old 03-21-2005, 09:36 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi again,

Quote:
first what do you mean by a virtual fs?
Neither the /proc directory nor its sub-directories and its files actually exits (virtual), so how one can access, read and edit those files? They are created dynamically in memory form raw kernel data only on demand when you access them. It is actually part of the system's memory - in other words, the kernel sets aside an area of memory in which it stores information about the system. This same area is mounted onto the filesystem so user programs have access to this information.

Take a look here for a more detailed explanation of the /proc filesystem.

Quote:
I understood that by mounting file systems, we make the fs on one of our storage devices accessible to linux kernel from a special directory in the directory tree/structure and because one of our devices such as /dev/hda2 in your example contains information regarding operating system, it needs to be mounted before the user begins its work with the operating system, at boot time,and thus is added to "/etc/fstab" to be automatically mounted and when we turn the computer off this fs is automatically umounted which means that any changes made to the mountpoint of that directory are written on the fs.
At boot time the entries in /etc/fstab (they are not added on-the-fly, devices not in your fstab will not be mounted) are mounted and made accessible. This process is a bit more complicated. In a nutshell: The root fs ( / ) must be mounted first (by the kernel) and is sometimes mounted read-only first, to be re-mounted read-write later. After / is mounted the other devices are mounted by the init process.

Quote:
What I undersood by your meaning of virtual filesystem was that these file systems do not exist on a storage device, we make them mount automatically so that their mountpoints are filled with run time information with a special format(fstype such as proc,tnpfs,sysfs,devpts),and that when the computer begins working or when it is off these virtual fs donot contain any type of files unlike file systems such as root(/).
Am I right?
That sounds about rigth. Although I don't know about the special format. You can read (even write) to the entries in /proc.
A cat /proc/partitions for example will show you info about.... partitions.

Don't start writing to /proc entries unless you know what you are doing, it is often used for kernel tuning and setting features on/off.
This echo "0" > /proc/sys/net/ipv4/conf/all/accept_redirects is often used together with firewalls to disallow redirects.

The last example will be lost after a reboot, unless you put that line in one of the rc.X file in your /etc/rc.d/init.d directory.

Hope this clears things up a bit.

Last edited by druuna; 03-21-2005 at 09:38 AM.
 
Old 03-22-2005, 07:35 AM   #6
faezeh
LQ Newbie
 
Registered: Mar 2005
Posts: 19

Original Poster
Rep: Reputation: 0
Hi again,
I understood by your meaning of virtual fs that runtime information exist as part
of the kernel (Do they consume space for example in RAM?)when a user types "cd /proc"
or when other programms want to access this information,because the directories in linux
are only used as mountpoints,this runtime information are stored in the virtual
file system and this virtual file system is mounted to the mountpoint"/proc",and thus
made accessible to other programms and users,Am I right?
Thanks
 
Old 03-22-2005, 11:40 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Your 'nutshell' reply sounds about correct.

Only thing I'm not sure you grasp: For the user (and processes) /proc can be seen as 'just another fs'. You can for example create, delete files and dirs. You shouldn't though, and user made files are probably gone after the next boot.

I'm not sure if, and if so how much, is stored in RAM. My guess: parts are. But that's just a guess. Mind you I'm not a kernel inner workings expert

You probably looked at it already, but take a look at man proc as well.

By the way: Manpages should mention where they get their info from (normally mentioned in the FILES section). Take a look at the FILES section of man netstat
 
  


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
"bad interpreter : no such file or directory" when configure "flex" acer_peri Linux - Software 10 11-10-2010 01:19 AM
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 09:00 AM
what is "S" instead of "X" in the file permission when i look at /usr/bin/chsh? Linux_interest Linux - Newbie 4 08-28-2004 09:22 AM
decrypting a file using "crypt" & "rot13" JAMZM101 Solaris / OpenSolaris 1 03-07-2004 09:32 AM
Can't locate object method "splitpath" via package "File::Spec" RobJohnston Linux - General 2 06-28-2003 09:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

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