Home

LPI Linux Certification in a Nutshell Part 12

LPI Linux Certification in a Nutshell - novelonlinefull.com

You’re read light novel LPI Linux Certification in a Nutshell Part 12 online at NovelOnlineFull.com. Please use the follow button to get notification about the latest chapter next time when you visit NovelOnlineFull.com. Use F11 button to read novel in full-screen(PC only). Drop by anytime you want to read free – fast – latest novel. It’s great if you could leave a comment, share your opinion about the new chapters, new novel with others on the internet. We’ll do our best to bring you the finest, latest novel everyday. Enjoy

Chapter7.Devices, Linux Filesystems, and the Filesystem Hierarchy Standard (Topic 104)

Filesystem management is among the most critical activities that you must perform to maintain a stable Linux system. In simple situations, after a successful installation, you may never have a problem or need to manage filesystem specifics. However, understanding how to configure and maintain Linux filesystems is essential to safely manage your system and to pa.s.s Exam 101. This section contains the following Objectives: Objective 1: Create Part.i.tions and Filesystems This Objective states that an LPIC 1 candidate should be able to configure disk part.i.tions and create filesystems on media such as hard disks. It also includes using various mkfs mkfs commands to set up filesystems such as commands to set up filesystems such as ext2 ext2, ext3 ext3, reiserfs reiserfs, vfat vfat, and xfs xfs, in addition to managing swap part.i.tions. Weight: 2.

Objective 2: Maintain the Integrity of Filesystems A candidate should be able to verify the integrity of filesystems, monitor free s.p.a.ce and inodes, and repair simple filesystem problems. This Objective includes the commands required to maintain a standard filesystem as well as the extra data a.s.sociated with a journaling journaling filesystem. Weight: 2. filesystem. Weight: 2.

Objective 3: Control Filesystem Mounting and Unmounting Candidates should be able to manually mount and unmount filesystems, configure filesystem mounting on system boot, and configure user-mountable removable filesystems such as flash drives, floppies, and CDs. Weight: 3.

Objective 4: Set and View Disk Quotas This Objective includes managing disk quotas for system users. You should be able to set up a disk quota for a filesystem, edit, check, and generate user quota reports. Weight: 1.

Objective 5: Manage File Permissions and Ownership Candidates should be able to control file access through file permissions. This Objective includes access permissions on regular and special files as well as directories. Also included are access modes such as suid, sgid suid, sgid, and the sticky bit sticky bit. You should also be aware of the use of the group field to grant file access to workgroups, the immutable flag immutable flag, and the default file creation mode. Weight: 3.

Objective 6: Create and Change Hard and Symbolic Links Candidates should be able to create and manage hard and symbolic links to a file. This Objective includes the ability to create and identify links, copy files through links, and use linked files to support system administration tasks. Weight: 2.

Objective 7: Find System Files and Place Files in the Correct Location This Objective states that candidates should be thoroughly familiar with the FHS, including typical file locations and directory cla.s.sifications. This includes the ability to find files and commands on a Linux System. Weight: 2.

Objective 1: Create Part.i.tions and Filesystems The term filesystem filesystem refers to two different things. First, it can mean the way files and directories are physically structured on a disk or other storage medium. Linux supports many different filesystems (in this sense of the word), including refers to two different things. First, it can mean the way files and directories are physically structured on a disk or other storage medium. Linux supports many different filesystems (in this sense of the word), including ext2 ext2 and and ext3 ext3, the nonjournaled and journaled (respectively) native filesystems; msdos msdos or or vfat vfat, the native MS-DOS and Windows (respectively) filesystems; JFS, a filesystem used on OS/2 and AIX; XFS, the native IRIX filesystem; and many, many others.

In the second sense of the word, it refers to the structure and contents of some storage medium. To view the contents of a filesystem (in this sense of the word) on a Linux system, the device must be mounted mounted, or attached to the hierarchical directory structure on the system. Much of the strength and flexibility of Linux (and Unix) comes from the ability to mount any filesystem that it supports, whether that filesystem is somewhere remote on the network or on a locally attached disk, anywhere in its directory structure, in a way that is completely transparent to users. For example, the files under /usr /usr will work equally well whether they are on a disk attached to the system or mounted from a master server. Even the will work equally well whether they are on a disk attached to the system or mounted from a master server. Even the / / (root) filesystem can be located on a distant server if the system is properly configured. (root) filesystem can be located on a distant server if the system is properly configured.

Disk Drives Under Linux Linux supports many types of disk devices and formats. Any SCSI or IDE hard disk will work with Linux, as will floppy disks, CD-ROMs, CD-Rs, USB flash drives, and other types of removable media. These media can contain the standard Linux ext2 ext2 filesystem, FAT, FAT32, NTFS, as well as other filesystem types. This flexibility makes Linux coexist nicely with other operating systems on multiboot systems. filesystem, FAT, FAT32, NTFS, as well as other filesystem types. This flexibility makes Linux coexist nicely with other operating systems on multiboot systems.

The most commonly found hard disks on PCs are IDE drives. These disks feature a relatively simple system interface, and most of the "smarts" of the disk are onboard the disk itself. The IDE standard allows disk manufacturers to sell their product at a very compet.i.tive price, expanding their markets to more consumers and limited-budget commercial customers.

A single IDE interface is capable of attaching two disk drives to a system. One device is named master master and the other is the and the other is the slave slave. Most PCs have a primary primary and and secondary secondary IDE interface. Together, these interfaces allow up to four devices (primary master, primary slave, secondary master, and secondary slave). IDE interface. Together, these interfaces allow up to four devices (primary master, primary slave, secondary master, and secondary slave).

Also used on PCs are SCSI drives. SCSI is an older standard for connecting peripherals; however, modern SCSI versions are quite fast and flexible. Typically, SCSI devices are used for their increased speed and reliability in large-scale and high-end server environments. With the increased speeds, however, come increased prices-often two to five times the price of their IDE counterparts.

Compared to IDE, SCSI offers excellent performance, lower CPU utilization, and a much more flexible connection scheme capable of handling up to 15 devices on a single bus. These conveniences allow SCSI systems to grow as s.p.a.ce requirements increase without major hardware reconfiguration.

A third option available on motherboards in recent years is the Serial ATA (SATA) interface. SATA is basically a newer version of the IDE standard, and allows for much faster communication between the controller and the physical disk. The Linux kernel currently uses the SCSI emulation layer SCSI emulation layer to support SATA hard drives, so from a device standpoint, SATA disks are treated the same way as SCSI disks. It's also important to note that some Linux distributions are configured to use the SCSI emulation layer for IDE disks as well, so you may be referring to your disks via the SCSI naming conventions even if you have IDE or SATA disks. to support SATA hard drives, so from a device standpoint, SATA disks are treated the same way as SCSI disks. It's also important to note that some Linux distributions are configured to use the SCSI emulation layer for IDE disks as well, so you may be referring to your disks via the SCSI naming conventions even if you have IDE or SATA disks.

Hard disk devices By default, Linux defines IDE device files as follows: /dev/hda Primary master IDE (often the hard disk) /dev/hdb Primary slave IDE /dev/hdc Secondary master IDE (often a CD-ROM) /dev/hdd Secondary slave IDE SCSI device files (or any devices using the SCSI emulation layer) are similar, except that there is no four-device limitation: /dev/sda First SCSI drive /dev/sdb Second SCSI drive /dev/sdc Third SCSI drive (and so on) Under Linux, a typical PC with a single hard disk on the primary IDE interface and a single CD-ROM on the secondary IDE interface would have disk drive /dev/hda /dev/hda and CD-ROM and CD-ROM /dev/hdc /dev/hdc.

On the ExamYou should be prepared to identify IDE and SCSI devices based on their device filenames.

Disk part.i.tions Almost every operating system supports a system for dividing a disk into logical devices, called part.i.tions part.i.tions. Other terms for the same basic concept are slices slices and and logical volumes logical volumes, although logical volumes generally also imply the ability to span physical disks. Linux supports several different part.i.tioning formats, but by default it uses the MS-DOS format. The MS-DOS part.i.tion table allows for up to four primary part.i.tions primary part.i.tions. One of these four primary part.i.tions can be replaced with an extended part.i.tion extended part.i.tion, which can contain up to 12 logical part.i.tions logical part.i.tions, for a total of 15 possible usable part.i.tions (16 if you count the extended part.i.tion "container," but it is not usable for data).

The type of part.i.tion (as well as the type of device) affects the name of the device Linux uses to access the part.i.tion.

Primary part.i.tions This type of part.i.tion contains a filesystem. If all four primary part.i.tions exist on an IDE drive, they are numbered as follows: /dev/hda1 /dev/hda2 /dev/hda3 /dev/hda4 One of these primary part.i.tions may be marked active active, in which case the PC BIOS will be able to select it for boot.

Extended part.i.tions An extended part.i.tion is a variant of the primary part.i.tion but cannot contain a filesystem. Instead, it contains logical part.i.tions logical part.i.tions. Only one extended part.i.tion may exist on a single physical disk. For example, the part.i.tions on a disk with one primary part.i.tion and the sole extended part.i.tion might be numbered as follows: /dev/hda1 (primary) (primary) /dev/hda2 (extended) (extended) Logical part.i.tions Logical part.i.tions exist within within the extended part.i.tion. Logical part.i.tions are numbered from 5 to 16. The part.i.tions on a disk with one primary part.i.tion, one extended part.i.tion, and four logical part.i.tions might be numbered as follows: the extended part.i.tion. Logical part.i.tions are numbered from 5 to 16. The part.i.tions on a disk with one primary part.i.tion, one extended part.i.tion, and four logical part.i.tions might be numbered as follows: /dev/hda1 (primary) (primary) /dev/hda2 (extended) (extended) /dev/hda5 (logical) (logical) /dev/hda6 (logical) (logical) /dev/hda7 (logical) (logical) /dev/hda8 (logical) (logical) If the part.i.tions were made on a SCSI or SATA drive, the hda hda would be replaced by would be replaced by sda sda, for example, /dev/sda2 /dev/sda2.On the ExamBe sure that you understand how part.i.tion numbering works. In particular, pay attention to the differences in numbering between primary, extended, and logical part.i.tions.

The root filesystem and mount points As a Linux system boots, the first filesystem that becomes available is the top level, or root root filesystem, denoted with a single forward slash. The root filesystem filesystem, denoted with a single forward slash. The root filesystem / /, also known as the root directory root directory, shouldn't be confused with the root root superuser account or the superuser's home directory, superuser account or the superuser's home directory, /root /root. The distinct directories / / and and /root /root are unrelated and are not required to share the same filesystem. In a simple installation, the root filesystem could contain nearly everything on the system. However, such an arrangement could lead to system failure if the root filesystem fills to capacity. Instead, multiple part.i.tions are typically defined, each containing one of the directories under are unrelated and are not required to share the same filesystem. In a simple installation, the root filesystem could contain nearly everything on the system. However, such an arrangement could lead to system failure if the root filesystem fills to capacity. Instead, multiple part.i.tions are typically defined, each containing one of the directories under / /. As the Linux kernel boots, the part.i.tions are mounted mounted to the root filesystem, and together create a single unified filesystem (see to the root filesystem, and together create a single unified filesystem (see Objective 3: Control Filesystem Mounting and Unmounting Objective 3: Control Filesystem Mounting and Unmounting for a discussion about mounting). Everything on the system that is not stored in a mounted part.i.tion is stored locally in the for a discussion about mounting). Everything on the system that is not stored in a mounted part.i.tion is stored locally in the / / (root) part.i.tion. The mounted filesystems are placed on separate part.i.tions and possibly multiple disk drives. (root) part.i.tion. The mounted filesystems are placed on separate part.i.tions and possibly multiple disk drives.

The choice of which directories are placed into separate part.i.tions is both a personal and technical decision. Here are some guidelines for individual part.i.tions: / (the root directory) (the root directory) Since the only filesystem mounted at the start of the boot process is / /, certain directories must be part of it to be available for the boot process. These include:/bin and and /sbin /sbinContains required system binary programs/devContains device files/etcContains configuration information used on boot/libContains shared librariesThese directories are always part of the single / / part.i.tion. See the description of the FHS in part.i.tion. See the description of the FHS in Objective 7: Find System Files and Place Files in the Correct Location Objective 7: Find System Files and Place Files in the Correct Location for more on the requirements for the root filesystem. for more on the requirements for the root filesystem.

/boot This directory holds static files used by the boot loader, including kernel images. On systems where kernel development activity occurs regularly, making /boot /boot a separate part.i.tion eliminates the possibility that a separate part.i.tion eliminates the possibility that / / will fill with kernel images and a.s.sociated files during development. will fill with kernel images and a.s.sociated files during development.

/home User files are usually placed in a separate part.i.tion. This is often the largest part.i.tion on the system and may be located on a separate physical disk or disk array.

/tmp This directory is often a separate part.i.tion used to prevent temporary files from filling the root filesystem. By default, all users have read/write access to files they create in /tmp /tmp.

/var Logfiles are stored here. This is similar to the situation with /tmp /tmp, where user files can fill any available s.p.a.ce if something goes wrong or if the files are not cleaned periodically.

/usr This directory holds a hierarchy of directories containing user commands, source code, and doc.u.mentation. It is often quite large, making it a good candidate for its own part.i.tion. Because much of the information stored under /usr /usr is static, some users prefer that it be mounted as read-only, making it impossible to corrupt. is static, some users prefer that it be mounted as read-only, making it impossible to corrupt.

In addition to the preceding six part.i.tions listed, a swap swap part.i.tion is also necessary for a Linux system to enable virtual memory. For information on determining the size of a swap part.i.tion, see part.i.tion is also necessary for a Linux system to enable virtual memory. For information on determining the size of a swap part.i.tion, see Chapter5 Chapter5.

Using these guidelines at installation time, the disk part.i.tions for an IDE-based system with two physical disks (40 GB and 200 GB) on the primary IDE controller might look as described in Table7-1 Table7-1.

Table7-1.An example part.i.tioning scheme

Part.i.tion Type Mounted filesystem Size /dev/hda1 Primary /boot 1 GB /dev/hda2 Primary / 5 GB /dev/hda3 Extended - - /dev/hda5 Logical /usr 10 GB /dev/hda6 Logical /var 10 GB /dev/hda7 Logical /opt 10 GB /dev/hda8 Logical /tmp 2 GB /dev/hda4 Primary (swap part.i.tion) part.i.tion) 2 GB /dev/hdb1 Primary /home 200 GB

Once a disk is part.i.tioned, it can be difficult or risky to change the part.i.tion sizes. Commercial and open source tools are available for this task, but a full backup is recommended prior to their use.

NoteIf you are resizing your part.i.tions, you may want to investigate setting up your system using Logical Volume Manager Logical Volume Manager (LVM). LVM is currently not covered on the LPI exams, but its use is quickly growing. For more information, read the (LVM). LVM is currently not covered on the LPI exams, but its use is quickly growing. For more information, read the LVM-HOWTO at the Linux Doc.u.mentation Project.

Managing part.i.tions Linux has two basic options for part.i.tioning disk drives. The fdisk fdisk command is a text-based program that is easy to use and exists on every Linux distribution. It is also required for Exam 101. Another option you may wish to explore after mastering command is a text-based program that is easy to use and exists on every Linux distribution. It is also required for Exam 101. Another option you may wish to explore after mastering fdisk fdisk is is cfdisk cfdisk, which is still a text-mode program but uses the curses curses system to produce a GUI-style display. system to produce a GUI-style display.

Creating filesystems Once a disk is part.i.tioned, filesystems may be created in those part.i.tions using the mkfs mkfs utility. utility. mkfs mkfs is a frontend program for filesystem-specific creation tools such as is a frontend program for filesystem-specific creation tools such as mkfs.ext2 mkfs.ext2 and and mkfs.msdos mkfs.msdos, which are in turn linked to mke2fs mke2fs and and mkdosfs mkdosfs, respectively. mkfs mkfs offers a unified frontend, while the links provide convenient names. The choice of which executable to call is up to you. offers a unified frontend, while the links provide convenient names. The choice of which executable to call is up to you.

Creating swap part.i.tions Swap part.i.tions are necessary if you want your Linux system to have access to virtual memory. Virtual memory is a section of the hard disk designated for use as memory when the main system memory (the RAM) is all in use. The common formula for determining the amount of swap s.p.a.ce you need has usually been twice the amount of RAM your system has. Although swap is not required by Linux, at least 128 MB is recommended for some spooling functions. On the other hand, memory-intensive applications may recommend much more, based on variables such as the number of users, database tables/sizes, or other application configuration guidelines. It is important to know what the system will be used for when considering swap s.p.a.ce.

The command to create a swap part.i.tion is mkswap mkswap. This command prepares a part.i.tion for use as Linux swap s.p.a.ce and is needed if you plan to fully configure a disk from scratch. It is also required if you need to add an additional swap part.i.tion.

Name fdisk Syntax fdisk[device]

Description Manipulate or display the part.i.tion table for device device using a command-driven interactive text interface. using a command-driven interactive text interface. device device is a physical disk such as is a physical disk such as /dev/hda /dev/hda, not a part.i.tion such as /dev/hda1 /dev/hda1. If omitted, device device defaults to defaults to /dev/hda /dev/hda. Interactive commands to fdisk fdisk are a single letter followed by a carriage return. The commands do not take arguments, but instead start an interactive dialog. Commands that operate on a part.i.tion will request the part.i.tion number, which is an integer. For primary and extended part.i.tions, the part.i.tion number is from 1 to 4. For logical part.i.tions, which are available only when the extended part.i.tion already exists to contain them, the part.i.tion number is from 5 to 16. are a single letter followed by a carriage return. The commands do not take arguments, but instead start an interactive dialog. Commands that operate on a part.i.tion will request the part.i.tion number, which is an integer. For primary and extended part.i.tions, the part.i.tion number is from 1 to 4. For logical part.i.tions, which are available only when the extended part.i.tion already exists to contain them, the part.i.tion number is from 5 to 16.

When making changes to the part.i.tion table, fdisk fdisk acc.u.mulates changes without writing them to the disk, until it receives the write command. acc.u.mulates changes without writing them to the disk, until it receives the write command.

Frequently used commands a Toggle the bootable bootable flag on/off for a primary part.i.tion. flag on/off for a primary part.i.tion.

d Delete a part.i.tion. You are prompted for the part.i.tion number to delete. If you delete a logical part.i.tion when higher-numbered logical part.i.tions exist, the part.i.tion numbers are decremented to keep logical part.i.tion numbers contiguous.

l List the known part.i.tion types. A table of part.i.tion types is printed.

m Display the brief help menu for these commands.

n Add a new part.i.tion. You are prompted for the part.i.tion type (primary, extended, or logical). For primary and extended part.i.tions, you are asked for the part.i.tion number (14). For logical part.i.tions, the next logical part.i.tion number is selected automatically. You are then prompted for the starting disk cylinder for the part.i.tion and are offered the next free cylinder as a default. Finally, you are prompted for the last cylinder or a size, such as +300M +300M. By default, new part.i.tions are a.s.signed as Linux ext2 ext2, type 83. To create another part.i.tion type, such as a swap part.i.tion, first create the part.i.tion with the n n command, and then change the type with the command, and then change the type with the t t command. command.NoteNote that fdisk fdisk displays options for extended and primary part.i.tion types if an extended part.i.tion does not yet exist. If the extended part.i.tion already exists, displays options for extended and primary part.i.tion types if an extended part.i.tion does not yet exist. If the extended part.i.tion already exists, fdisk fdisk displays options for logical and primary part.i.tion types. displays options for logical and primary part.i.tion types.

p Display the part.i.tion table as it exists in memory. This depiction will differ from the actual part.i.tion table on disk if changes have not been saved.

q Quit without saving changes.

t Change a part.i.tion's system ID. This is a hex number that indicates the type of filesystem the part.i.tion is to contain. Linux ext2 ext2 part.i.tions are type 83, and Linux swap part.i.tions are type 82. part.i.tions are type 83, and Linux swap part.i.tions are type 82.

w Write (save) the part.i.tion table to disk and exit. No changes are saved until the w w command is issued. command is issued.

Example 1 Display the existing part.i.tion table on /dev/hda /dev/hda without making any changes: without making any changes: #fdisk/dev/hda Command(mforhelp):p Disk/dev/hda:255heads,63sectors,1027cylinders Units=cylindersof16065*512bytes DeviceBootStartEndBlocksIdSystem /dev/hda1*12502008093+83Linux /dev/hda225128024097582Linuxswap /dev/hda328110276000277+5Extended /dev/hda528129310439183Linux /dev/hda629430610439183Linux /dev/hda730731910439183Linux Command(mforhelp):q # In this configuration, /dev/hda /dev/hda has two primary part.i.tions, has two primary part.i.tions, /dev/hda1 /dev/hda1, which is bootable, and /dev/hda2 /dev/hda2, which is the swap part.i.tion. The disk also has an extended part.i.tion /dev/hda3 /dev/hda3, which contains three logical part.i.tions, /dev/hda5 /dev/hda5, /dev/hda6 /dev/hda6, and /dev/hda7 /dev/hda7. All other primary and logical part.i.tions are Linux ext2 ext2 part.i.tions. part.i.tions.

Example 2 Starting with a blank part.i.tion table, create a bootable primary part.i.tion of 300 MB on /dev/hda1 /dev/hda1, the extended part.i.tion on /dev/hda2 /dev/hda2 containing the remainder of the disk, a logical part.i.tion of 200 MB on containing the remainder of the disk, a logical part.i.tion of 200 MB on /dev/hda5 /dev/hda5, a logical swap part.i.tion of 128 MB on /dev/hda6 /dev/hda6, and a logical part.i.tion on /dev/hda7 /dev/hda7 occupying the remainder of the extended part.i.tion: occupying the remainder of the extended part.i.tion: #fdisk/dev/hda Command(mforhelp):n Commandaction eextended pprimarypart.i.tion(1-4)p Part.i.tionnumber(1-4):1 Firstcylinder(1-1027,default1):Enter Usingdefaultvalue1 Lastcylinderor+sizeor+sizeMor+sizeK(1-1027,default1027):+300M Command(mforhelp):a Part.i.tionnumber(1-4):1 Command(mforhelp):n Commandaction eextended pprimarypart.i.tion(1-4)e Part.i.tionnumber(1-4):2 Firstcylinder(40-1027,default40):Enter Usingdefaultvalue40 Lastcylinderor+sizeor+sizeMor+sizeK(40-1027,default1027):Enter Usingdefaultvalue1027 Command(mforhelp):n Commandaction llogical(5orover) pprimarypart.i.tion(1-4)l Firstcylinder(40-1027,default40):Enter Usingdefaultvalue40 Lastcylinderor+sizeor+sizeMor+sizeK(40-1027,default1027):+200M Command(mforhelp):n Commandaction llogical(5orover) pprimarypart.i.tion(1-4)l Firstcylinder(79-1027,default79):Enter Usingdefaultvalue79 Lastcylinderor+sizeor+sizeMor+sizeK(79-1027,default1027):+128M Command(mforhelp):t Part.i.tionnumber(1-6):6 Hexcode(typeLtolistcodes):82 Changedsystemtypeofpart.i.tion6to82(Linuxswap) Command(mforhelp):n Commandaction llogical(5orover) pprimarypart.i.tion(1-4)l Firstcylinder(118-1027,default118):Enter Usingdefaultvalue118 Lastcylinderor+sizeor+sizeMor+sizeK(118-1027,default1027):Enter Usingdefaultvalue1027 Command(mforhelp):p Disk/dev/hda:255heads,63sectors,1027cylinders Units=cylindersof16065*512bytes DeviceBootStartEndBlocksIdSystem /dev/hda1*13931323683Linux /dev/hda240102779361105Extended /dev/hda54065208813+82Linuxswap /dev/hda6668213652183Linux /dev/hda7831027759068183Linux Command(mforhelp):w Thepart.i.tiontablehasbeenaltered!

Callingioctl()tore-readpart.i.tiontable.

Syncingdisks.

# Note the use of defaults for the part.i.tion start cylinders and for end cylinder selections, indicated by Enter Enter in this example. Other part.i.tion sizes are specified in megabytes using responses such as in this example. Other part.i.tion sizes are specified in megabytes using responses such as +128M +128M.

NoteIf you are attempting to create part.i.tions for other operating systems with the Linux fdisk fdisk utility, you could run into a few problems. As a rule, it is safest to prepare the part.i.tions for an operating system using the native tools of that operating system. utility, you could run into a few problems. As a rule, it is safest to prepare the part.i.tions for an operating system using the native tools of that operating system.As you might expect, using fdisk fdisk on a working system can be dangerous, because one errant on a working system can be dangerous, because one errant w w command can render your disk useless. Use extreme caution when working with the part.i.tion table of a working system, and be sure you know exactly what you intend to do and how to do it. command can render your disk useless. Use extreme caution when working with the part.i.tion table of a working system, and be sure you know exactly what you intend to do and how to do it.On the ExamYou should understand disk part.i.tions and the process of creating them using fdisk fdisk.

Name mkfs Syntax mkfs[-tfstype][fs_options]device Description Make a filesystem of type fstype fstype on on device device. If fstype fstype is omitted, is omitted, ext2 ext2 is used by default. When called by is used by default. When called by mkfs mkfs, these programs are pa.s.sed any fs_options fs_options included on the command line. It is common to see references to commands such as included on the command line. It is common to see references to commands such as mkfs.ext2 mkfs.ext2, mkfs.ext4 mkfs.ext4, or mkfs.xfs mkfs.xfs. These are all aliases for mkfs, specifying a specific kind of filesystem you wish to create.

Frequently used options -c Check device device for bad blocks before building the filesystem. for bad blocks before building the filesystem.

-L label label Set the volume label for the filesystem (ext-based filesystems only).

-n label label Set the 11-character volume label for the filesystem (mkdosfs only). only).

-q Uses mkfs mkfs in quiet mode, resulting in very little output. in quiet mode, resulting in very little output.

-v Used to enter verbose mode.

-j Create an ext3 ext3 journal file ( journal file (mkfs.ext2 only). Using only). Using -t ext3 -t ext3 or running or running mkfs.ext3 mkfs.ext3 has the same effect as using the has the same effect as using the -j -j option. option.

Example 1 Using defaults, quietly create an ext2 ext2 part.i.tion on part.i.tion on /dev/hda3 /dev/hda3: #mkfs-q/dev/hda3 mke2fs1.14,9-Jan-1999forEXT2FS0.5b,95/08/09 # Example 2 Create an ext2 ext2 filesystem labeled filesystem labeled rootfs rootfs on existing part.i.tion on existing part.i.tion /dev/hda3 /dev/hda3, checking for bad blocks and with full verbose output: #mkfs-text2-Lrootfs-cv/dev/hda3 mke2fs1.27(8-Mar-2002) Filesystemlabel=rootfs OStype:Linux Blocksize=1024(log=0) Fragmentsize=1024(log=0) 26208inodes,104422blocks 5221blocks(5.00%)reservedforthesuperuser Firstdatablock=1 13blockgroups 8192blockspergroup,8192fragmentspergroup 2016inodespergroup Superblockbackupsstoredonblocks: 8193,16385,24577,32769,40961,49153, 57345,65537,73729,81921,90113,98305 Runningcommand:badblocks-b1024-s/dev/hda3104422 Checkingforbadblocks(read-onlytest):done Writinginodetables:done Writingsuperblocksandfilesystemaccountinginformation:done Thisfilesystemwillbeautomaticallycheckedevery28mountsor 180days,whichevercomesfirst.Usetune2fs-cor-itooverride.

Additional options are available in the mke2fs mke2fs and and mkdosfs mkdosfs programs, which may be needed to fine-tune specific filesystem parameters for special situations. In most cases, the default parameters are appropriate and adequate. programs, which may be needed to fine-tune specific filesystem parameters for special situations. In most cases, the default parameters are appropriate and adequate.

Name mkswap Syntax mkswapdevice Description Prepare a part.i.tion for use as swap s.p.a.ce. This command can also set up swap s.p.a.ce in a file on another filesystem.

Example On an existing part.i.tion, which should be set to type 82 (Linux swap), ready swap s.p.a.ce: #mkswap/dev/hda5 Settingupswaps.p.a.ceversion1,size=139792384bytes #NoteRunning any of the filesystem creation programs is, like fdisk fdisk, potentially dangerous. All data in any previously existing filesystems in the specified part.i.tion will be deleted. Since mkfs mkfs does not warn you prior to creating the filesystem, be certain that you are operating on the correct part.i.tion. does not warn you prior to creating the filesystem, be certain that you are operating on the correct part.i.tion.On the ExamThe exam is likely to contain general questions about using mkfs mkfs and and mkswap mkswap, although details such as inode allocation are beyond the scope of the LPIC Level 1 exams.

Objective 2: Maintain the Integrity of Filesystems Over the course of time, active filesystems can develop problems, such as: A filesystem fills to capacity, causing programs or perhaps the entire system to fail.

A filesystem is corrupted, perhaps due to a power failure or system crash.

A filesystem runs out of inodes, meaning that new filesystem objects cannot be created.

Carefully monitoring and checking Linux filesystems on a regular basis can help prevent and correct these types of problems.

Monitoring Free Disk s.p.a.ce and Inodes A read/write filesystem isn't much good if it grows to the point where it won't accept any more files. This could happen if the filesystem fills to capacity or runs out of inodes inodes.

Inodes are the data structures within filesystems that describe files on disk. Every filesystem contains a finite number of inodes, set when the filesystem is created. This number is also the maximum number of files that the filesystem can accommodate. Because filesystems are created with a huge number of inodes, you'll probably never create as many files as it would take to run out of inodes. However, it is possible to run out of inodes if a part.i.tion contains many small files.

It is important to prevent s.p.a.ce and inode shortages from occurring on system part.i.tions. The df df command gives you the information you need on the status of both disk s.p.a.ce utilization and inode utilization. command gives you the information you need on the status of both disk s.p.a.ce utilization and inode utilization.

Monitoring Disk Usage Have you ever found yourself wondering, "Where did all the disk s.p.a.ce go?" Some operating systems make answering this question surprisingly difficult using only native tools. On Linux, the du du command can help display disk utilization information on a per-directory basis and perhaps answer that question. command can help display disk utilization information on a per-directory basis and perhaps answer that question. du du recursively examines directories and reports detailed or summarized information on the amount of s.p.a.ce consumed. recursively examines directories and reports detailed or summarized information on the amount of s.p.a.ce consumed.

Modifying a Filesystem There are many cases where an administrator might want to make changes to an existing filesystem. For example, if the purpose of a particular filesystem changes, the volume label should be changed to match. This and many other ext2 ext2 filesystem settings can be viewed and modified using the filesystem settings can be viewed and modified using the tune2fs tune2fs command. command.

Checking and Repairing Filesystems No matter how stable, computers do fail, even due to something as simple as a power cable being accidentally unplugged. Unfortunately, such an interruption can make a mess of a filesystem. If a disk write operation is aborted before it completes, the data in transit could be lost, and the portions of the disk that were allocated for it are left marked as used. In addition, filesystem writes are cached in memory, and a power loss or other crash prevents the kernel from synchronizing the cache with the disk. Both of these scenarios lead to inconsistencies in the filesystem and must be corrected to ensure reliable operation.

Filesystems are checked with fsck fsck. Like mkfs, fsck mkfs, fsck is a frontend to filesystem-specific utilities, including is a frontend to filesystem-specific utilities, including fsck.ext2 fsck.ext2, which is a link to the e2fsck e2fsck program. (See its manpage for detailed information.) program. (See its manpage for detailed information.) Notee2fsck can also check can also check ext3 ext3 filesystems. When it finds an filesystems. When it finds an ext3 ext3 filesystem that was not cleanly unmounted, it first commits the journal, then checks the filesystem as it normally would with filesystem that was not cleanly unmounted, it first commits the journal, then checks the filesystem as it normally would with ext2 ext2.

Part of the information written on disk to describe a filesystem is known as the superblock superblock, written in block 1 of the part.i.tion. If this area of the disk is corrupted, the filesystem is inaccessible. Because the superblock is so important, copies of it are made in the filesystem at regular intervals, by default every 8192 blocks. The first superblock copy is located at block 8193, the second copy is at block 16385, and so on. As you'll see, fsck fsck can use the information in the superblock copies to restore the main superblock. can use the information in the superblock copies to restore the main superblock.

Name df Syntax df[options][file[file...]]

Description Display overall disk utilization information for mounted filesystems on file file. Usually, file file is a device file for a part.i.tion, such as is a device file for a part.i.tion, such as /dev/hda1 /dev/hda1. The file file may also be the mount point or any file beneath the mount point. If may also be the mount point or any file beneath the mount point. If file file is omitted, information for mounted filesystems on all devices in is omitted, information for mounted filesystems on all devices in /etc/fstab /etc/fstab are displayed. are displayed.

Frequently used options -h Displays results in a human-readable format, including suffixes such as M M (megabytes) and (megabytes) and G G (gigabytes). (gigabytes).

-i Displays information on remaining inodes rather than the default disk s.p.a.ce information.

Example 1 Check disk s.p.a.ce utilization on all filesystems: #df-h FilesystemSizeUsedAvailUse%Mountedon /dev/sda1387M56M311M15%/ /dev/sda5296M5.2M276M2%/boot /dev/sda91.9G406M1.4G22%/home /dev/sda653M12M39M23%/root /dev/sda1099M104k93M0%/tmp /dev/sda8972M507M414M55%/usr /dev/sda7296M9.3M272M3%/var This example shows that of the seven filesystems mounted by default, none exceeds 55 percent capacity.

Example 2 Check the same filesystems for inode utilization: #df-i FilesystemInodesIUsedIFreeIUse%Mountedon /dev/sda11028007062957387%/ /dev/sda57831229782830%/boot /dev/sda95140009345130660%/home /dev/sda614056641134155%/root /dev/sda102610460260440%/tmp /dev/sda82570403670022034014%/usr /dev/sda778312269780430%/var Among these part.i.tions, the largest consumption of inodes is a mere 14 percent. It is clear that none of the filesystems is anywhere near consuming the maximum number of inodes available. Note that the /usr /usr part.i.tion (with 14 percent of inodes used) has used 55 percent of the disk s.p.a.ce. With utilization like this, the part.i.tion (with 14 percent of inodes used) has used 55 percent of the disk s.p.a.ce. With utilization like this, the /usr /usr volume will most likely fill to capacity long before the inodes are exhausted. volume will most likely fill to capacity long before the inodes are exhausted.

Example 3 Quickly determine which part.i.tion the current working directory (represented simply by a single dot) is located: #df.

Filesystem1k-blocksUsedAvailableUse%Mountedon /dev/sda11028007062957387%/ When a filesystem is nearing capacity, files may simply be deleted to make additional s.p.a.ce available. However, in the rare case in which an inode shortage occurs, the filesystem must be recreated with a larger number of inodes unless a significant number of files can be deleted.

Name du Syntax du[options][directories]

Please click Like and leave more comments to support and keep us alive.

RECENTLY UPDATED MANGA

Martial Peak

Martial Peak

Martial Peak Chapter 5686: Meng Que Author(s) : Momo,莫默 View : 14,958,053
Emperor’s Domination

Emperor’s Domination

Emperor’s Domination Chapter 5744: Fight To The End Author(s) : Yan Bi Xiao Sheng,厌笔萧生 View : 16,758,037

LPI Linux Certification in a Nutshell Part 12 summary

You're reading LPI Linux Certification in a Nutshell. This manga has been translated by Updating. Author(s): Adam Haeder. Already has 815 views.

It's great if you read and follow any novel on our website. We promise you that we'll bring you the latest, hottest novel everyday and FREE.

NovelOnlineFull.com is a most smartest website for reading manga online, it can automatic resize images to fit your pc screen, even on your mobile. Experience now by using your smartphone and access to NovelOnlineFull.com