mount and umount

John Seth johnseth at phoenixwing.com
Sun Sep 21 19:00:14 EDT 2003


A mount point is nothing more than a directory. Writing to it is
possible at any time unless a device is mounted read-only to that
directory.  If a device is not mounted, it merely becomes 'just another
directory'.

To my knowledge you would have to run the 'mount' command and parse the
output to see if your device exists in the mounted device list. Try 'man
mount' to see if there's a test ability.

-- 
<? print(pack("c*", 74,117,115,116,32,/* Tony Evans                  */
 65,110,111,116,104,101,114,32,80,72, /* Linux/Web Implementation    */
 80,32,72,97,99,107,101,114,46,10));  /* http://www.phoenixwing.com/ */ ?>


> I have a removeable ide hard disk as hdb1.  I want to write a script to
> access it for backup (a copy of my fstab is included below.  I wanted to
> test if it was mounted, and, if not, mount it.  To try it out, I went
> into an Xterm.
> I su'd and mounted it -
> mount /dev/hdb1 /mount/portable.  I  did a cd /mnt/portable and wrote a
> small junk file to it and that worked.  So far so good.  Then, I did a
> cd .. and umount /dev/hdb1.
> I tried that again and it told it was not mounted (as expected).  BUT, I
> then did an ls /mnt/portable and it still worked!  I even copied another
> small junk file to it (although I had to su for it to work, which I
> don't understand).
>
> I thought that when I unmounted the device, trying to access, let alone
> write to /mnt/portable would fail and generate an error.  It didn't!
>
> What don't I understand (about this in particular :) )?
>
> How do you test to see if a device is mounted (or accessible?) ?
>
> Joe
>
> /etc/fstab:
>
> /dev/hda7 / ext3 defaults 1 1
> /dev/hda6 /boot ext2 defaults 1 2
> none /dev/pts devpts mode=0620  0
> /dev/hda9 /home ext3 defaults 1 2
> none /mnt/cdrom supermount
> dev=/dev/scd0,fs=auto,ro,--,iocharset=iso8859-1,codepage=850,umask=0  0
> /dev/hda1 /mnt/dos_hda1 vfat
> iocharset=iso8859-1,codepage=850,umask=0,defaults  0
> /dev/hda5 /mnt/dos_hda5 vfat
> iocharset=iso8859-1,codepage=850,umask=0,defaults  0
> none /mnt/floppy supermount
> dev=/dev/fd0,fs=auto,--,iocharset=iso8859-1,sync,codepage=850,umask=0 0
> 0
> /dev/hdb1 /mnt/portable ext3 rw,user,noauto,exec,suid  0
> none /proc proc defaults  0
> /dev/hda8 swap swap defaults  0
> ----------------------------------
> "I can assure you the flying saucers, given that they exist, are not
> constructed by any power on earth." --Harry S. Truman; White House Press
> Conference, Washington DC, April 4, 1950.
>
>
>
>
>
>




More information about the nflug mailing list