Lab Questions


The Red Hat exams are unique based on their reliance on labs and hands-on demonstrations. With these questions, you're practicing the skills you need on both Red Hat exams.

Lab 1

1. 

In this lab, you'll install an updated kernel. This requires that an updated kernel be available, and you may not be able to run this lab unless you have such a kernel. However, if an older kernel is available for the distribution, you could add the --force switch to the rpm command used in this lab to downgrade to the old kernel temporarily.

In most cases, if you have an appropriate connection to the RHN or a rebuild repository (or even the update repositories for Fedora Core 6), you should be able to install the new kernel. List two methods you could use.

Finally, observe what happens to /boot/grub/grub.conf. What changed? What's the default kernel?

image from book

Answers

1. 

Installing an updated kernel is easy. Assuming it's available from a repository such as the RHN, all you should have to do is run the following command:

 # yum install kernel 

However, you can also download and install the kernel RPM. Naturally, if the RPM is readily available, you can install it by applying a command such as rpm -ivh to the new kernel RPM. Be sure to avoid upgrading; that would overwrite any existing kernel.

As for the GRUB configuration file, you'll see a new stanza associated with the new kernel as well as the associated initial RAM disk. The other parameters should remain the same (except for version numbers) relative to the stanza that boots the existing kernel. The default directive in GRUB now points to the existing (and presumably working) kernel. (This is different from previous versions of Red Hat Enterprise Linux.)

Lab 2

2. 

In this lab, you'll customize and recompile the kernel. Yes, this is beyond what is listed in the Red Hat Exam Prep guide. However, recent changes to the kernel compilation process leads me to believe that Red Hat may reintroduce this skill into the RHCE exam sometime in the near future.

This lab is more of a detailed kernel building exercise than a typical lab. Even if you don't need to compile a kernel on the Red Hat exams, I predict that you will need to compile a kernel at some point as a Linux system administrator. See the Lab Answers section at the end of this chapter for the exercise.

If you want to try things out for yourself, download and install the kernel src.rpm for the active kernel. Install it, and run the rpmbuild command on the associated .spec file. Customize some minor part of the kernel, change the EXTRAVERSION directive in the associated Makefile, and run make rpm to compile and create an RPM for the custom kernel.

image from book

Answers

2. 

Before building a new kernel, you need the correct RPM packages (with dependencies), often associated with the Development Tools package group. As with the rest of this chapter and the Red Hat exams, this assumes that you have a PC with a 32-bit Intel type CPU. The procedures for other CPUs vary and are not, as of this writing, covered on the Red Hat exams.

The following list of RPMs are associated with the source code (version numbers omitted). This does not include dependencies. When possible, use the yum command to satisfy and install these dependencies automatically.

 kernel-`uname -r`.src.rpm unidef rpm-build glibc-headers glibc-devel cpp ncurses ncurses-devel binutils gcc 

If you want to use a tool such as those you can start with the make xconfig or make gconfig command, you'll also need the following packages:

 tcl gtk2-devel qt-devel glib2-devel libglade2-devel 

  1. When you installed RHEL, if you installed the Development Tools package group, you've probably already installed most of these packages.

  2. Install the kernel-`uname -r`.src.rpm. It should install the kernel-2.6.spec file in the /usr/src/ redhat/SPECS directory.

  3. Build the kernel; navigate to the SPECS directory, and run the rpmbuild -bb kernel-2.6.spec command.

  4. Inspect the result in the /usr/src/redhat/BUILD directory. You should see the kernel source code in the kernel-2.6.18/linux-2.6.18.`uname -m` subdirectory. Navigate to that directory. You'll be running the remaining kernel configuration commands there.

  5. Set up a unique name for the kernel that you're about to modify. Open the Makefile file in a text editor. Look for the EXTRAVERSION variable. Red Hat adds this variable as a suffix to the recompiled kernel. Modify this variable appropriately, perhaps with your initials.

  6. Jot down the value of the EXTRAVERSION variable here: ______________

  7. Determine the correct CPU on your hardware. Use the following command:

     # uname -m 

  8. Jot down the CPU model name here: ________________

  9. Make sure you're in the kernel source code directory. It is time to configure your kernel, using one of the four major tools:

    • make config A line-by-line tool that gives you a choice with all kernel options.

    • make menuconfig A text-based menu that allows you to select just the changes you want.

    • make xconfig A GUI interface associated with KDE tools.

    • make gconfig A GUI interface associated with GNOME tools.

  10. In the kernel configuration menu of your choice, navigate to the General Setup category, and enable the Kernel .config Support option.

  11. Save the custom kernel and exit.

  12. When you save the new configuration, the kernel configuration tool overwrites the .config file in the local directory.

  13. Process the custom kernel with the following command. This will produce a lot of output and may take an hour or more.

     # make rpm 

  14. Check the /usr/src/redhat/RPMS/`uname -m` subdirectory. You should see a custom RPM that you can now use. Check its name against the EXTRAVERSION directive you set earlier in this lab.

  15. Install the custom RPM.

  16. Create a new initial RAM disk in your /boot directory. For example, if your EXTRAVERSION=-prep, create it with the following command:

     # mkinitrd /boot/initrd-2.6.18-prep 2.6.18-prep 

  17. Create a stanza that points to the kernel and initial RAM disk files. You should be able to use the existing stanza as a model.

  18. Congratulations, you have just installed a custom kernel on your new system. As long as you also have your original kernel in your boot loader menu, test it out!

  19. Run the reboot command. You should see both kernels in the boot loader menu. Try your custom kernel. (If it doesn't work, you can always power cycle your system and boot into the original working kernel.)

Lab 3

3. 

In this lab, you'll add a new RAID array to your system. This is possible if you have free space on the current drive or can add a new drive. That's not as difficult as it appears if you have a VMware-based system. You can even use a USB key for this purpose (assuming you don't need to save any data on that key).

One way to test this lab is to create a separate RAID partition for the /tmp directory. Unless you use it for downloads, it's fairly small; on my system, it has 120KB of data. (If you're using /tmp for downloads, chances are you're using a production system, and that can be dangerous, unless your backups are in order.)

Create a simple RAID 1 mirror. All you need are two partitions. While it's best if the partitions are on different physical drives, it's not required for this lab. Remember to activate the array. Assign and mount it on a new directory. Copy files from your home directory. If the space used by your home directory is greater than available from the RAID array, you don't have to copy everything. Add the information to your /etc/fstab, and test the result.

image from book

Answers

3. 

This lab assumes that you have some unpartitioned space, either on an existing drive or a new drive that you've just added. A VMware machine is one excellent option that makes adding a new drive relatively easy. For the purpose of this lab, even a USB key will suffice.

To add a new partition, you'll need to use either fdisk or parted. Allocate no more than half of the available free space to the first partition. Make sure to designate the RAID filetype. If you use fdisk, you'll need to either reboot or run partprobe to make Linux reread the new partition table. Whatever you do, one simple way to make sure you have a new partition of the RAID filetype is with the following command:

 # fdisk -l 

Of course, a RAID 1 mirror requires two different RAID partitions. So if you've created only one RAID partition, you'll have to repeat the process for the second RAID partition.

For the purpose of this lab, I assume the new RAID partitions are associated with /dev/hdb1 and /dev/hdb2, and this is the first RAID array configured on the local system. Just remember this lab is just for practice-you should never configure RAID partitions from the same physical drive. If that drive fails, you'll lose all data on that RAID array.

If your partitions are associated with different devices, substitute accordingly. For example, if this is the second local RAID array, the device is /dev/md1. You can create a RAID 1 mirror with the correct mdadm command:

 # mdadm --create /dev/md0 --level=1 --raid-devices=2 \ /dev/hdb1 /dev/hdb2 

Now that you've created an array, you'll need to format it. In this case, you can format it to the default ext3 filesystem with the following command:

 # mkfs.ext3 /dev/md0 

Assign and mount it on a new directory. I've created a /temp directory for this purpose:

 # mount /dev/md0 /temp 

Copy files from the /tmp directory. The dot after /tmp/ makes sure to copy all files and directories, including those that are hidden:

 # cp -a /tmp/. /temp/ 

Unmount the /temp directory, and mount the RAID array on /tmp:

 # umount /temp # mount /dev/md0 /tmp 

Make sure things are what you expect:

 # ls -a /tmp 

Unmount /tmp:

 # umount /tmp 

Add the information to your /etc/fstab, and run the following command to test the result. Based on this lab, you'd add the following to /etc/fstab:

 /dev/md0 /tmp ext3 defaults 0 0 

Then to test the result, run the following command to mount all filesystems listed in /etc/fstab:

 # mount -a 

Lab 4

4. 

Lab 4 and Lab 5 are to be run in sequence.

In Lab 4, you'll add a new LV to your system. It doesn't have to be complex; you can use free extents from an available LVM or a single new LVM partition. If possible, you'll want to leave some free extents for Lab 5, or you'll have to create another new LVM partition in that lab.

One way to test this lab is to create a separate LVM for the /tmp directory. Unless you use it for downloads, it's fairly small; on my system, it has 120KB of data. (If you're using /tmp for downloads, chances are you're using a production system, and that can be dangerous, unless your backups are in order.)

Add the information to your /etc/fstab, and run mount -a to test the result.

image from book

Answers

4. 

For this lab, I assume that you've never created an LV before on the local system. The first step is to create (or reallocate) dedicated partitions for this purpose and assign it to the LVM file type. In fdisk, that's file type 8e; to set the first partition to LVM in parted, run set 1 lvm on. Repeat the process for additional LVM partitions. For the purpose of this lab, I've created a single partition, /dev/sdb1, with 200MB, and assume you're working from the command line. Of course, you can do everything in this lab-after creating a partition-with the GUI Logical Volume Management tool.

Next, create a PV; for example, if the new LVM partition you created is /dev/sdb1, run the following command:

 # pvcreate /dev/sdb1 

If you want to confirm the result, run the pvs command. Now create a new VG; with the following command, you use the /dev/sdb1 PV to create a VG named vgrp01:

 # vgcreate vgrp01 /dev/sdb1 

You can confirm this result with the vgs command. Now create a new LV with the lvcreate command. The following command creates an LV named lvol01 of 100MB from the previously created VG:

 # lvcreate -L 100M vgrp01 -n lvol01 

Confirm this result with the lvs command. Next, format the LV you've just created:

 # mkfs.ext3 /dev/vgrp01/lvol01 

Now you can mount it on a specific directory. Using the example described in Lab 3, I've created a /test directory and have mounted the LV on it:

 # mount /dev/vgrp01/lvol01 /test 

Copy files from the /tmp directory. The dot after /tmp/ makes sure to copy all files and directories, including those that are hidden:

 # cp -a /tmp/. /temp/ 

Unmount the volume, and remount it on /tmp:

 # umount /dev/vgrp01/lvol01 # mount /dev/vgrp01/lvol01 /tmp 

Make sure things are what you expect, that nothing has changed within /tmp:

 # ls -a /tmp 

Unmount /tmp:

 # umount /tmp 

Add the information to your /etc/fstab, and run the following command to test the result. Based on this lab, add the following to /etc/fstab:

 /dev/vgrp01/lvol01   /tmp  ext3  defaults  0 0 

Then test the result; the following command mounts all filesystems listed in /etc/fstab:

 # mount -a 

Lab 5

5. 

In Lab 5, you'll increase the size of the new LV. First, run the df command to review the space taken by the current version of the LV. Unmount it from the directory you've configured. Use available free space from existing LVM partitions, or create a new LVM partition. Remount the newly expanded LV, and test the result. Are the files still there? What is the size of the new LV?

image from book

Answers

5. 

In this lab, you'll use free VG space from Lab 4. If you don't have that available, you'll have to repeat the steps described in Lab 4 to create a new PV and VG. To confirm available VG space, run the vgs command. In my case, I see the following output from my system:

 # vgs VG         #PV #LV #SN Attr   VSize   Vfree vgrp01       1   1   0 wz--n- 192.00M 92.00M 

As you can see, I have 92MB of free space, which I add to the existing LV with the following command:

 # lvextend -L +92M /dev/vgrp01/lvol01 



RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302)
Linux Patch Management: Keeping Linux Systems Up To Date
ISBN: 0132366754
EAN: 2147483647
Year: 2004
Pages: 227
Authors: Michael Jang

Similar book on Amazon
Linux Quick Fix Notebook
Linux Quick Fix Notebook
Self-Service Linux: Mastering the Art of Problem Determination
Self-Service Linux: Mastering the Art of Problem Determination
RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 & EX300), 6th Edition (Certification Press)
RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 & EX300), 6th Edition (Certification Press)
Security Strategies in Linux Platforms and Applications (Information Systems Security & Assurance)
Security Strategies in Linux Platforms and Applications (Information Systems Security & Assurance)

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net