|Lesson 7||Mounting and unmounting partitions|
|Objective||Describe the use of the mount and unmount commands. |
Mounting and unmounting partitions on Unix OS
You attach a new filesystem to the filesystem using the
In its simplest form, this command's syntax on a Linux machine is
mount –t type device mount-point
This command instructs the system to attach the filesystem on the specified device special file to the directory given as a mount-point
mount-point. In addition, the
mount command takes many options that affect the way the mounted filesystem is treated.
The mount command Options
mount command takes many options that affect the way the mounted filesystem is treated. You specify options on the command line as a comma-separated list marked with a
–o flag. For example, this Linux command mounts /dev/fd0 with the read-only (
nosuid options set:
mount –t ext2 –o ro,nosuid /dev/fd0
For a complete list of potential options, refer to the manual page for
mount on your system. Note also that options vary among filesystem types. Here are some common useful options for the
| Option || Purpose |
ro=Read-only. Filesystem is mounted read-only.
| If a filesystem is mounted |
nosuid, the SUID protection bit has no effect for files on that filesystem. This can be a useful security measure. The default is
suid, which allows the SUID bit to take effect.
| If a filesystem is mounted |
noexec, binaries on that filesystem cannot be run; the filesystem is used for data only. The default is
exec, which means binaries can be run.
noauto means the filesystem must be mounted by an explicit call to the
mount command, rather than automatically at boot time. This option is used in configuration files discussed in the next lesson.
remount an already mounted filesystem. Used to change the options set for a mounted filesystem, without a complete
On a Solaris system, you would use
–F instead of
–t to specify the type of filesystem. Solaris, however, automatically mounts a filesystem once it is set up in the system configuration file. Generally, it's necessary to specify either the mount-point or the special device file in the
mount command, but not both. For example:
looks up /disk1d in the configuration file to determine what special file is used to access it and then constructs and executes the proper
mount command. We eill examine this in detail later in this module.
On AIX, use
–v instead of
–F to specify the type of filesystem.
The command to unmount, or unattach, a filesystem is
You may specify either the device to be unmounted or the mount-point to be released. For example:
A filesystem cannot be unmounted if it is "busy." A filesystem is busy if some process has files open in that filesystem. For example, if your shell has the directory /home/userA as its current directory, and you try to unmount /home, you will see the following:
/home: Device Busy
In most cases, you must have root permissions to mount or unmount filesystems. Note: How do you remove the floppy on Solaris? How do you make the CD-ROM come out of the drive? Try the
A mount-point is the directory to which a filesystem will be mounted.
eject command. Many Sun machines have no physical eject button, so you have to rely on this command to get your removable disk out. It serves the same purpose as umount for removable devices.