FedoraThis forum is for the discussion of the Fedora Project.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
/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).
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?
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.
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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.