 |
|
Accessing Hard
Disks
Oracle Database Tips by Donald Burleson |
An important first step when learning a new
operating system is determining how to view the contents of the disk
drives and other devices such as CD ROMs and floppies.
To begin this process, launch a gnome-terminaland type the ls command. This command lists the contents
of the current working directory, most likely the account's home
directory, /root if logged in as root.
The ls command can be combined with a number of
switches, giving it more functionality. For example, the ls ?l commandreturns a list of files along with all of the attributes
of the files. This command will not return hidden files. Use the ls ?a
commandto return a list of all
files or the ls ?la commandto
return all files including their attributes.
The ls command can be combined with a path such as
ls /etc or a filename such as ls myfile.txt or both a path and a
filename. It can also be used with wildcards such as * for
multi-characters, or - for a single character.
The cd command
is used to change to a different working directory. For example, cd /etc
will place you into the /etc directory. The cd command alone will
place you back into the home directory.
Using the ls command, you can now examine how
Linux controls devices such as hard drives and CDROMs. In the
directory /dev there are listings for hundreds of files that allow
Linux to control devices, most of which are not in use at this time.
These device files are used by Linux to pass data to and receive data
from a device driver and communicate with devices. Linux uses the file
/dev/hda to read from and write to the first hard disk.
If this hard disk is partitioned, it uses the
/dev/hda1 file to access the first partition. Similarly, the /dev/hda2
file is used to access the second partition on the first drive.
The fdisk ‑l command is used to list the hard
disks and their subsequent partitions on the system. This command will
list all partitions, even those that are not mounted or formatted.
In the example shown in Figure 3.1, the first line
reports that hard disk /dev/hda is 6,448 megabytes. The second line
reports that it has 784 cylinders. The third line reports each
cylinder is 8,225,280 bytes. Below the third line, the partitions are
listed, which in this case is just one, /dev/hda1.
This partition starts on cylinder 1 and ends on
cylinder 784, the final cylinder. A second drive, /dev/hdb is also
listed. It has 13.5 gigabytes and three partitions: /dev/hdb1,
/dev/hdb2, and /dev/hdb3. The start cylinder, end cylinder, and file
system for each partition are listed.
Accessing a Hard Disk
by Mounting its File System
In Linux, just because the system detects a hard
disk partition does not necessarily mean that the files on that
partition are accessible. In order to access the files on a disk, the
disk has to be mounted. This brings up the obvious question, 'since
the ls command works, does that mean files can be accessed on disk??
The answer to this question is yes, because the system has already
mounted some or all of the partitions on the disks.
To determine what partitions or devices are
mounted at any time, use either the mount ?l or the df ?h command as
shown in Figure 3.2. In this example, the partition /dev/hdb2 is
mounted on the mount-point /, and the partition /dev/hdb1 is mounted
on the mount-point /boot. The swap partition /dev/hdb3 is not mounted
because swap partitions are handled differently by the operating
system. Note that the df ‑h command reports the used and available
disk space on each mounted file system.
What is a Mount-Point?
To access a file system on a device such as a hard
drive or floppy drive, the file system must be mounted. To mount a new
file system, a directory must exist in the current file system. That
directory does not have to be empty; there can be files within it even
subdirectories. However, once a different file system is mounted to
that directory, the files and subdirectories within that directory
will become unavailable until the new file system is un‑mounted.
To keep things simple and to keep all files
accessible, it is important to keep the directories intended for
mounting other file systems empty. In fact, these directories should
be created and used simply for mounting a specific file system that
may or may not be mounted at boot time.
Fedora has a few mount-points already created for
use. Type the command ls /mnt and you will see a list of the
mount-points that Fedora has created to mount devices that are
commonly mounted and that were detected when the operating system was
installed.
The /etc/fstab File
The /etc/fstab file is a text file that tells
Fedora what file systems to mount on boot. It also associates certain
devices to certain mount-points, effectively abbreviating the command
for mounting those devices. To view this file, type the command more
/etc/fstab as shown in Figure 3.3.
The contents of the /etc/fstab file are listed in
six columns, delimited by white-space, namely device, mount-point,
file-system type, options, dump, and file-system check order. The
details for each of these columns can be found in the manual page for
the /etc/fstab file. Type the man fstab command to enter a manual
page, and type q to exit a manual page.
In the example shown in Figure 3.3, the device
with label ?/? is mounted at the mount-point /, and the device with
label ?/boot? is mounted at /boot. There are two CDROMs and one floppy
that have each been assigned its own mount-point.
Mounting a File System
with the Mount Command
Figure 3.4 shows an example of mounting a file
system using the full syntax and another example using the abbreviated
syntax. The line beginning with ### is commented out. It is used to
illustrate the various parts of the mount command.
Only a device or partition listed in the
configuration file /etc/fstab can be mounted with the abbreviated
syntax such as shown for mounting the floppy drive.
The umount
command is used to un-mount a file system (note the missing ?n?).
Always un-mount a file system before removing a floppy or CD; Linux
does not gracefully handle unexpected file system removal.
 |
If you want to learn RAC at home, get the bestselling book "Personal
Oracle Real Application Clusters" by Edward Stoever.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts. |
|