Chapter 5: Linux Filesystem Administration
Hard limit
limit cannot be exceeded
fuser -u command
lists users using a directory
repquota command
report user quotas
quotaon and quotaoff commands
toggle quotas on and off
Bad blocks
unusable areas of a disk (cannot hold a magnetic charge)
vgextend command
used to add a new PV to an existing VG
mkisofs command
used to create ISO image from a directory of files takes at least 2 arguments: - filename to be created - directory used to create the ISO image
lvcreate command
used to create LVs from available space in VG
vgcreate command
used to create a VG that uses the space in PVs arguments are name of the VG and PVs to be used
pvdisplay command
used to display detailed information about each PV
vgdisplay command
used to display detailed information about each vg
lvdisplay command
used to display information about each LV
lvextend
used to increase the size of an LV i.e., to use space extended onto an existing VG
/etc/fstab file
used to mount devices at boot time also consulted when users do not specify enough mount command arguments 6 fields: - device to mount - mount point - type - mount options - dump# - fsck#
mount command
used to mount devices to mount point directories when used with no options or arguments, lists currently mounted filesystems
mknod command
used to re-create a corrupted device file Must know file type, major, and minor numbers
umount command
used to unmount devices from mount point directories
Hard disk quotas
user limits on filesystem usage Quotas can restrict number of files/directories or total disk space usage
Root filesystem
when the Linux system is first turned on, a filesystem on the hard drive is mounted to the / directory (contains most OS files)
/run/media/username directory
In GUI environment, CD or DVD automatically mounted to a directory underneath the /run/media/username directory Named for the label on the CD or DVD System places shortcut within the GUI environment
cfdisk command
Interactive graphical utility for creating, manipulating and deleting partitions Reboot computer after using the command to ensure proper reloading into memory
Master Boot Record (MBR) or Master Boot Block (MBB)
Partition definitions stored in the first readable sector of the hard disk
Partition
Physical division of an HDD; can have its own filesystem
mkswap command
Prepare the swap partition
Syncing
Process of writing data stored in RAM to the HDD
yum install quota command
Quota support is not installed on Fedora 20 by default
iso9660 filesystem
Typically used by CDs and DVDs and are read-only when accessed using Linux mount with -r (read only) option cannot be ejected until properly unmounted can be used to create ISO images that contain other files can be mounted as a loopback device using the mount command
Physical Volumes
Unused partitions on hard disks that the LVM can use to store information
Logical Volumes (LVs)
Usable volumes that are created by the LVM from the available storage space within a VG You work with mount points of LVs as you would work with any other had disk partition device file Edit /etc/fstab to ensure that LVs are automatically mounted at system startup
tune2fs command
Used to change filesystem parameters -i option sets interval to forcing full system check
parted (GNU Parted) command
Used to create and modify partitions on both MBR and GPT hard disks
pvcreate command
Used to create physical volumes (PV)
Logical Volume Manager (LVM)
Used to create volumes
mkfs (make filesystem) command
Used to format a disk device with a filesystem -t option specifies filesystem type default is ext2
Soft limit
User may exceed quota briefly For a certain period of time (seven days by default)
Disk usage
Using more filesystems typically results in less hard disk space per filesystem May result in errors when filesystems fill up with data Periodically remove obsolete files such as old log files to make room for new ones
du (directory usage) command
View size of a directory and contents in kilobytes -s option: summarizes output - h option more user friendly format
dumpe2fs command
View total number of inodes and free inodes for an ext2, ext3, or ext4 filesystem - h option: more user friendly format
GUID Partition Table (GPT)
You can't use the fdisk or cfdisk commands to create and modify partitions before you format them with a filesystem or prepare them for use as swap memory
Major number
a number in a device file that points to the device's driver in the Linux kernel Several different devices can share the same major number if they are of the same general type
quota command
allows regular users to view their own quotas and current usage
Swap partitions
do not contain a filesystem, you must still prepare and activate them for Linux
edquota command
edit user quotas
Filesystem corruption
errors in filesystem structure preventing retrieval of data Commonly occurs due to improper system shutdown
Filesystems
formatting: creating a filesystem on a device All storage media need to contain a filesystem before they can be used
Minor number
indicates the particular device
GPT partitions support filesystem commands
- Format partitions with a filesystem using mkfs command - Mount them to the directory tree with the mount command - Update the /etc/fstab file to mount them automatically
Device File
A file representing a system device One file per device, typically found in the /dev directory Specifies how to transfer data to and from the device
3 types of hard disks:
- PATA - SATA - SCSI SATA & SCSU are well-suited to Linux servers - Faster access speed - Multiple hard drives can be attached to a controller
LVM components
- Physical Volumes (PVs) - Volume Groups (VGs) - Logical volumes (LVs)
PATA HDD
- Primary Master /dev/hda - Primary Slave /dev/hdb - Secondary Master /dev/hdc - Secondary Slave /dev/hdd different device file for each
For PATA drives
- Primary master /dev/hda - Primary slave /dev/hdb - Secondary master /dev/hdc - Secondary slave /dev/hdd
swapon command
Activate the swap partition Edit /etc/fstab file to ensure that new swap partition is activated as virtual memory
Physical Extent (PE) size
Block size for saving data in a VG - Should be set when creating a VG - Can use vgcreate -s to set the PE
Working with CDs, DVDs and ISO images
Can be mounted with mount command and unmounted with umount Different device file, depends on the technology used by the drive itself
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
e2fsck command
Check an ext2, ext3, or ext4 filesystem -c option checks for bad blocks
Monitoring Filesystems
Check mounted filesystems periodically for: - Errors - Disk space usage - Inode usage Minimizes problems that can occur as a result of a damaged filesystem Reduces the likelihood that a file cannot be saved due to insufficient disk space
Unique characteristics of a device file
Consists of the device file type (block or character), major number, and minor number
Volume Groups
Contain one or more physical volumes (PVs)
gdisk command
Create and work with partitions on GPT hard disk
swapoff command
Deactivate the swap partition
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 Create empty directories used specifically for mounting devices to prevent making files inaccessible
pvscan, vgscan, lvscan commands
Display information about PVs, VGs, and LVs, respectively
Mounting new filesystems automatically at boot time
Edit /etc/fstab file to allow system to mount new filesystems automatically at boot time
SCSI
First SCSI HDD (/dev/sda) Second SCSI HDD (/dev/sdb) Third SCSI HDD (/dev/sdc)
Advantages of multiple partitions
It is 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
For SATA or SCSI drives
Linux may use many or different names, depending on the actual CD or DVD drive To make identification of CD/DVD driver easier, Fedora Linux creates a file called /dev/cdrom (a symbolic link to the correct device file for your first CD or DVD drive)
Minimum required partitions
Linux requires at least 2 partitions: - root - swap
df (disk free space) command
Monitor free space used by mounted filesystems -h option: to view a more user friendly format To get information about different filesystems, you must mount them prior to using df command
SSD
Most SSDs are SATA and are treated like a SATA hard disk by Linux /dev/sda could refer to the first SATA hard disk or the first SATA SSD
Removable Storage
Most removable storage devices emulate SCSI protocol int he 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, you must know the device file and mount point directory
Block devices
Transfer chunks or blocks of data using physical memory to buffer the transfer Faster data transfer than character devices i.e., Floppy disks, CD-ROMS, DVDs, USB flash drives, hard disk drives
Character devices
Transfer data character-by-character to and from the device
View list of devices that are currently used on the system and their major numbers
cat /proc/devices
fsck command
check a filesystem for errors Filesystem must be unmounted -f option used to perform full check -a or -y automatically repair any errors
fdisk command
create partitions after installation - Specify hard disk partition as an argument - Variety of options for fdisk prompt to achieve different tasks Reboot computer after using the command to ensure proper reloading into memory
Mounting
making a device accessible to users via the logical directory tree