LPI Linux Certification in a Nutshell (24 page)

Read LPI Linux Certification in a Nutshell Online

Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger

Tags: #Reference:Computers

BOOK: LPI Linux Certification in a Nutshell
11.46Mb size Format: txt, pdf, ePub
Chapter 7. Devices, Linux
Filesystems, and the Filesystem Hierarchy
Standard (Topic 104)

Filesystem management is among the most critical activities that you
must perform to maintain a stable Linux system. In simple situations, after
a successful installation, you may never have a problem or need to manage
filesystem specifics. However, understanding how to configure and maintain
Linux filesystems is essential to safely manage your system and to pass Exam
101. This section contains the following Objectives:

Objective 1: Create Partitions and
Filesystems

This Objective states that an LPIC 1 candidate should be
able to configure disk partitions and create filesystems on media such
as hard disks. It also includes using various
mkfs
commands to set up filesystems such as
ext2
,
ext3
,
reiserfs
,
vfat
, and
xfs
, in addition to managing swap partitions.
Weight: 2.

Objective 2: Maintain the Integrity of
Filesystems

A candidate should be able to verify the integrity of
filesystems, monitor free space and inodes, and repair simple
filesystem problems. This Objective includes the commands required to
maintain a standard filesystem as well as the extra data associated
with a
journaling
filesystem. Weight: 2.

Objective 3: Control Filesystem Mounting and
Unmounting

Candidates should be able to manually mount and unmount
filesystems, configure filesystem mounting on system boot, and
configure user-mountable removable filesystems such as flash drives,
floppies, and CDs. Weight: 3.

Objective 4: Set and View Disk Quotas

This Objective includes managing disk quotas for system
users. You should be able to set up a disk quota for a filesystem,
edit, check, and generate user quota reports. Weight: 1.

Objective 5: Manage File Permissions and
Ownership

Candidates should be able to control file access through
file permissions. This Objective includes access permissions on
regular and special files as well as directories. Also included are
access modes such as
suid, sgid
, and the
sticky bit
. You should also be aware of the use
of the group field to grant file access to workgroups, the
immutable flag
, and the default file creation
mode. Weight: 3.

Objective 6: Create and Change Hard and Symbolic
Links

Candidates should be able to create and manage hard and
symbolic links to a file. This Objective includes the ability to
create and identify links, copy files through links, and use linked
files to support system administration tasks. Weight: 2.

Objective 7: Find System Files and Place Files in the
Correct Location

This Objective states that candidates should be
thoroughly familiar with the FHS, including typical file locations and
directory classifications. This includes the ability to find files and
commands on a Linux System. Weight: 2.

Objective 1: Create Partitions and Filesystems

The term
filesystem
refers to two different
things. First, it can mean the way files and directories are physically
structured on a disk or other storage medium. Linux supports many
different filesystems (in this sense of the word), including
ext2
and
ext3
, the nonjournaled
and journaled (respectively) native filesystems;
msdos
or
vfat
, the native MS-DOS
and Windows (respectively) filesystems; JFS, a filesystem used on OS/2 and
AIX; XFS, the native IRIX filesystem; and many, many others.

In the second sense of the word, it refers to the structure and
contents of some storage medium. To view the contents of a filesystem (in
this sense of the word) on a Linux system, the device must be
mounted
, or attached to the
hierarchical directory structure on the system. Much of the strength and
flexibility of Linux (and Unix) comes from the ability to mount any
filesystem that it supports, whether that filesystem is somewhere remote
on the network or on a locally attached disk, anywhere in its directory
structure, in a way that is completely transparent to users. For example,
the files under
/usr
will work
equally well whether they are on a disk attached to the system or mounted
from a master server. Even the
/
(root) filesystem can be located on a distant server if the system is
properly configured.

Disk Drives Under Linux

Linux supports many types of disk devices and formats. Any
SCSI or
IDE hard disk will work with Linux, as will floppy disks,
CD-ROMs, CD-Rs, USB flash drives, and other types of removable media.
These media can contain the standard Linux
ext2
filesystem, FAT, FAT32, NTFS, as well as other filesystem types. This
flexibility makes Linux coexist nicely with other operating systems on
multiboot systems.

The most commonly found hard disks on PCs are IDE drives. These
disks feature a relatively simple system interface, and most of the
“smarts” of the disk are onboard the disk itself. The IDE standard
allows disk manufacturers to sell their product at a very competitive
price, expanding their markets to more consumers and limited-budget
commercial customers.

A single IDE interface is capable of attaching two disk drives to
a system. One device is named
master
and the other is the
slave
. Most PCs have a
primary
and
secondary
IDE interface. Together,
these interfaces allow up to four devices (primary master, primary
slave, secondary master, and secondary slave).

Also used on PCs are
SCSI drives. SCSI is an older standard for connecting
peripherals; however, modern SCSI versions are quite fast and flexible.
Typically, SCSI devices are used for their increased speed and
reliability in large-scale and high-end server environments. With the
increased speeds, however, come increased prices—often two to five times
the price of their IDE counterparts.

Compared to IDE, SCSI offers excellent performance, lower CPU
utilization, and a much more flexible connection scheme capable of
handling up to 15 devices on a single bus. These conveniences allow SCSI
systems to grow as space requirements increase without major hardware
reconfiguration.

A third option available on motherboards in recent years is the
Serial ATA (SATA) interface. SATA is basically a newer version of the
IDE standard, and allows for much faster communication between the
controller and the physical disk. The Linux kernel currently uses the
SCSI emulation layer
to support SATA
hard drives, so from a device standpoint, SATA disks are treated the
same way as SCSI disks. It’s also important to note that some Linux
distributions are configured to use the SCSI emulation layer for IDE
disks as well, so you may be referring to your disks via the SCSI naming
conventions even if you have IDE or SATA disks.

Hard disk devices

By default, Linux defines IDE device files as
follows:

/dev/hda

Primary master IDE (often the hard disk)

/dev/hdb

Primary slave IDE

/dev/hdc

Secondary master IDE (often a CD-ROM)

/dev/hdd

Secondary slave IDE

SCSI device files (or any devices using the SCSI emulation
layer) are similar, except that there is no four-device
limitation:

/dev/sda

First SCSI drive

/dev/sdb

Second SCSI drive

/dev/sdc

Third SCSI drive (and so on)

Under Linux, a typical PC with a single hard disk on the
primary IDE interface and a single CD-ROM on the
secondary IDE interface would have disk drive
/dev/hda
and CD-ROM
/dev/hdc
.

On the Exam

You should be prepared to identify IDE and SCSI devices based
on their device filenames.

Disk partitions

Almost every operating system supports a system for dividing a
disk into logical devices, called
partitions
. Other terms for the
same basic concept are
slices
and
logical volumes
, although logical
volumes generally also imply the ability to span physical disks. Linux
supports several different partitioning formats, but by default it
uses the MS-DOS format. The MS-DOS partition table allows for up to
four
primary partitions
. One of these four
primary partitions can be replaced with an
extended
partition
, which can contain up to 12
logical
partitions
, for a total of 15 possible usable partitions
(16 if you count the extended partition “container,” but it is not
usable for data).

The type of partition (as well as the type of device) affects
the name of the device Linux uses to access the partition.

Primary partitions

This type of partition contains a filesystem. If
all four primary partitions exist on an
IDE drive, they are numbered as follows:

  • /dev/hda1

  • /dev/hda2

  • /dev/hda3

  • /dev/hda4

One of these primary partitions may be marked
active
, in which case the PC BIOS will be
able to select it for boot.

Extended partitions

An extended partition is a variant of the primary
partition but cannot contain a filesystem. Instead, it contains
logical partitions
. Only one extended
partition may exist on a single physical disk. For example, the
partitions on a disk with one primary partition and the sole
extended partition might be numbered as follows:

  • /dev/hda1
    (primary)

  • /dev/hda2
    (extended)

Logical partitions

Logical partitions exist
within
the extended partition. Logical
partitions are numbered from 5 to 16. The partitions on a disk
with one primary partition, one extended partition, and four
logical partitions might be numbered as
follows
:

  • /dev/hda1
    (primary)

  • /dev/hda2
    (extended)

  • /dev/hda5
    (logical)

  • /dev/hda6
    (logical)

  • /dev/hda7
    (logical)

  • /dev/hda8
    (logical)

If the partitions were made on a SCSI or SATA drive, the
hda
would be replaced by
sda
, for example,
/dev/sda2
.

On the Exam

Be sure that you understand how
partition numbering works. In particular, pay
attention to the differences in numbering between primary, extended,
and logical partitions.

The root filesystem and mount points

As a Linux system boots, the first filesystem that
becomes available is the top level, or
root
filesystem, denoted with a
single forward slash. The root filesystem
/
, also
known as the
root directory
, shouldn’t be
confused with the
root
superuser account or the
superuser’s home directory,
/root
. The distinct
directories
/
and
/root
are
unrelated and are not required to share the same filesystem. In a
simple installation, the root filesystem could contain nearly
everything on the system. However, such an arrangement could lead to
system failure if the root filesystem fills to capacity. Instead,
multiple partitions are typically defined, each containing one of the
directories under
/
. As the Linux kernel boots,
the partitions are
mounted
to the root
filesystem, and together create a single unified filesystem (see
Objective 3: Control Filesystem Mounting and Unmounting
for a discussion
about mounting). Everything on the system that is not stored in a
mounted partition is stored locally in the
/
(root) partition. The mounted filesystems are placed on separate
partitions and possibly multiple disk drives.

The choice of which directories are placed into separate
partitions is both a personal and technical decision. Here are some
guidelines for individual partitions:

/
(the root directory)

Since the only filesystem mounted at the start of the boot
process is
/
, certain directories must be
part of it to be available for the boot process. These
include:

/bin
and
/sbin

Contains required system binary programs

/dev

Contains device files

/etc

Contains configuration information used on
boot

/lib

Contains shared libraries

These directories are always part of the single
/
partition. See the description of the FHS
in
Objective 7: Find System Files and Place Files in the Correct
Location
for more on the requirements for the root filesystem.

/boot

This directory holds static files used by the boot loader,
including kernel images. On systems where kernel development
activity occurs regularly, making
/boot
a
separate partition eliminates the possibility that
/
will fill with kernel images and
associated files during development.

/home

User files are usually placed in a separate partition.
This is often the largest partition on the system and may be
located on a separate physical disk or disk array.

/tmp

This directory is often a separate partition used to
prevent temporary files from filling the root filesystem. By
default, all users have read/write access to files they create
in
/tmp
.

/var

Logfiles are stored here. This is similar to the situation
with
/tmp
, where user files can fill any
available space if something goes wrong or if the files are not
cleaned periodically.

/usr

This directory holds a hierarchy of directories containing
user commands, source code, and documentation. It is often quite
large, making it a good candidate for its own partition. Because
much of the information stored under
/usr
is
static, some users prefer that it be mounted as read-only,
making it impossible to corrupt.

In addition to the preceding six partitions listed, a
swap
partition is also necessary
for a Linux system to enable virtual memory. For information on
determining the size of a swap partition, see
Chapter 5
.

Using these guidelines at installation time, the disk partitions
for an IDE-based system with two physical disks (40 GB and 200 GB) on
the primary IDE controller might look as described in
Table 7-1
.

Table 7-1. An example partitioning scheme

Partition

Type

Mounted filesystem

Size

/dev/hda1

Primary

/boot

1 GB

/dev/hda2

Primary

/

5 GB

/dev/hda3

Extended

-

-

/dev/hda5

Logical

/usr

10 GB

/dev/hda6

Logical

/var

10 GB

/dev/hda7

Logical

/opt

10 GB

/dev/hda8

Logical

/tmp

2 GB

/dev/hda4

Primary

(
swap
partition)

2 GB

/dev/hdb1

Primary

/home

200 GB

Once a disk is partitioned, it can be difficult or risky to
change the partition sizes. Commercial and open source tools are
available for this task, but a full backup is recommended prior to
their use.

Note

If you are
resizing your partitions, you may want to investigate
setting up your system using
Logical Volume Manager
(LVM). LVM
is currently not covered on the LPI exams, but its use is quickly
growing. For more information, read the
LVM-HOWTO at the Linux Documentation
Project
.

Other books

Rounding Third by Meyer, Walter G.
Breeding My Boss's Wife by Natalia Darque
Jane by April Lindner
The Infinite Air by Fiona Kidman
WrappedInThought by Viola Grace
Miss Marple and Mystery by Agatha Christie