1 / 35

RH030 Linux Computing Essentials

RH030 Linux Computing Essentials. Workbook 5 - Part 1 The Linux Filesystem. Objectives chapters 1 - 4. How the linux filesystem structure works Superblock, dentries, inodes, data blocks Linking items in the FSH Link-count Understanding the types of items found in the filesystem

luann
Download Presentation

RH030 Linux Computing Essentials

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RH030 Linux Computing Essentials Workbook 5 - Part 1 The Linux Filesystem

  2. Objectives chapters 1 - 4 • How the linux filesystem structure works • Superblock, dentries, inodes, data blocks • Linking items in the FSH • Link-count • Understanding the types of items found in the filesystem • We already understand • regular files, directories, and symbolic links. • Now we look at /dev: • block and character device nodes. • Attaching items to the FSH • Permanent storage devices • Temporary storage devices Linux+ Guide to Linux Certification, 2e

  3. Command Covered • ls – l - i -s -lt • ln – s • stat • mount • umount • mkfs • df Linux+ Guide to Linux Certification, 2e

  4. First how do you do use ‘c’ to clear the screen ? • alias command: • Has 2 uses: • Used to create shortcut of commands • alias c=clear • List all existing alias’s • alias • unalias command: • Used to remove an existing alias • Needs to be put into the ~/.bashrc to be permanent Linux+ Guide to Linux Certification, 2e

  5. Structure’s of linux filesystem • FSH - main structural sections: • Superblock: Contains general information about the filesystem • Namely the file's user owner, group owner, and permissions • Also the number of inodes and data blocks • Dentry: • Filenames are kept in directory entry data structures called “dentries” • These are associated with an inode. • Inode: • Inode table: Consists of several inodes • Contains the metadata about the item which is the actual attributes or properties of the item. Such as file size, data block locations. • Various times are stored the last time a file was accessed (read), changed, or modified, respectively - atime ctime mtime • Data blocks: Data making up the actual contents of the file • The data is the content of the file Linux+ Guide to Linux Certification, 2e

  6. Working with inodes & files • Each inode has a unique number. • ls –i • Each inode contains a link count. • ls –l • The inode records a file's link count, or the number of dentries (filenames) that refer to the file. • When listing files with ls -l, the second column gives the link count. • Usually, regular files only have one name, and the link count as one. • As we will find out, however, this is not always the case. • Other ls options • To see the size of a filels –s • To sort it into time of last modified (mtime) ls –lt Linux+ Guide to Linux Certification, 2e

  7. stat command • Used to examine the inode information of a file or directory in detail stat [options] itemname • To see the filesystem information instead of the file use: stat -f itemname Linux+ Guide to Linux Certification, 2e

  8. ln command works with inodes • ln <sourcefile> <linkname> • Used for linking items in the FSH • Requires Two arguments: • Source file and a Target file to create as a link to existing file • Files can be created as pointers to another file • Similar to a Microsoft shortcut • Or as a linked duplicate of another file. • There are 2 types of links : symbolic or hard links • Symbolic link: pointer to source file ( shortcut) • Hard link: duplicate of source file Linux+ Guide to Linux Certification, 2e

  9. Hard linked file - duplicate • ln ~/project-file linked-projectfile • ls -i • Two files share the same physical inode & data • Hard linked files share the same inode • Must be in the same filesystem • Directories may not be hard linked The structure of hard linked files Linux+ Guide to Linux Certification, 2e

  10. Symbolic Link - pointer • ln -s /etc/passwd linked-passwd • Use -soption to create symbolic link • Is just is a shortcut to another item • Sometimes called a soft link. • This type can to be used across filesystems • Each entry has it’s own inode entry. • Can be linked to directories The structure of symbolically linked files Linux+ Guide to Linux Certification, 2e

  11. Hard Links verse Soft Links • Hard Links • Create’s a duplicate item which shares the same inode number • Directories may not be hard linked. • Hard links must refer to files in the same filesystem. • Hard links have no concept of "original" and "copy". • Once a hard link has been created, all instances are treated equally. • Symbolic or Soft Links • Create’s a pointer item which has a different inode number • Soft links may refer to directories. • Soft links may span filesystems (partitions). • Soft links have a concept of "referrer" and "referred". • Removing the "referred" file results in a dangling referrer. Linux+ Guide to Linux Certification, 2e

  12. How Linux Identifies Device’s • All physical devices on a linux system are represented by a file on the hardrive called a Device Node: • The system uses this Device Node to refer to the physical device. • One file per device – typically found in /dev directory. • Use’s a /dev pathname to refer to each device nodes • These pathname is used to refer to specific devices in the filesystem • pathname = /dev/<device node/file> • Naming device files • Can be just ASCII letters • But commonly use a combination of letters and numbers • Letters = type of physical device • Numbers = unique identification for this specific type of device. Examples = /dev/tty2 /dev/cdrom /dev/hda1 Linux+ Guide to Linux Certification, 2e

  13. Each partition is associated with a different device node. • IDE HDDs are configured in one of the following: • Primary master (/dev/hda) • Primary slave (/dev/hdb) • Secondary master (/dev/hdc) • Secondary slave (/dev/hdd) • SCSI hard disks are configured in one of the following: • First SCSI HDD (/dev/sda) • Second SCSI HDD (/dev/sdb) • Third SCSI HDD (/dev/sdc) • And so on Linux+ Guide to Linux Certification, 2e

  14. OK - /dev holds Device Nodes • But what do they do? • A device node specifies how data is transferred to/from the device. • The job of a device node is to act as a conduit to a particular device driver within the kernel. • When a user writes to a device node, the device node transfers the information to the appropriate device driver in the kernel. • When a user would like to collect information from a particular device, they read from that device's associated device node, just as reading from a file. Linux+ Guide to Linux Certification, 2e

  15. Types of Device Nodes • There are 2 types of Device Files: Block or Character • c = Character devices: • Transfer’s data to and from system character by character • b = Block devices: • Transfer chunks or blocks of data • CD-ROM, HDD, floppy disks • This is identified by the first character infront of the permissions. ls –l /dev/fd0 $ brw-r--r-- 1 root root 2, 0 Feb 23 16:02 /dev/fd0 Linux+ Guide to Linux Certification, 2e

  16. Character Device Files in /dev Directory Table 6-1 (continued): Common device files Linux+ Guide to Linux Certification, 2e

  17. Block Device Files in the /dev Directory • Disk devices are represented by device files that reside in /dev Table 6-1: Common device files Linux+ Guide to Linux Certification, 2e

  18. Quick Device Node exercise • ps • who • ps –u sheila_a • Lets assume Sheila is on puseudo terminal pts/874 • And Sheila_a is on puseudo terminal pts/875 cal > /dev/pts/875 • As chapter 3 does not have an online exercise. • Do this exercise for yourself. Linux+ Guide to Linux Certification, 2e

  19. Storage devices • For access storage devices attached to the FSH. • This requires an empty directory on the FSH. • Whilst Linux does allow low level access to disk drives through device nodes in the /dev directory they are commonly mounted to the FSH. • The mount command is used to both show what devices are available and to attach new devices to the FSH. • The umount command is used to unattach a device. Linux+ Guide to Linux Certification, 2e

  20. umounted / not attached floppy Empty mount point Figure 6-1: The directory structure prior to mounting Linux+ Guide to Linux Certification, 2e

  21. mounted / attached floppy Figure 6-2: The directory structure after mounting a floppy device Linux+ Guide to Linux Certification, 2e

  22. mount command • Only the root user can mount new filesystems. • But everyone can see what is mounted and available. • Mount has 2 uses: • To display the already available or mounted filesystems • mount • With no options or arguments, it lists the currently mounted filesystems - Displays the /etc/mtab • To mount a new file system and allow access to it. Linux+ Guide to Linux Certification, 2e

  23. mount command • Only the root user can mount new filesystems. • To mount a new file system and allow access to it. • mount –t ext3 /dev/fd0 /mnt/floppy • This Associates a device node with the mountpoint thru which it will be accessed. • Can also used to specify the type of filesystem you wish to use. mount /mnt/floppy • If no device node settings are given it reads these settings from the /etc/fstab Linux+ Guide to Linux Certification, 2e

  24. umount command • Only the root user can umount new filesystems. • umount command: • Used to unmount devices from their mount point directories • Remember to umount the disk before removing it from the drive. • A temporary device is NOT written until it is unmounted. Linux+ Guide to Linux Certification, 2e

  25. fuser command • To umount a device from the FSH tree the empty mount point / directory needs to be free for use. • If you get a “device busy” error message when you try to mount a filesystem it means the empty mount point is not free. • fuser -u /mnt/floppy • Checks whether the /mnt/floppy is being used by any user. • Identifies the user Linux+ Guide to Linux Certification, 2e

  26. Mount Points & Mounting • Mount point: • Refers to en empty directory by which a device or storage area is attached to the FSH. • Any existing directory can be a mount point • But this should really be an empty directory = empty mount point. • Mounting: • Mounting refers to attaching a filesystem to the FSH. • Before they can be accessed. • All devices/filesystems are required to be mounted onto the FSH. • The mount command is used to map the device node of a partition or storage device to an already existing empty directory. • That directory is then referred to as a mount point. • So the term ‘mounting’ - refers to the act of making a device accessible to users via the FSH or logical directory tree structure. Linux+ Guide to Linux Certification, 2e

  27. external partitioning are permanent storage devices Figure 6-7: A sample dual-boot Linux partitioning strategy Linux+ Guide to Linux Certification, 2e

  28. Remember this ? Empty mount point Empty mount point Figure 6-1: The directory structure prior to mounting Linux+ Guide to Linux Certification, 2e

  29. /etc/fstab is run at boot time. • All permanent external filesystems are mounted to the / directory. • Through the /etc/fstab system configuration file. • cat /etc/fstab • System Administrators edit the /etc/fstab file • to add new partitions • to mount new filesystems automatically at boot time. • It is also consulted when users do not specify enough argumentswhen they use the mount command to mount a temporary filesystem. • Six fields: Device to mount, mount point, type, mount options, dump#, fsck# Linux+ Guide to Linux Certification, 2e

  30. Summary of mount commands Table 6-4: Useful commands when mounting and unmounting filesystems Linux+ Guide to Linux Certification, 2e

  31. Mounting temporary storage devices • A temporary device must have a mount point already available. • CDROM • Typically they use iso9660 filesystem type and are not writable. • And are mount with –r (read-only) option • Cannot be ejected until properly unmounted • mount –t iso9660 /dev/cdrom /mnt/cdrom • USB • Typically they use vfat filesystem • Identified as scsi devices • mount –t vfat /dev/sda1 /mnt/usb • Floppy • Typically they use either ext3 or vfat filesystem • mount –t ext3 /dev/fd0 /mnt/floppy Linux+ Guide to Linux Certification, 2e

  32. All storage devices need a filesystems on them. • For access storage devices need to be formatted with a filesystem. • Filesystem: Is an organization imposed on physical storage media • There are many different types of filesystems. • The default filesystem of Red Hat Enterprise Linux is the ext3 filesystem. Linux+ Guide to Linux Certification, 2e

  33. mkfs command • Can be used to format a device or partition. • mkfs /dev/fd0 • With no options assumes the default filesystem ext2. • mkfs –t ext3 /dev/fd0 • Also used to specify the type of filesystem you wish to use. • There are other commands also available which directly identify the filesystem to be created on the device. • Basically these two formats of commands do exactly the same thing. Table 6-3: Commands used to create filesystems Linux+ Guide to Linux Certification, 2e

  34. df commnd • df (disk free space) command: • Monitor free space used by mounted filesystems • –h option: More user friendly Linux+ Guide to Linux Certification, 2e

  35. Workbook5 - Command Summary • ls – n –i –s • stats • ln –s • mount umount • mkfs df Linux+ Guide to Linux Certification, 2e

More Related