320 likes | 399 Views
Chapter 9 Part III Linux File System Administration. Disk devices are represented by device files that reside in the /dev directory Device file – a file used by Linux commands that represent a specific device on the system
E N D
Chapter 9 Part III Linux File System Administration Disk devices are represented by device files that reside in the /dev directory Device file – a file used by Linux commands that represent a specific device on the system Character devices - Transfer data to and from the system one character or data bit at a time Block devices • Storage devices that transfer to and from the system in chunks of many bits by caching the information in RAM • Can transfer information must faster than character devices?
The /dev Directory List 1st floppy & 1st SCSI tape device $ ls –l /dev/fd0 /dev/tst0 brw-rw---- 1 root floppy 2, 0 Aug 30 2001 /dev/fd0 crw-rw---- 1 root disk 9, 0 Apr 4 2001 /dev/st0 Major number floppy 2, scsi tape 9 • Used by the kernel to identify what device driver to call to interact properly with a given category of hardware Minor number 0 on both • Used by the kernel to identify which specific device, within a given category, to use a driver to communicate with • The b indicates block devices • The c indicates character devices
The /dev Directory Table 6-1 (continued): Common device files
Filesystems Filesystem • The organization imposed on a physical storage medium that is used to manage the storage and retrieval of data Formatting • The process where a filesystem is placed on a disk drive Create the ext2 format file system on floppy device 0 $ mkfs –t ext2 /dev/fd0 or $ mkfs /dev/fd0 (ext2 is default filesystem for mkfs) To list devices currently used on the system. $ cat /proc/devices
Working with Floppy Disks • Floppy disks must be prepared before they are used in Linux • Each disk device must be formatted with a filesystem prior to being used to store files Table 6-3: Commands used to create filesystems Table 6-3: Commands used to create filesystems
Filesystem Types Table 6-2: Common Linux filesystems
Filesystem Types Table 6-2 (continued): Common Linux filesystems
Mounting Mounting • Process used to associate a device with a directory in the logical directory tree such that users may store data on that device Mount point • Directory in a file structure to which something is mounted Mount floppy to default mount point (directory) $ mount /dev/fd0 Mount floppy to specified mount point (directory) $ mount /dev/fd0 /flopper
Working with Floppy Disks Table 6-4:Commands useful when mounting and unmounting filesystems
Mounting Figure 6-1: The directory structure prior to mounting
Mounting Figure 6-2: The directory structure after mounting a floppy device
Mounting • When the Linux filesystem is first turned on, a filesystem present on the hard drive is mounted to the / directory • Root filesystem • Filesystem that contains the most files that make up the operating system • Should have enough free space to prevent errors and slow performance
Working with Floppy Disks Figure 6-6: Viewing the contents of a CD-ROM in a GUI environment
Working with Floppy Disks Figure 6-7: Unmounting a CD-ROM device in a GUI environment
Working with CD-ROMs • Linux systems have an ATAPI compliant IDE CD-ROM drive that attaches to the mainboard via an IDE ribbon cable • These CD-ROMs act as a normal IDE hard disk, and must be configured on of the four configurations below, as seen with their associated device files: • Primary master (/dev/hda) • Primary slave (/dev/hdb) • Secondary master (/dev/hdc) • Secondary slave (/dev/hdd)
Working with Hard Disks • IDE hard disk drives attach to the mainboard with an IDE cable and must be configured on one of four configurations, each of which has a different device file: • Primary master (/dev/hda) • Primary slave (/dev/hdb) • Secondary master (/dev/hdc) • Secondary slave (/dev/hdd)
Working with Hard Disks • SCSI hard disks are well-suited to Linux servers that require a great deal of storage space for programs and user files • Different device files associated with SCSI hard disks: • First SCSI hard disk drive (/dev/sda) • Second SCSI hard disk drive (/dev/sdb) • Third SCSI hard disk drive (/dev/sdc)
Working with Hard Disks • Different device files associated with SCSI hard disks (continued): • Fourth SCSI hard disk drive (/dev/sdd) • Fifth SCSI hard disk drive (/dev/sde) • Sixth SCSI hard disk drive (/dev/sdf) • And so on
Hard Disk Partitioning • Recall that hard disks have the largest storage capacity of any device used to store information on a regular basis • This poses some problems, because as the size of a disk increases, organization becomes more difficult and the chance of error increases • Partition • A physical division of a hard disk drive
Hard Disk Partitioning • It is good practice to use more than just two partitions on Linux system as this division can be useful to: • Segregate different types of data • Allow for the use of more than one type of filesystem on one hard disk drive • Reduce the chance the filesystem corruption will render a system unusable • Speed up access to stored data by keeping filesystems as small as possible
Hard Disk Partitioning • Tracks • Area on a hard disk that form a concentric circle of sectors • Sector • Smallest unit of data storage on a hard disk • Block • Unit of data commonly used by filesystem commands
Hard Disk Partitioning • Cylinder • Series of tracks on a hard disk that are written to simultaneously by the magnetic heads in a hard disk drive Figure 6-8: The physical areas of a hard disk
Hard Disk Partitioning Table 6-5:Common hard disk partition device files for /dev/had and /dev/sda
Hard Disk Partitioning Figure 6-9: A sample Linux partitioning strategy
Hard Disk Partitioning Figure 6-10: A sample dual-boot Linux partitioning strategy
Working with Hard Disk Partitions • Disk Druid is an easy-to-use partitioning tool used with Red Hat Linux, specifically designed for installation only • To create partitions after installations, you use the fdisk command • To use the fdisk command, you simply specify the hard disk partition as an argument
Disk Usage • There may be several filesystems mounted to the directory tree • The more filesystems that are used, the less likely it is that a corrupted filesystem may interfere with normal system operations • Conversely, using more filesystems typically results in less hard disk space per filesystem and may result in system errors if certain filesystems fill up with data • The easiest method for monitoring free space by mounted filesystem is to use the df (disk free space) command
Checking Filesystems for Errors • Filesystem corruption • Errors in a filesystem structure that prevent the retrieval of stored data • Syncing • Process of writing data to the hard disk drive that was stored in RAM • Bad blocks • Those areas of a storage medium used by filesystem commands
Checking Filesystems for Errors Table 6-6: Common options to the fsck command
Hard Disk Quotas • Soft limits • Limit imposed that can be exceeded for a certain period of time • Hard limit • Limit imposed that cannot be exceeded
Chapter 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
Chapter Summary • There are many different filesystems available to Linux • It is 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