LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   /etc/mtab vs. /proc/self/mounts (https://www.linuxquestions.org/questions/slackware-14/etc-mtab-vs-proc-self-mounts-371224/)

ciotog 10-09-2005 10:55 AM

/etc/mtab vs. /proc/self/mounts
 
I was reading through the man page for mount today, and noticed in the section about using the loop device that it's recommended to make /etc/mtab a symlink to /proc/mounts in order for umount to automatically free loop devices. Now I shut down every night and rarely use the loop device, but I'm also somewhat pedantic and would rather have things just right.

Now /proc/mounts is a symlink to /proc/self/mounts, so to follow the mount man page recommendation properly /etc/mtab should point there instead, but on examining the contents of both those files there are several minor differences:
Code:

bash-3.00# cat /etc/mtab
/dev/hda3 / reiserfs rw 0 0
/dev/hda5 /home reiserfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
usbfs /proc/bus/usb usbfs rw 0 0

and
Code:

bash-3.00# cat /proc/self/mounts
rootfs / rootfs rw 0 0
/dev/root / reiserfs rw 0 0
/dev/hda5 /home reiserfs rw 0 0
devpts /dev/pts devpts rw 0 0
proc /proc proc rw,nodiratime 0 0
sysfs /sys sysfs rw 0 0
usbfs /proc/bus/usb usbfs rw 0 0

Despite the differences (which suggests two different processes each acting on one of the files), is it still ok to change /etc/mtab to be a symlink, or is this not recommended (other than by the mount man page)? Or is there a way to remove /etc/mtab altogether (since the existence of /proc/self/mounts makes it redundant and it doesn't make sense to have it in /etc anyway)?

imitheos 10-10-2005 04:31 AM

Re: /etc/mtab vs. /proc/self/mounts
 
Quote:

Originally posted by ciotog
I was reading through the man page for mount today, and noticed in the section about using the loop device that it's recommended to make /etc/mtab a symlink to /proc/mounts in order for umount to automatically free loop devices. Now I shut down every night and rarely use the loop device, but I'm also somewhat pedantic and would rather have things just right.

Now /proc/mounts is a symlink to /proc/self/mounts, so to follow the mount man page recommendation properly /etc/mtab should point there instead, but on examining the contents of both those files there are several minor differences:
Code:

bash-3.00# cat /etc/mtab
devpts /dev/pts devpts rw,gid=5,mode=620 0 0

and
Code:

bash-3.00# cat /proc/self/mounts
devpts /dev/pts devpts rw 0 0

Despite the differences (which suggests two different processes each acting on one of the files), is it still ok to change /etc/mtab to be a symlink, or is this not recommended (other than by the mount man page)? Or is there a way to remove /etc/mtab altogether (since the existence of /proc/self/mounts makes it redundant and it doesn't make sense to have it in /etc anyway)?

Most programs use /etc/mtab, so you can't delete it but you can symlink it to /proc/mounts
This way from what you see in your example you lose some information about mounting.
That is why the man page mention you won't be able to umount automatically loop devices.
you will have to do "losetup -d /dev/loopX"

I used /proc/mounts for a long time and didn't notice any "problem" other than the loop umounting (which is annoying if you
use it frequently)


All times are GMT -5. The time now is 02:09 PM.