Re: quick scripting 'is /P/Q mounted'
- Date: Tue, 13 Mar 2018 14:49:56 +0100
- From: <tomas@xxxxxxxxxx>
- Subject: Re: quick scripting 'is /P/Q mounted'
-----BEGIN PGP SIGNED MESSAGE-----
On Tue, Mar 13, 2018 at 10:33:43PM +0900, Mark Fletcher wrote:
> On Tue, Mar 13, 2018 at 08:49:58PM +1100, David wrote:
> > On 13 March 2018 at 14:40, Mike McClain <mike.junk.46@xxxxxxx> wrote:
> > >
> > > If my other computer is South40 and I want to mount South40's /docs
> > > on my /south40/docs/ directory I can do that. As one script calls
> > > another I want to know if I need to mount South40 without
> > > $( mount | grep 'south40/docs').
> > >
> > > Suggestions?
> > Installing the package util-linux will provide the mountpoint command
> > which exits true=0 if its argument is in use as a mountpoint. Example:
> > $ if mountpoint / ; then echo "exit status is $?" ; fi
> > / is a mountpoint
> > exit status is 0
> Unless I've misunderstood the question, you can tell if something is
> mounted at a mount point by checking if anything is present under the
> mount point [...]
Not if the file system is really empty (and no, lost+found doesn't really
count, since not all file systems have that). Watch this:
tomas@trotzki:~$ dd if=/dev/zero of=fatty bs=1024 count=1024
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00582808 s, 180 MB/s
tomas@trotzki:~$ mkfs.vfat fatty
bash: mkfs.vfat: command not found
tomas@trotzki:~$ /sbin/mkfs.vfat fatty
mkfs.fat 4.1 (2017-01-24)
tomas@trotzki:~$ sudo mount -ouid=tomas,gid=tomas fatty /mnt
[sudo] password for tomas:
tomas@trotzki:~$ ls -al /mnt
drwxr-xr-x 2 tomas tomas 16384 Jan 1 1970 .
drwxr-xr-x 23 root root 4096 Feb 23 12:42 ..
Conversely, the directory you mount things on doesn't have to be empty:
its contents is just shadowed while the mount lasts.
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
-----END PGP SIGNATURE-----