ln -s /proc/mounts /etc/mtab -- don't

Posted by: borislav

ln -s /proc/mounts /etc/mtab -- don't - 01/10/2000 03:21

I finally got around to poking inside the player filesystem today. One of the first things I did was "ln -s /proc/mounts /etc/mtab" which gets mount and df working.

A while later I wanted to sync some more songs and discovered that sync no longer works... Not from emplode, not from emptool. I was about to blame it on the 1.01-rc2 release which I'd just upgraded to but before reporting a bug I thought I'd back out the one change I did and... welll, now it works again.

Is it possible to have both df and sync working?

Borislav

Posted by: altman

Re: ln -s /proc/mounts /etc/mtab -- don't - 01/10/2000 05:40

df works if you put the filesystem after it, eg "df /" or "df /drive0". The ln breaks fsck, and we've not had time to work out why. The sync fails as the fsck gets confused.

Hugo


Posted by: schofiel

Re: ln -s /proc/mounts /etc/mtab -- don't - 02/10/2000 03:32

Are you telling fsck to follow symbolic (soft) links?

One of the few remaining Mk1 owners... #00015
Posted by: fvgestel

Re: ln -s /proc/mounts /etc/mtab -- don't - 02/10/2000 04:21

Rob,
fsck.ext2 reads /etc/mtab to verify the filesystem isn't mounted. If it's mounted it will isssue a warning and waits for a reply. No check is performed to verify that /etc/mtab is a symlink; it just reads /proc/mounts as if it is /etc/mtab.

Frank van Gestel
Posted by: fvgestel

Re: ln -s /proc/mounts /etc/mtab -- don't - 02/10/2000 04:47

To use df you can set the following alias in your .profile :

alias df='/sbin/df `echo \`cat /proc/mounts | sed "s/ [^/].*$//" | sed "s/^.* //"\``'

Please note the difference between single, double and backquotes ( ' " ` )

Frank van Gestel
Posted by: smu

Re: ln -s /proc/mounts /etc/mtab -- don't - 03/10/2000 15:02

Hi Frank

To use df you can set the following alias in your .profile :
alias df='/sbin/df `echo \`cat /proc/mounts | sed "s/ [^/].*$//" | sed "s/^.* //"\``'

Please note the difference between single, double and backquotes ( ' " ` )


The "echo" part is actually superfluous (sp?), and the two sed commands can be joined to make it a bit faster and easier to read. The result is the following alias:
alias df='df       `cat /proc/mounts  | sed "s/ [^/].*$//;s/^.* //"`'
++ | | | | | | | |
call df -------+ +----------+---+ +++ +------+---+ +---+--+
as parameter, output /proc/mounts --+ | | |
use sed to manipulate each line, ------------+ | |
first remove anything following the last "/" ------------+ |
then remove anything before the first " " -------------------------+

Just like you said: Be careful regarding the double / single quotes, back ticks etc.

cu,
sven
Posted by: bonzi

Re: ln -s /proc/mounts /etc/mtab -- don't - 03/10/2000 15:50

One could also add redirection of stderr to null ( 2>/dev/null) to get rid of complaint about not being able to read table of mounted filesystems.

(BTW, no brownie points for me this time: instead of alias I made a script that symlinked /etc/mtab, run df, than unlinked it again. Hardly elegant and does not work with filesystems mounted RO. Thanks for reminded me aliases existed (needless to say, my profiles and rcs that got migrated and bloated from system so system over the years have hundreds of aliases and short shell functions, and yet I wrote a damned script!) ).

Cheers!

Dragi "Bonzi" Raos
Zagreb, Croatia
Q#5196, MkII#80000376, 18GB green
Posted by: fvgestel

Re: ln -s /proc/mounts /etc/mtab -- don't - 03/10/2000 16:15

You're right, combining the two makes sense.
The echo command is only needed on the serial console for some dark reason;
see here for other strange console behaviour

Frank van Gestel