| Getting Started with Linux - Lesson 13 |
|---|
Mounting file systems
In this part of the lesson about file systems we'll learn how to use the
commands mount and umount
We've mentioned previously that there's a different idea in Linux as to
what constitutes a floppy disk drive, a CD-ROM drive and another partition
of your hard disk (the Windows partition, for example). Though some windows
managers for Linux have provisions for clicking on an icon to access a floppy
drive, for example, the method behind this is quite different from other
OSes. In Linux the floppy drive or other device must be "mounted". That
means basically, incorporating it temporarily into your Linux file system or,
in other words, telling Linux that it is a file to be written to or copied
from.
To access a floppy disk from the command line of our shell, we would use
the command mount and type the following: (remember: you need to be
working as 'root' to do this)
mount -t ext2 /dev/fd0 /floppy
Now this assumes a couple of things:
- you have a floppy disk in the drive (you'd be surprised how many times
I forget to actually put the floppy in the drive)
- in this example, the floppy type (indicated by the option -t) is a Linux
formatted floppy. If you want to mount a Windows floppy, change the option
to -t vfat
- in your root directory (you can get to it by typing: cd /), you
have a directory called floppy. If you don't, you should create
it (mkdir floppy). Some Linux distributions create this
automatically during the installation process. Some don't.
Let's explain what we've just done here. When we typed: mount -t ext2 /dev/fd0 /floppy we told Linux that our floppy disk is now part of our
Linux file system (/dev/fd0) and that any files we would like to store on
that disk will be copied to /floppy, as if it were just another directory
on our Linux system. If you did it right, typing the command 'df' (the command
to see how much free disk space) should include something like this:
| /dev/fd0 | 1390 | 649 | 669 | 49% | /floppy
|
Your numbers may vary (especially if your floppy is blank!)
Now, to copy to and from the floppy disk, you would type:
cp my_file /floppy
If you wanted to create individual subdirectories on the floppy, you would
first change to the /floppy directory:
cd /floppy
Then you would use the mkdir command to create the directories
you want. You can also use the command cp -r my_directory/ /floppy to
copy the directory automatically to the floppy. (make sure you have space! -
I have on occasion tried to copy a 3MB file to a 1MB floppy!)
Mounting other devices
You can also use the mount command to copy to and from other devices.
If you would like to get some files from a CD-ROM, the standard command
to do this is:
mount -t iso9660 /dev/hdb /cdrom
The type, iso9660 is the standard file system for a CD. The device
(/dev/hdb) is the non-SCSI type of CD-ROM and the mount point (/cdrom)
should exist. If it doesn't, you should create it in the root directory
with 'mkdir', just as you may have done with the /floppy directory.
Remember that the concept of CD-ROM is read only.
You won't be able to write to this type of CD-ROM drive. A message
will tell you that when you mount this type of device.
Mounting another partition of the hard disk.
Many people may have preferred to install Linux along with another
operating system. You may have Linux and Windows installed in the
same computer. If you would like to access files on the Windows partition
you would type the following command:
mount -t vfat /dev/hda1 /mnt
Windows is always in the primary partition, so that's why we've used
the device /hda1 (hard disk partition 1). The choice for /mnt
is the standard mount point in this case. You may use the /mnt directory
to mount the other devices (floppies, CDs) as well. I use the different
empty directories (/floppy /cdrom /mnt) to avoid confusion.
If you change to the mount directory (cd /mnt) and then type:
ls and you'll see something interesting. The directories are blue but
the files are green (or red - depending on your distribution of Linux).
You won't have the various color combinations as you do in Linux. That's
because Windows' file system doesn't distinguish file types. Everything
looks like it's a program (binary) instead of a regular file.
When you copy files from the Windows partition to the Linux partition
you should bear this in mind. For example, if you wanted to copy an mp3
file from the Windows partition to the Linux partition to test out your
sound configuration, it would show up as a executable program and not
just a standard file under Linux. This doesn't effect your playing it, but for
a more accurate accounting of what you have on your system, you may want
to change the permissions of the file so that it shows up as a regular
file in your color scheme. We'll talk about file permissions and
and making changes to them shortly.
[Previous] [Next]
|