Chapter 5 Study Guide
/Dev directoy
The /dev directory contains the special device files that control access all the devices. Two main types of devices under all systems:
Character devices
Data transfers character by character to and from the device.
Block devices
Transfers chunks or blocks of information at a time by using physical memory to buffer the transfer
To view the type of the file use the following command
ls -l/dev/dsk
Major and minor numbers are associated with the device special files in the /dev directory and are used by the operating system to determine the actual driver and device to be accessed by the user-level request for the special device file.
The major number identifies the device class or group, such as a controller for several terminals. The major number is assigned, sequentially, to each device driver by the Installable Driver Tools during driver installation.
The minor number identifies a specific device, such as a single terminal. Minor numbers are assigned to special files by the driver writer in another system configuration file called the Node file.
Filesystems
Filesystem: The organization imposed on a physical storage medium that is used to manage the storage, store, retrieve, and update data on device. All filesystems have three common components: the superblock, the inode table, and the data blocks. Together they organize files and allow rapid access to and retrieval of data.
Filesystems used by most linux distributions:
Extended Filesystem - ext (Linux)
Second Extended Filesystem - ext2 (Linux)
Third Extended Filesystem - ext3 (Linux, journalling)
Reiser Filesystem - reiserfs (Linux, journalling)
IS0 9660 Filesystem - iso9660 (CD-ROM)
Minix Filesystem - Minix (Minix. first filesystem used by Linux)
FAT 16 bit - msdos (DOS, Windows)
Virtual Fat Fielsystem - vfat (DOS, Windows) Supports long filenames
Network Filesystem - NFS
Uniform Filesystem - ufs ( BSD, Solarius, NeXTStep)
UMSDOS Filesystem - umsdos (Unix filesystem on DOS)
jfs (Linux, journalling)
ntfs - Used by Windows
Mounting
Mounting the process used to associate a device with a directory in the logical directory tree such that users can store data on that devices.
A mount point is a physical location or a directory in the partition used as a root filesystem.
Floppies
Used to transfer small amounts of information from computer to computer in the past Not available on all systems today Each disk must be formatted with a filesystem prior to being used to store files After formatting then you must mount it on the directory tree before it can be used
Use the mkfs (make file system) command to format the floppy disk Specify the filesystem type with a –t switch Specify a different file system name after the –t option such as the DOS FAT filesystem:
mkfs –t msdos /dev/fd0
If you don’t specify the filesystem then the default assumed is the ext2 file system: mkfs /dev/fd0
To mount a device on the directory tree use the mount command with options to specify the filesystem type to mount the directory.
For example:
fuser -u /media/floppy
To unmount use the following command: unmount /media/floppy
CDs and DVDs
Can be mounted with mount and unmounted with umount commands. Device files used by these drives are different than Floppies
Standard Configurations:
Primary master (dev/had) Primary slave (dev/hdb) Secondary master (dev/hdc) Secondary slave (dev/hdd)
If you have SATA or SCSI drive then Linux uses different names
First SATA/SCSI drive (/dev/sda, /dev/scd0, /dev/sr0, and /devsg0) Second SATA/SCSI drive ( /dev/sdb, /dev/scd1, /dev/sr1, and /dev/sg1) Third SATA/SCSI drive ( /dev/sdc, /dev/scd2, /dev/sr2, and /dev/sg2
Symbolic Links
/dev/cdrom- 1st CD-ROM drive /dev/cdrw 1st CD-RW drive /dev/dvd 1st DVD-ROM drive /dev/dvdrw 1st DVD-RW drive
ISO 9660 File System
CDs, and DVDs, use this filesystem type.
Are read-only when accessed using a Linux
You must use a disk-burning software to record to a CD, or DVD.
To mount a CD or DVD to a directory use this filesystem type and add the –r (read only) option to the command
For example:
mount –r –t iso9660 /dev/cdrom /media/cd
Not limited to CDs, and DVDs.
You can also create ISOs.
To create an ISO image from a directory of files use the mkisofs command.
For example:
mkisofs –RJ –o newimage.iso/data mount –o loop –t iso9660 newimage.iso /mnt
Hard Disks
3 Flavors of Hard Disks: PATA, SATA, SCSI
PATA
Primary master (/dev/hda)
Primary slave (/dev/hdb)
Secondary master (/dev/hdc)
Secondary slave (/dev/hdd)
SATA/SCSI
/dev/sda
/dev/sdb
/dev/sdc
Etc.
Each partition can contain separate filesystems
Can be mounted to different mount point directories
Linux always requires two partitions
One for the root and One for the swap (virtual memory)
Partitions decrease the likely hood of corruption in the file system
Partitions are definitions stored in the first readable sector, known as the Master Boot Record (MBR)
Large drisks > 2TB use a GUID Partition Table (GPT) to allow for additional addressing of the sectors
Hard Disks can only contain up to four primary partitions but you can created extended partitions to overcome this.Extended partitions can then contain many more subpartitions called logical drives.Partitions can be created specific to a certain file system. You can create partitions at installation using the graphical installation program or you can create partitions after the install using the fdisk command.
fdisk Options
Some of the more common options for fdisk.
-h, --help
displays a help message.
-v, --version
displays the program’s version.
-L, --linux-fdisk
turns on Linux fdisk compatibility mode. This is the same as running lfdisk.
-G, --gnu-fdisk
turns off Linux fdisk compatibility mode.
-i, --interactive
where necessary, prompts for user intervention.
-p, --script
never prompts for user intervention.
-l, --list
lists the partition table on the specified device and exits. If there is no device specified, lists the partition tables on all detected devices.
-r, --raw-list
displays a hex dump of the partition table of the disk, similar to the way Linux fdisk displays the raw data in the partition table.
-u, --sector-units
use sectors, instead of cylinders for a default unit.
-s, --size=DEVICE
prints the size of the partition on DEVICE is printed on the standard output.
-t, --list-partition-types
displays a list of supported partition types and features.
cfdisk will give you the GUI based fdisk program.
Reboot to save changes to the MBR or GPT.
After reboot, you can use the mkfs, mount, and unmount commands specifying the partition device file as an argument
Swap partitions must be prepared to swap partitions and activate them for use on Linux.
Use the mkswap command to prepare the swap partition.
Use the swapon command to activate it.
Use Logical Volume Manager (LVM) to create volumes
Volumes can contain filesystems and mounted to directories within the Linux filesystem hierarchy
More flexible than using partitions
You can use free space from any partitions on any hard disks to create the volume
Additional hard disks can easily be added to the LVM
LVM components:
Physical Volumes (PVs) Unused partitions LVM uses to store info
A Volume Group (VG) Contains one or more PVs. Represents the pool of hard disk storage space that is available to the LVM for creating logical volumes
Logical Volumes (LVs) The usable volumes created by the LVM from the storage within a VG. LVs contain a filesystem and are mounted to a directory in the hierarchy. LVs can be resized easily by the LVM to use more or less storage space.
LVM Commands
pvcreate /dev/sda4 pvdisplay vgcreate vg00 /dev/sda4 vgdisplay lvcreate –L 15GB –n data vg00 lvdisplay
You then work with these files you created as you would any other partition device file.
USB and Fireware based storage
Used because of their large capacity and portability. Devices which typically connect to your PC via high speed USB or Firewire cables are: flash memory drives, external hard drives, digital cameras (that contain flash memory cards), media players.
Monitoring Filesystems
Keep at least 10% of the “/” filesystem free otherwise performance can suffer.
/usr should have enough free space for the software you want installed.
/var grows with log files so delete old logs.
/usr grows with what you save there.
Easiest method to monitor free space is to use the df (Disk free) command.
df –h
displays in an easier to read format showing in gigs or megabytes.
df only views mounted filesystems so mount them prior to using df.
If you are running out of space you can use the du command to see directory sizes.
du can be used with | more or less
du -s
will show in a summary format
du -h
will show in gigs and megabytes like df
Filesystem corruption happens on all OS’s
The most common corruption occurs when shutting down a computer and the memory gets saved to the hard drive (known as syncing). Some areas of a hard drive can go bad and not be readable by the system.
To check for errors use the fsck command (filesystem check). If you do not specify a filesystem type it will try to automatically detect one.
The filesystem must be UNmounted before you can check it
fsck –a or –y
to automatically fix errors
fsck –C
displays a progress line
fsck –f
to perform a full scan, if you do not it will be a quick scan
Hard Disk Quotas
If you have a lot of users you might want to limit the amount of disk space they can use Two types of quotas:
Soft Quotas: Users can go over their quota for a period of time
Hard Quotas: Cannot be passed.
quotaon
turns it on
-a for all mounted filesystems
-u or –g for users and groups
quotaoff
turns it off
-u or –g as above
-a ends all quotas
edquota
to edit a quota that exists
repquota
displays quota report
Sources: Supported File Systems