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. (Now a days Ubuntu, fedora and other user friendly Linux flavors automatically detects windows NTFS and other partitions.)
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 any partition
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
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 partitions
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
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.
How to unmount partitions
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
or
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/floppyor
$ 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.
No comments:
Post a Comment