Vous êtes sur la page 1sur 47

Linux+ Guide to Linux

Certification
Objectives
Identify the structure and types of device
files in the /dev directory
Understand common filesystem types and
their features
Mount and unmount filesystems to and from
the Linux directory tree
Create and manage filesystems on floppy
disks, CDs, DVDs, USB storage devices,
FireWire storage devices, and hard disk
partitions
Create and use ISO images


2
Objectives (continued)
O Use the LVM to create and manage
logical volumes
O Monitor free space on mounted
filesystems
O Check filesystems for errors
O Use hard disk quotas to limit user space
usage
3
The /dev Directory
Device file: file representing a system device
Typically found in /dev directory
Specifies how to transfer data to and from the
device
Character devices: transfer data to and from
system character by character
Block devices: transfer chunks or blocks of
data using physical memory as a buffer
Fast data transfer
Floppy disks, CD-ROMs, DVDs, USB flash
drives, hard disk drives
4
The /dev Directory
(continued)
O Major number: points to the devices
driver in the Linux kernel
O Minor number: indicates the particular
device
O Device file type (block or character), major
number, and minor number make up the
unique characteristics of a device file
5
The /dev Directory
(continued)
O mknod command: can be used to re-
create a corrupted device file
O Must know file type, major, and minor
numbers
O /dev/MAKEDEV command: can be used
to re-create a device file based on its
common name
O Useful if dont know some of the
information required for the mknod
command
6
Filesystems
O Filesystem: organization and
management imposed on physical storage
media
O Formatting: creating a filesystem on a
device
7
Mounting
Mounting: making a device accessible to
users via the logical directory tree
Mount point: directory to which a device
is attached
The mounted device temporarily covers up
the contents of the mount point
Any existing directory can be a mount
point
In order to prevent making files
inaccessible, create empty directories
used specifically for mounting devices

8
Mounting (continued)

9
Figure 5-1: The directory structure prior to mounting
Mounting (continued)
10
Figure 5-2: The directory structure after mounting a floppy
device
Mounting (continued)
Root filesystem: when Linux filesystem is
first turned on, a filesystem on the hard
drive is mounted to the / directory
Contains most OS files
mount command: used to mount devices
to mount point directories
When used with no options or arguments,
lists currently mounted filesystems
umount command: used to unmount
devices from mount point directories
11
Working with Floppy Disks
Disk devices must be prepared before use
Formatted with a filesystem
mkfs (make filesystem) command: Used to
format a disk device with a filesystem
t option: Specifies filesystem type
Default is ext2 filesystem
To mount or unmount floppies, must ensure that no
user is currently using the mount point directory
Use mount command with no options or arguments
to get list of currently mounted filesystems
Once mounted, use as any other directory
12
Working with Floppy Disks
(continued)
O mkfs -t ext3 /dev/hda1
O mke2fs
O mkfs.ext3
O mkfs.msdos
O mkfs.vfat
13
Table 5-3: Commands used to create filesystems
Working with Floppy Disks
(continued)
14
O <device to mount>
O <mount point>
O <type>

O <mount options>
O <dump#>
O <fsck#>

fuser command: With the u option, lists users
using a directory
/etc/fstab file: Used to mount devices at boot time
Also consulted when users do not specify enough
mount command arguments
Six fields:
Working with Floppy Disks
(continued)
O mount
O Mount <filesystem> <target>
O umount
O umount <target>
15
Table 5-4: Useful commands when
mounting and unmounting filesystems
Working with CDs, DVDs, and
ISO Images
Most software is packaged on CDs and
DVDs
Can be mounted using the mount
command and unmounted using umount
command
Different device file - depend on the
technology used by the drive itself.
For PATA drives, use one of the following:
Primary master (/dev/hda)
Primary slave (/dev/hdb)
Secondary master (/dev/hdc)
Secondary slave (/dev/hdd)
16
Working with CDs, DVDs, and
ISO Images (continued)
For SATA or SCSI drives, Linux may use
many different names, depending on the
actual CD or DVD drive
To make identification of CD/DVD drive
easier, Fedora Linux includes symbolic links
within the /dev directory:
/dev/cdrom symbolic link to first CD-ROM
drive
/dev/cdrw symbolic link to first CD-RW drive
/dev/dvd symbolic link to first DVD-ROM
drive
/dev/dvdrw symbolic link to first DVD-RW
drive
17
Working with CDs, DVDs, and
ISO Images (continued)
CDs and DVDs Typically use iso9660
filesystem type and are read only when
accessed using Linux
Mount with r (read-only) option
Cannot be ejected until properly unmounted
In GUI environment, CD or DVD
automatically mounted to a directory
underneath the /media directory
Named for the label on the CD or DVD
System places shortcut on desktop
18
Working with CDs, DVDs, and
ISO Images (continued)
Figure 5-3: Accessing a DVD within the GNOME desktop
environment
19
Working with CDs, DVDs, and
ISO Images (continued)
iso9660 filesystem can be used to create
ISO images that contain other files
Can be mounted as a loopback device
using the mount command
mkisofs command: Used to create ISO
image from directory
Receives at least two arguments:
Filename to be created
Directory used to create the ISO image
20
Working with Hard Disks
O Three types of hard disks: PATA, SATA,
and SCSI
O PATA HDDs must be configured in one of
the following:
O Primary master (/dev/hda)
O Primary slave (/dev/hdb)
O Secondary master (/dev/hdc)
O Secondary slave (/dev/hdd)
O Different device file for each
21
Working with Hard Disks
(continued)
SATA and SCSI hard disks are well-suited to
Linux servers
Faster access speed
Multiple hard drives can be attached to a
controller
Associated with different device files
First SCSI HDD (/dev/sda)
Second SCSI HDD (/dev/sdb)
Third SCSI HDD (/dev/sdc)
And so on
22
Standard Hard Disk
Partitioning
Partition: physical division of an HDD; can
have its own filesystem
Linux requires at least two partitions; root
and swap
Good practice to use more than two
partitions
Segregate different types of data
Allow for use of multiple filesystem types on
one HDD
Reduce chance that filesystem corruption will
render a system unusable
Speed up access to stored data
23
Standard Hard Disk
Partitioning (continued)
Track: area on a hard disk that forms a
concentric circle
Sector: portion of a track containing
information
Block: combination of sectors
Cylinder: series consisting of the same
concentric track on all of the metal platters
inside a HDD
Partition definitions stored in first readable
sector of the hard disk
Master Boot Record (MBR) or master boot
block (MBB)
24
Standard Hard Disk
Partitioning (continued)
25 Figure 5-4: The physical areas of a hard disk
Standard Hard Disk
Partitioning (continued)
26
Table 5-5: Common hard disk partition
device files for /dev/hda and /dev/sda
Standard Hard Disk
Partitioning (continued)
27
Table 5-5 (continued): Common hard disk
partition device files for /dev/hda and /dev/sda
Standard Hard Disk
Partitioning (continued)
28 Figure 5-5: A sample Linux partitioning strategy
Standard Hard Disk
Partitioning (continued)
29
Figure 5-6: A sample dual-boot Linux partitioning strategy
Working with Standard Hard
Disk Partitions
fdisk command: Create partitions after
installation
Specify hard disk partition as an argument
Variety of options for fdisk prompt to
achieve different tasks
cfdisk command: Interactive graphical
utility for creating, manipulating and deleting
partitions
Reboot computer after using the fdisk and
cfdisk commands to ensure proper
reloading into memory
30
Working with Standard Hard
Disk Partitions (continued)
Edit /etc/fstab file to allow system to mount
new filesystems automatically at boot time
mkswap command: Prepare the swap
partition
swapon command: Activate the swap
partition
swapoff command: Deactivate the swap
partition
Edit /etc/fstab file to ensure that new swap
partition is activated as virtual memory
31
Working with the LVM
Logical Volume Manager (LVM): Used to
create volumes
Volumes can contain filesystems and can be
mounted to directories
More flexible than standard partitions allows
use of free space across multiple hard disks
Has error correction abilities
LVM components: physical volumes (PVs),
volume group (VG), and logical volumes
(LVs)
32
Working with the LVM
(continued)
33
Working with the LVM
(continued)
pvcreate command: used to create PVs
pvdisplay command: used to display
detailed information about each PV
vgcreate command: used to create a VG
that uses the space in PVs
Arguments are name of the VG and PVs to be
used
Physical Extent: block size for saving data in
a VG
Should be set when creating a VG
Can use vgcreate -s to set the PE

34
Working with the LVM
(continued)
vgdisplay command: used to display
detailed information about each VG
lvcreate command: used to create LVs
from available space in a VG
lvdisplay command: used to display
information about each LV
Work with mount points of LVs as would
work with any other had disk partition device
file
Edit /etc/fstab to ensure that LVs are
automatically mounted at system startup

35
Working with the LVM
(continued)
O pvscan, vgscan, and lvscan
commands: Display information about
PVs, VGs, and LVs, respectively
O vgextend command: used to add a new
PV to an existing VG
O lvextend command: used to increase
the size of an LV, e.g., to use space
extended onto an existing VG
36
Working with USB and
FireWire-Based Storage
Devices
Most removable storage devices emulate
SCSI protocol in the firmware of the
device
Devices are automatically mounted to a
new directory under the /media directory
named for the label on the device
Easy to work with removable storage
devices using a GUI interface
If you want to use commands, must know
the device file and mount point directory
37
Monitoring Filesystems
O Check mounted filesystems periodically
O Errors
O Disk Space usage
O Inode usage
O Minimizes problems that due to damaged
filesystems
38
Disk Usage
Using more filesystems typically results in
less hard disk space per filesystem
Errors when filesystems fill up with data
Periodically remove obsolete files such as old
log files to make room for new ones
df (disk free space) command: Monitor free
space used by mounted filesystems
h option: More user friendly
To get information about different filesystems,
you must mount them prior to using df
command
39
Disk Usage (continued)
O du (directory usage) command: view size
of a directory and contents in Kilobytes
O s option: Summarizes output
O h option: More user friendly
O dumpe2fs command: view total number
of inodes and free inodes for ext2, ext3, or
ext4 filesystem
O Use h option

40
Checking Filesystems for
Errors
O Filesystem corruption: errors in filesystem
structure preventing retrieval of data
O Commonly occurs due to improper system
shutdown
O Syncing: process of writing data stored in
RAM to the HDD
O Bad blocks: unusable areas of a disk
O Cannot hold a magnetic charge

41
Checking Filesystems for
Errors (continued)
fsck (filesystem check) command: check a
filesystem for errors
Filesystem must be unmounted
f option used to perform full check
e2fsck command: Check ext2, ext3, and
ext4 filesystems
-c option checks for bad blocks
tune2fs command: Used to change
filesystem parameters
-i option sets interval to forcing full system
check
42
Checking Filesystems for
Errors (continued)
43
Table 5-6: Common options to the fsck command
Hard Disk Quotas
O If several users on a system, must be
enough hard disk space for each users
files
O Hard disk quotas: user limits on filesystem
usage
O Restrict number of files/directories or total
disk space usage
O Soft limit: user may exceed quota briefly
O Hard limit: limit cannot be exceeded
44
Hard Disk Quotas (continued)
O quotaon and quotaoff commands:
toggle quotas on and off
O edquota command: edit user quotas
O repquota command: report user quotas
O quota command: allows regular users to
view their own quotas and current usage

45
Summary
Disk devices are represented by device files
that reside in the /dev directory
Each disk drive must contain a filesystem,
which is then mounted to the Linux directory
tree for usage using the mount command
Hard disks must be partitioned into distinct
sections before filesystems are created on
those partitions
Many different filesystems available to Linux

46
Summary (continued)
The LVM can be used to create logical
volumes from the free space within multiple
partitions
USB and FireWire storage devices are
recognized as SCSI disks by the Linux
system
Important to monitor disk usage using the
df, du, and dumpe2fs commands to avoid
running out of storage space
If hard disk space is limited, you can use
hard disk quotas to limit the space that each
user has on filesystems
47

Vous aimerez peut-être aussi