Using Linux:Managing the Filesystem
-->
Previous
Table of Contents
Next
Using the mount Command
To mount a block device into the file system, use the mount command. You must specify what device contains the filesystem, what type it is, and where in the directory hierarchy to mount it.
A mount command looks like this:
mount [-t type] [-o options] device mount-point
device must be a block device; or, if it contains a colon, it can be the name of another machine from which to mount a filesystem. mount-point should be an existing directory; the filesystem appears at this position (anything previously in that directory is hidden). The filesystem type and options are optional, and the variety and meaning of options depend on the type of filesystem being mounted. If the filesystem you want to mount is specified in the /etc/fstab file, you need to specify only the mount point or the device name; the other details will be read from /etc/fstab by mount.
Mounting a floppy with the mount command
1. Use the mount command, followed by the device name, the t (filesystem type) option, the name of a filesystem, and the mount point in your systems directory structure. For example, to mount a floppy disk, first log on as the root operator, and then use the mkdir command to create a mount point like this:
# mkdir /mnt/floppy
2. Use the mount command, specifying your floppy drives device name, and the type of filesystem (such as DOS), like this:
# mount /dev/fd1 -t vfat /mnt/floppy
mount: block device /dev/fd1 is write-protected,
mounting read-only
3. The disks contents become available at the specified mount point (directory). Use the ls (list directory) command to verify that the disk is mounted, like this:
# ls /mnt/floppy
grub-0.4.tar.gz
4. After you have finished reading, copying, or deleting files on the disk, use the umount command, followed by the mount point, or pathname, to unmount the filesystem, like this:
# umount /mnt/floppy
SEE ALSO To learn more about drivers, code modules, and the magic of the Linux kernel, see page 577.
Is it magic, or the Linux kerneld daemon?Mounting a vfat floppy disk causes the Linux kernel to automatically load the vfat driver into the kernel while it is needed. These (and other) drivers are loaded by the system daemon kerneld; when the drivers are no longer being used, such as after a filesystem is unmounted, the drivers are unloaded to recover the memory.
Any one of several things can cause the mount command to fail. It is possible to specify an incorrect device name (that is, to specify a device file that does not exist, one for which a driver is not available in the kernel, or one for which the hardware is not present). Other error conditions include unreadable devices (for example, empty floppy drives or bad media) and insufficient permissions (mount commands other than those sanctioned by the administrator by listing them with the option user in /etc/fstab are forbidden to ordinary users). Trying to mount a device at a mount point that does not already exist also will not work.
Dont forget the mount point
In order to mount a filesystem, the point at which it is to be mounted (that is, the mount point) must be a directory. This directory doesnt have to be empty but after the filesystem is mounted, any files underneath it will be inaccessible. Be careful when mounting disks or other media!
Still more error conditions are possible but unlikely (for example, exceeding the compiled-in limit to the number of mounted filesystems) or self-explanatory (for example, most usage errors for the mount command itself).
Linux provides a singly rooted filesystem, in contrast to those operating systems that give each filesystem a separate drive letter. Although this might seem less flexible, it is actually more flexible, because the size of each block device (that is, the hard disk, or whatever) is hidden from programs, and things can be moved around.
For example, if you have some software that expects to be installed in /opt/umsp, you can install it in /big-disk/stuff/umsp and make /opt/umsp a symbolic link. There is also no need to edit a myriad of configuration files that are now using the wrong drive letter after you install a new disk drive, for example.
There are many options governing how a mounted filesystem behaves; for example, it can be mounted read-only. There are options for filesystems such as msdos, and others, such as the nfs filesystem, which has so many options that it has a separate manual page (man nfs).
Previous
Table of Contents
Next
Wyszukiwarka
Podobne podstrony:
492 496490 aindex (490)487 490szklarnia 1id 490więcej podobnych podstron