What is mounting >
As you know, you can
store your data in different physical storage devices, like floppies, CD-ROMs,
and hard disk drives. Your hard disk or disks are also very likely split up
into different partitions with different filesystems.
If you're migrating to
Linux from Microsoft Windows, you're probably used to accessing all your
filesystems very easily: you just boot up your puter, go to My Computer, and find all your Windows partitions there
immediately. For example, if you have a second hard drive (or a second Windows
partition), it automatically appears as D:\ and you can immediately access it.
The same goes for floppies, CD-ROMs, digital cameras, and other storage devices
- you just plug them in, and you'll be able to immediately access them.
However, this isn't the case in Linux.
You're probably a bit
confused at first: you put your floppy or CD into the drive and start wondering
why you're not able to access it! This is because your floppies, CDs, hard disk
partitions, and other storage devices must be attached to some existing
directory on your system before they can be accessed. This attaching is called mounting, and the directory where the device is
attached is called a mount point.
After the device is
mounted, you can access the files on that device by accessing the directory
where the device is attached. When you're done and want to remove the floppy or
CD or other device, you need to detach, unmount, it before removing it.
< How to mount >
Mounting is done with
the mount command.
When mounting, you
must tell the mount command what is the device or partition you
want to mount and what is the mount point. The mount point must be a directory
that already exists on your system. For example, to mount your floppy:
$ mount /dev/fd0 /mnt/floppy
$ mount /dev/fd0 /mnt/floppy
In this example, /dev/fd0 is your floppy drive,
and /mnt/floppy is the mount point.
Now when you access /mnt/floppy, you'll actually access the files on your
floppy.
Usually /dev/fd0 is your floppy drive,
although some distros are configured so that /dev/floppy is the same thing as /dev/fd0. Usually your CD-ROM
is configured the same way: /dev/cdrom is your CD-ROM device (or, more specifically, /dev/floppy is a symbolic link to
your actual floppy drive, and /dev/cdrom is a symbolic link to your CD-ROM drive).
< Where to mount >
Although many Linux
distros have directories like /mnt/floppy or /floppy created by default so you can mount your
floppies there, you're not forced to use these directories. Using the mount command, you can mount
your devices or partitions into any existing directory you want!
Usually your Linux
distro is configured so that one particular directory is the default mount
point for one particular device. In most distros it's /mnt/floppy or /floppy for floppies, and /mnt/cdrom or /cdrom for CD-ROMs. When this
is the case, you don't need to tell mount the whole device name: just give either the
device or mount point and you're ok. For example, if /mnt/floppy is the default mount
point for /dev/fd0 (or whatever your floppy drive is), this would
mount your floppy:
$ mount /mnt/floppy
$ mount /mnt/floppy
The default mount
points for different devices are configured in a file called /etc/fstab. The root user can
freely edit the mount points configured in that file. If you're interested in
learning how this file works, have a look at the Editing and
understanding/etc/fstab tuXfile.
< How to unmount >
Unmounting is done
with the umount command. No, I didn't make a typo: the command
really is umount, not unmount.
When unmounting,
you'll need to tell umount what mounted device to unmount, either by
telling what's the device or the mount point. For example, if /dev/fd0 is mounted to /mnt/floppy, you'll unmount it
with
$ umount /mnt/floppy
or
$ umount /dev/fd0
$ umount /mnt/floppy
or
$ umount /dev/fd0
It's not wise to
remove the floppy from the floppy drive without unmounting it first! In the
worst case the data you were writing to the floppy wasn't written into it yet.
With CD-ROMs you can't do this: the tray won't even open if you haven't
unmounted the CD first.
Example
uses of the Linux Command mount
The following examples illustrate typical uses
of the command mount for attaching the file directory of a device or partition to
the file directory tree of the Linux system.
mount
/dev/fd0 /mnt/floppy
This command will connect the
device "/dev/fd0" (usually the floppy drive) to the directory
"/mnt/floppy" so that you can access the files and directories
(folders) on the floppy disk in the floppy drive under the
"/mnt/floppy" directory. The directory "/mnt/floppy" is
also called the "mount point", which must already exist when this
command is executed.
mount /dev/cdrom /mnt/cdrom
This command will connect the device "/dev/cdrom"
(usually the CD ROM drive) to the directory "/mnt/cdrom" so that you
can access the files and directories on the CD ROM disk in the CD ROM drive
under the "/mnt/cdrom" directory, which must already exist when this
command is executed.
umount
/mnt/floppy
This command unmounts the floppy drive. After
this command is executed the files and directories on the floppy will no longer
be accessible from the directory tree of the Linux system.
umount
/dev/fd0
This has the same effect as the previous
command.
umount
/mnt/cdrom
This command unmounts the CD ROM drive. After
this command is executed the files and directories on the CD ROM will no longer
be accessible from the directory tree of the Linux system.
umount
/dev/cdrom
This has the same effect as
the previous command.
The default mount points for the various devices are defined the file /etc/fstab. Some Linux distributions use a program called automount, which automatically mounts all the partitions and devices listed in /etc/fstab.
The default mount points for the various devices are defined the file /etc/fstab. Some Linux distributions use a program called automount, which automatically mounts all the partitions and devices listed in /etc/fstab.
0 comments:
Post a Comment