Version User Scope of changes
Apr 17 2008, 10:00 AM EDT (current) Dr.Disk 8 words added, 2 words deleted, 1 photo added
Apr 17 2008, 9:54 AM EDT Dr.Disk 215 words added, 3 photos added

Changes

Key:  Additions   Deletions

Section 3: The Linux Filesystem - Certification CentralTarget Goals

  • Navigate the filesystem
  • Manage the filesystem
  • Maintain the filesystem

Section 3: The Linux Filesystem - Certification CentralNavigating in the Linux Shell

Basic Commands


Command What It Does
ls lists files and directories
cd moves through directory structure
mv moves files and directories
cp copies a file
rm Deletes files and directories
touch changes access or modification to a file
mkdir creates directories

All objects in Linux are seen as files

The root directory is represented by a /
You are placed in your home directory by default
The current working directory is represented by a period
The parent directory is represented by a double-period

Changing Directories using CD
  • CD alone returns to home directory
  • CD [pathname] takes you to specified path
  • CD ~ [pathname] takes you to the directory relative to home directory

Viewing Directory Contents

You can use dir or ls to view directory contents

Common Uses of LS (use man ls to see more extensive listing of options)
ls -Flists directories with a slash to end directory name
ls -Rprovides long-format listing
ls -lRecursively list subdirectories
ls -ld
Povides long directory listing of directory but not contents
ls -laPrints out regular and hidden files in the directory

Wildcards
MetacharacterAction
*Matches any or no character
?Matches single character
Set [ ]Matches single character
Range [ - ]Matches any single charcter in defined range

Section 3: The Linux Filesystem - Certification CentralManaging Files and Directories

Section 3: The Linux Filesystem - Certification Central
The default Linux filesystem is ext3
  • ext3 is built on the traditional ext2 (which provided fast access as well as rapid read and write times-but lacked journaling feature - records disk activity to speed recovery from improper shutdown)
  • reiserfs - Treats partition as one database, a balanced tree is used to store directories, files and metadata (which are stored near each other for rapid access)

Filesystem Info
All filesystems must be mounted before they are available using syntax: [device] [mountpoint]
The mount command attaches the filesystem on various devices to a single tree

Various paths to devices:
/dev/hda - 1st hard drive
/dev/hda1 - 1st partition on 1st hard drive
/dev/fd0 - 1st floppy
/dev/sd -1st SCSI disk
/dev/st - 1st SCSI tape drive
/dev/console - monitor
/dev/tty - other consoles

mount without options will display the device, mount point, type and whether it is read-write or read-only.
unmount is used to unmount volumes (if you are using a directory on a mounted file system you cannot unmount it)


Mounting DOS
mount -t msdos Create a directory in /mnt for each device you will mount

nvram lets you view and change values stored in non-volatile memory (requires 2.1x kernel with /dev/nram support)

Section 3: The Linux Filesystem - Certification CentralTo burn a CD on a mounted CD-R create a directory for the files and make an ISO image of the files using mkisofs and burn the CD using cdrecord

Automated mounting
use /etc/fstab to list file systems to be mounted during boot and unmounted at shutdown, it is automatically created or updated.

Directory Creation
mkdir [dirname] - command for creating directories. The dirname can include a path to another location. You may include multiple dirnames in one command to create multiple directories.

Section 3: The Linux Filesystem - Certification CentralFilesystem maintenance
FSCK - no I didn't just swear!

System performance is improved because disk writes aren't executed until required. Multiple read requests to the same block are served by RAM. An update utility consistentantly flushes the dirty buffers to disk to help prevent damage to data in the event of system disruption.

shutdown - synchronizes synchronizes disk buffers and cleanly exits any running process

fsck is used to check and repair the filesystem integrity. If no problems occur the number of files, blocks used and blocks free are listed. If problems occur the system prompts for correctve actions.

FSCK codes
CodeValue
0No errors
1 Filesystem errors found and corrected
2 You should reboot the system
4Errors found, but corrected
8Opperational error
16Usage/syntax error
128Shared library error

fsck -r /dev/ [filesystem] - interactively repairs the the [filesystem] isinidcated.
Section 3: The Linux Filesystem - Certification CentralOnly therepair one filesystem at a time.
Journaling
Metadata includes: file creation date; last file modification date; ownership (group and user), permissions, file size, file location

Journaling helps maintain integrity of system if file is being written during a crash.

Before making a file change journaling makes note of the intended change. Once the change is made, amn entry is made indicating if the change was successful.

So....
If the system crashes before a journal entry is made the original data is intact but any changes may be lost.
If the crash occurs during a disk write, the journal entry remains to indicate impending change so that upon successful reboot the entry is read and either the change is executed or rolled back to a previous state

Performance Issues
  • recovery time after failure
  • bitmap tracking of the filesystem
  • fragmentation

Section 3: The Linux Filesystem - Certification CentralJournaling uses disk space efficiently by allowing data to be read and written faster for a variety of file sizes via dynamic space allocation.

Section 3: The Linux Filesystem - Certification Central2 common filesystems are ext3 and reiserfs

fdformat - performs a low-level format

setfdprm - sets the device type eliminating the need to specify device capacity when formatting disk

The Return of MKFS
mkfs - used to create the filesytem

Filesystems
TypeDefinition
ext2extended and most common LInux filesystem
ext3updated ext3
romfsramdisk read only filesystem
NFSNetwork File System - used to acces remote files on network
msdosDOS-FAT filesystem

Section 3: The Linux Filesystem - Certification CentralCreating any filesystem also creates a lost+found directory. When system crashes or improper shutdown occurs files and directories without a directory entry are reattached to the inode table and placed in lost+found upon reboot.