pavement

Umount

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
m (Added example)
m (Reverted edits by 65.87.115.8 (Talk); changed back to last version by DrModiford)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{System-Commands}}
 
{{System-Commands}}
  
The '''unmount''' command is used to unlink a file system from the local host, usually a file system previously linked using the [[mount]] command.
+
The '''umount''' command is used to unlink a file system from the local host, usually a file system previously linked using the [[mount]] command.
  
Typically the unmount command is used to release a CD or DVD-ROM drive so that it can be ejected, allow a USB memory key to be cleanly unmounted before unplugging it (Microsoft Windows has a similar function to safely remove devices) or any other file system linked to the local host.
+
Typically the umount command is used to release a CD or DVD-ROM drive so that it can be ejected, allow a USB memory key to be cleanly unmounted before unplugging it (Microsoft Windows has a similar function to safely remove devices) or any other file system linked to the local host.
  
Example:
+
== Example use ==
  
  # unmount /mnt/cdrom
+
An example pf the unmount command:
 +
 
 +
  # umount /mnt/cdrom
  
 
This simply unlinks the CD-ROM drive (or rather the 'file system' stored on the physical media) from the local host.
 
This simply unlinks the CD-ROM drive (or rather the 'file system' stored on the physical media) from the local host.
  
See also related articles: [[mount]] and [[etc/fstab]].
+
== Notes ==
 +
 
 +
The umount command will not unlink a file system that is in use.  While this may sound obvious it can often catch-out even the best sysadmins.  This could be caused by opening a file for editing or simply having the mount-point as the current directory, as per the following example:
 +
 
 +
# mount_cd9660 /dev/acd0 /mnt/cdrom/
 +
# cd /mnt/cdrom/
 +
# ls
 +
.cshrc          INSTALL.HTM    boot.catalog    media          sys
 +
.profile        INSTALL.TXT    cdrom.inf      mnt            tmp
 +
6.3-RELEASE    README.HTM      dev            packages        tools
 +
COPYRIGHT      README.TXT      docbook.css    proc            usr
 +
ERRATA.HTM      RELNOTES.HTM    etc            rescue          var
 +
ERRATA.TXT      RELNOTES.TXT    floppies        root
 +
HARDWARE.HTM    bin            lib            sbin
 +
HARDWARE.TXT    boot            libexec        stand
 +
#
 +
# umount /mnt/cdrom
 +
umount: unmount of /mnt/cdrom failed: Device busy
 +
 
 +
This example shows how a user could mount a CD-ROM file system and enter into the '/mnt/cdrom' mount-point before trying to unlink it.  This creates an error noting the device (in this case, the CD-ROM drive) is busy.  To resolve this problem the user would simply need to do the following:
 +
 
 +
# cd ..
 +
# umount /mnt/cdrom
 +
#
 +
 
 +
Which returns the user to the '/mnt' directory and releases the file system from use.
 +
 
 +
Other possible causes is mounting and entering into a linked file system as a general user and then using the [[su]] command to operate as the [[root]] user then, while as root, trying the umount command.  The file system remains locked under the general user's session.  In this case the user must exit out of the root user session and release the file system before trying again.
 +
 
 +
The [[fstat]] command can be used to identify open, or active, files on the locally attached file systems.
 +
 
 +
== See also ==
 +
 
 +
See also related articles: [[mount]], [[etc/fstab]] and [[fstat]].
  
 
[[Category:System Commands]]
 
[[Category:System Commands]]

Latest revision as of 20:43, 29 June 2009

The Mediawiki system (the 'software' that runs this site) capitalises all articles. Please note that commands on most UNIX and Unix-like systems are entered in lower case. As an example the article documenting the Ln command would be issued from the command line as 'ln'.

The umount command is used to unlink a file system from the local host, usually a file system previously linked using the mount command.

Typically the umount command is used to release a CD or DVD-ROM drive so that it can be ejected, allow a USB memory key to be cleanly unmounted before unplugging it (Microsoft Windows has a similar function to safely remove devices) or any other file system linked to the local host.

[edit] Example use

An example pf the unmount command:

# umount /mnt/cdrom

This simply unlinks the CD-ROM drive (or rather the 'file system' stored on the physical media) from the local host.

[edit] Notes

The umount command will not unlink a file system that is in use. While this may sound obvious it can often catch-out even the best sysadmins. This could be caused by opening a file for editing or simply having the mount-point as the current directory, as per the following example:

# mount_cd9660 /dev/acd0 /mnt/cdrom/
# cd /mnt/cdrom/
# ls
.cshrc          INSTALL.HTM     boot.catalog    media           sys
.profile        INSTALL.TXT     cdrom.inf       mnt             tmp
6.3-RELEASE     README.HTM      dev             packages        tools
COPYRIGHT       README.TXT      docbook.css     proc            usr
ERRATA.HTM      RELNOTES.HTM    etc             rescue          var
ERRATA.TXT      RELNOTES.TXT    floppies        root
HARDWARE.HTM    bin             lib             sbin
HARDWARE.TXT    boot            libexec         stand
#
# umount /mnt/cdrom
umount: unmount of /mnt/cdrom failed: Device busy

This example shows how a user could mount a CD-ROM file system and enter into the '/mnt/cdrom' mount-point before trying to unlink it. This creates an error noting the device (in this case, the CD-ROM drive) is busy. To resolve this problem the user would simply need to do the following:

# cd ..
# umount /mnt/cdrom
#

Which returns the user to the '/mnt' directory and releases the file system from use.

Other possible causes is mounting and entering into a linked file system as a general user and then using the su command to operate as the root user then, while as root, trying the umount command. The file system remains locked under the general user's session. In this case the user must exit out of the root user session and release the file system before trying again.

The fstat command can be used to identify open, or active, files on the locally attached file systems.

[edit] See also

See also related articles: mount, etc/fstab and fstat.

Personal tools