Hp world/Interex 2002 Linux Partitions and Boot Loaders Red Hat Linux 2 23 lab: lvm for Linux




Дата канвертавання22.04.2016
Памер84.83 Kb.

HP World/Interex 2002



Linux Partitions and Boot Loaders
Red Hat Linux 7.2


23–1. LAB: LVM for Linux


Directions

In this lab, you are going to learn how to use the Logical Volume Manager for Linux.





1) Create two 1000MB primary partitions on any free disk space and set the type to LVM Linux (Hint: Hex Code 8e). Reboot your system (if fdisk requires). Create an initial LVM configuration file (/etc/lvmtab) with the vgscan command.
# fdisk /dev/hd@ (or /dev/sd@)

# reboot (if necessary)

# ll /etc/lvmtab

# vgscan


# ll /etc/lvmtab



2) Format the two 1000MB primary partitions for LVM usage using the pvcreate command and list the results using the pvdisplay command. Examine the contents of the LVM configuration file and directory (/etc/lvmtab.d). Create a LVM volume group called /dev/vglinux using the two LVM physical volumes and then reexamine the contents of the LVM configuration file and directory. List the contents of the /dev/vglinux directory. (Notice the creation of the character device file named group.) Display the LVM configuration for both physical volumes and the newly created volume group.
# pvcreate /dev/hd@1#

# pvdisplay /dev/hd@1#

# pvcreate /dev/hd@2#

# pvdisplay /dev/hd@2#

# strings /etc/lvmtab

# ll /etc/lvmtab.d

# ll /etc/lvmconf

# vgcreate /dev/vglinux /dev/hd@1# /dev/hd@2#

# strings /etc/lvmtab

# ll /etc/lvmtab.d

# ll /etc/lvmconf

# ll /dev/vglinux

# pvdisplay /dev/hd@1#

# pvdisplay /dev/hd@2#

# vgdisplay /dev/vglinux




3) Create a 100 MB logical volume called linus in the /dev/vglinux volume group using the lvcreate command. List the contents of the /dev/vglinux directory and display the LVM configuration for this logical volume. (Notice the creation of the block device file named linus.) Create a 100 MB logical volume called torvalds in the /dev/vglinux volume group. List the contents of the /dev/vglinux directory and LVM configuration for this logical volume. (Notice the creation of the block device file named torvalds.) Extend the linus logical volume to 200 MB using the lvextend command. Display the LVM configuration for this logical volume. (Explore the file structure of the /proc/lvm directory and display the contents of the /proc/lvm/global file.)
# lvcreate -L 100 -n linus vglinux

# ll /dev/vglinux

# lvdisplay /dev/vglinux/linus

# lvcreate -L 100 -n torvalds vglinux

# ll /dev/vglinux

# lvdisplay /dev/vglinux/torvalds

# lvextend -L +100 /dev/vglinux/linus

# lvdisplay /dev/vglinux/linus

# ls -lR /proc/lvm

# cat /proc/lvm/global





4) Create an ext3 file system on the linus logical volume in the /dev/vglinux volume group using the mkfs command and mount it to /mnt/linus directory. Create a device swap space on the torvalds logical volume in the /dev/vglinux volume group using the mkswap command and activate it at priority level one using the swapon command. Configure the file system to mount and the swap space to activate automatically on reboot. Reboot the system. (Look for a message informing you of the successfully initialization of the LVM driver during the reboot.)
# mkfs -t ext2 -j /dev/vglinux/linus

# mkdir /mnt/linus

# mount -t ext3 /dev/vglinux/linus /mnt/linus

# mount -v

# df

# mkswap /dev/vglinux/torvalds



# swapon -p 1 /dev/vglinux/torvalds

# swapon -s

# cat /proc/swaps

# vi /etc/fstab

. . . . . . .

/dev/vglinux/linus /mnt/linus ext3 defaults 1 3

/dev/vglinux/torvalds swap swap pri=3 0 0




5) Increase the size of the linus logical volume in the /dev/vglinux volume group to 300 MB using the lvextend command. Unmount the /mnt/linus file system. Extend the ext3 file system on the linus logical volume using the e2fsck and resize2fs command and then remount it to /mnt/linus directory. Confirm the size of the file system.
# lvextend -L 500 /dev/vglinux/linus

# umount /mnt/linus

# e2fsck -f /dev/vglinux/linus

# resize2fs /dev/vglinux/linus

# mount -a

# df




6) Create another 1000MB primary partition on any free disk space and set the type to LVM Linux (Hint: Hex Code 8e). Reboot your system (if fdisk requires). Format the 1000MB primary partition for LVM usage using the pvcreate command and list the results using the pvdisplay command. Extend the LVM volume group called /dev/vglinux using the newly created LVM physical volume. Display the LVM configuration for the new physical volume and the volume group. Create a 100 MB logical volume called redhat on the new physical volume in the /dev/vglinux volume group using the lvcreate command. Confirm the size and placement of the redhat logical volume on the new physical volume.
# fdisk /dev/hd@

# reboot (if necessary)

# pvcreate /dev/hd@3#

# pvdisplay /dev/hd@3#

# vgdisplay vglinux

# vgextend vglinux /dev/hd@3#

# pvdisplay /dev/hd@3#

# vgdisplay vglinux

# lvcreate -L 100 -n redhat vglinux /dev/hd@3#

# ll /dev/vglinux

# lvdisplay /dev/vglinux/redhat

# pvdisplay -v /dev/hd@3#





7) Remove the 100 MB logical volume called redhat from the /dev/vglinux volume group using the lvremove command. Remove the new physical volume from the /dev/vglinux volume group using the pvremove command. Confirm the removal of the redhat logical volume and the new physical volume. Deallocate the disk space that was being used by the removed physical volume using the fdisk command. Reboot your system (if fdisk requires).
# lvremove /dev/vglinux/redhat

# lvdisplay /dev/vglinux/redhat

# vgreduce vglinux /dev/hd@3#

# pvdisplay /dev/hd@3#

# fdisk /dev/hd@

# reboot (if necessary)


24–1. LAB: Configuring the LInux LOader (LILO)


Directions

In this lab, you are going to learn how to configure and install the LInux LOader (LILO).





1) Make a copy of the /etc/lilo.conf file and call it /etc/lilo.conf.orig. Create a recovery boot disk using the mkbootdisk command.
# cp /etc/lilo.conf /etc/lilo.conf.orig

# mkbootdisk –-device /dev/fd0





2) Edit the LILO configuration file (/etc/lilo.conf) to add “password=linux” to the global section of the boot loader. Apply the LILO boot loader changes by running the lilo command twice (first to test, then to apply you boot loader configuration). Reboot your system and select the default kernel. Does LILO require the password? (Yes) Reboot your system again and select the original RedHat kernel. Does LILO require the password? (Yes) Reboot your system once more and boot into single user mode using the default kernel. (You will need to type Ctrl + x at the RedHat logo boot list screen to get to a LILO boot: prompt and type in “linuxrev1 single”.) Does LILO require the password? (Yes)
# vi /etc/lilo.conf

prompt


timeout=50

default=linuxrev1

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

message=/boot/message

linear

password=linux
image=/boot/vmlinuz-2.4.7-10

label=linux

initrd=/boot/initrd-2.4.7-10.img

read-only

root=/dev/hda1
image=/boot/vmlinuz-2.4.7-10rev1

label=linuxrev1

initrd=/boot/initrd-2.4.7-10rev1.img

read-only

root=/dev/hda1
# lilo –t -v

# lilo -v

# reboot




3) Edit the LILO configuration file (/etc/lilo.conf) to add the word “restricted” to the global section of the boot loader. Apply the LILO boot loader changes by running the lilo command twice (first to test, then to apply you boot loader configuration). Reboot your system and select the default kernel. Does LILO require the password? (No) Reboot your system again and select the original RedHat kernel. Does LILO require the password? (No) Reboot your system once more and boot into single user mode using the default kernel. (You will need to type Ctrl + x at the RedHat logo boot list screen to get to a LILO boot: prompt and type in “linuxrev1 single”.) Does LILO require the password? (Yes)
# vi /etc/lilo.conf

prompt


timeout=50

default=linuxrev1

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

message=/boot/message

linear

password=linux



restricted
image=/boot/vmlinuz-2.4.7-10

label=linux

initrd=/boot/initrd-2.4.7-10.img

read-only

root=/dev/hda1
image=/boot/vmlinuz-2.4.7-10rev1

label=linuxrev1

initrd=/boot/initrd-2.4.7-10rev1.img

read-only

root=/dev/hda1
# lilo –t -v

# lilo -v

# reboot




4) Edit the LILO configuration file (/etc/lilo.conf) to remove the current “password=linux” and “restricted” entries in the global section of the boot loader and add “password=linux” to the default kernel boot block section of the boot loader. Apply the LILO boot loader changes by running the lilo command twice (first to test, then to apply you boot loader configuration). Reboot your system and select the default kernel. Does LILO require the password? (Yes) Reboot your system again and select the original RedHat kernel. Does LILO require the password? (No) Reboot your system once more and boot into single user mode using the default kernel. (You will need to type Ctrl + x at the RedHat logo boot list screen to get to a LILO boot: prompt and type in “linuxrev1 single”.) Does LILO require the password? (Yes)
# vi /etc/lilo.conf

prompt


timeout=50

default=linuxrev1

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

message=/boot/message

linear
image=/boot/vmlinuz-2.4.7-10

label=linux

initrd=/boot/initrd-2.4.7-10.img

read-only

root=/dev/hda1
image=/boot/vmlinuz-2.4.7-10rev1

label=linuxrev1

initrd=/boot/initrd-2.4.7-10rev1.img

read-only

root=/dev/hda1

password=linux
# lilo –t -v

# lilo -v

# reboot




5) Edit the LILO configuration file (/etc/lilo.conf) to add the word “restricted” to the default kernel boot block section of the boot loader. Apply the LILO boot loader changes by running the lilo command twice (first to test, then to apply you boot loader configuration). Reboot your system and select the default kernel. Does LILO require the password? (No) Reboot your system again and boot into single user mode using the default kernel. (You will need to type Ctrl + x at the RedHat logo boot list screen to get to a LILO boot: prompt and type in “linuxrev1 single”.) Does LILO require the password? (Yes)
# vi /etc/lilo.conf

prompt


timeout=50

default=linuxrev1

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

message=/boot/message

linear
image=/boot/vmlinuz-2.4.7-10

label=linux

initrd=/boot/initrd-2.4.7-10.img

read-only

root=/dev/hda1
image=/boot/vmlinuz-2.4.7-10rev1

label=linuxrev1

initrd=/boot/initrd-2.4.7-10rev1.img

read-only

root=/dev/hda1

password=linux



restricted
# lilo –t -v

# lilo -v

# reboot




6) Edit the LILO configuration file (/etc/lilo.conf) to remove the current “password=linux” and “restricted” entries in the default kernel boot block section of the boot loader and also remove the “prompt” and “timeout” entries in the global section of the boot loader. Apply the LILO boot loader changes by running the lilo command twice (first to test, then to apply you boot loader configuration). Reboot your system. Does LILO allow you to interact with the boot loader?
# vi /etc/lilo.conf

default=linuxrev1

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

message=/boot/message

linear
image=/boot/vmlinuz-2.4.7-10

label=linux

initrd=/boot/initrd-2.4.7-10.img

read-only

root=/dev/hda1
image=/boot/vmlinuz-2.4.7-10rev1

label=linuxrev1

initrd=/boot/initrd-2.4.7-10rev1.img

read-only

root=/dev/hda1
# lilo –t -v

# lilo -v

# reboot




7) Edit the LILO configuration file (/etc/lilo.conf) to add the “prompt” and “timeout” entries back in the global section of the boot loader and add an “alias=rev1” entry to the default kernel boot block section of the boot loader. Apply the LILO boot loader changes by running the lilo command twice (first to test, then to apply you boot loader configuration). Reboot your system and boot into single user mode using the default kernel using the alias. (You will need to type Ctrl + x at the RedHat logo boot list screen to get to a LILO boot: prompt. Type in the Tab key first to see the alias and then type in “rev1 single”.)
# vi /etc/lilo.conf

prompt


timeout=50

default=linuxrev1

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

message=/boot/message

linear
image=/boot/vmlinuz-2.4.7-10

label=linux

initrd=/boot/initrd-2.4.7-10.img

read-only

root=/dev/hda1
image=/boot/vmlinuz-2.4.7-10rev1

label=linuxrev1



alias=rev1

initrd=/boot/initrd-2.4.7-10rev1.img

read-only

root=/dev/hda1


# lilo –t -v

# lilo -v

# reboot




8) Edit the LILO configuration file (/etc/lilo.conf) to modify the root partition (“root=/dev/hda1”) entry in the global section of the boot loader to point to another partition (for example, the partition holding the /home file system). Apply the LILO boot loader changes by running the lilo command twice (first to test, then to apply you boot loader configuration). Reboot your system and select the default kernel. Does the system boot? (No) Power cycle the computer and boot the default kernel using the “root=” argument instructing LILO where to find the root partition. (You will need to type Ctrl + x at the RedHat logo boot list screen to get to a LILO boot: prompt and type in “linuxrev1 root=/dev/hda1”.)
# vi /etc/lilo.conf

prompt


timeout=50

default=linuxrev1

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

message=/boot/message

linear
image=/boot/vmlinuz-2.4.7-10

label=linux

initrd=/boot/initrd-2.4.7-10.img

read-only

root=/dev/hda1
image=/boot/vmlinuz-2.4.7-10rev1

label=linuxrev1

alias=rev1

initrd=/boot/initrd-2.4.7-10rev1.img

read-only

root=/dev/hda7
# lilo –t -v

# lilo -v

# reboot




9) Copy the /etc/lilo.conf.orig file back to the /etc/lilo.conf file. Apply the LILO boot loader changes by running the lilo command twice (first to test, then to apply you boot loader configuration). Reboot your system. Move the /sbin/init file to a backup location called /sbin/init.orig. Forcibly reboot the system using the reboot -f command. Does the system boot? (No) Turn the power off and then on (power cycle) the computer and boot the default kernel using the “init=” argument instructing LILO where to find a recovery shell. (You will need to type Ctrl + x at the RedHat logo boot list screen to get to a LILO boot: prompt and type in “linuxrev1 init=/bin/bash”.) Move the /sbin/init.orig copy back to the /sbin/init location. Did you succeed? (No) Remount the root (/) file system with read-write permission and then move the file. Did you succeed? (Yes) Reboot the system.
# cp /etc/lilo.conf.orig /etc/lilo.conf

# lilo –t -v

# lilo -v

# reboot
# mv /sbin/init /sbin/init.orig

# reboot -f

init-2.05# mv /sbin/init.orig /sbin/init (fails)

init-2.05# mount -n -o rw,remount /dev/hda1 /

init-2.05# mv /sbin/init.orig /sbin/init (succeeds)

init-2.05# /sbin/reboot





10) Move the /etc/inittab file to a backup location called /etc/inittab.orig. Forcibly reboot the system using the reboot -f command. Does the system boot? (No) Fix it.
# mv /etc/inittab /etc/inittab.orig

# reboot -f



init-2.05# mv /etc/inittab.orig /etc/inittab (fails)

init-2.05# mount -n -o rw,remount /dev/hda1 /

init-2.05# mv /etc/inittab.orig /etc/inittab (succeeds)

init-2.05# /sbin/reboot


24–2. LAB: Configuring the GRand Unified Boot loader (GRUB)


Directions

In this lab, you are going to learn how to configure and install the GRand Unified Boot loader (GRUB).





1) Change directory into /etc and examine the /etc/grub.conf file by executing the ls –l command. (Record the location of the actual file that this symbolic link points to.) Change directory into /boot/grub and display the contents of the grub.conf file. (Notice the peculiar syntax and file location of the GRUB boot loader and how only the original kernel was configured during the RedHat installation.) Run the info grub command for more details on the file syntax and grub utilities like grub, grub install, grub md5 crypt and grubby. Run the grub command and type in help at the grub> prompt. Run the other utilities with the –-help option to determine the expected syntax. Also, run RedHat’s new kernel pkg command with the –-help option to see how this command could replace the make install execution at the end of a kernel build to relocate the kernel (bzImage) to /boot AND automatically edit GRUB’s configuration file to boot that kernel.
# cd /etc

# ls -l /etc/grub.conf

lrwxrwxrwx 1 root root # grub.conf -> /boot/grub/grub.conf

# cd /boot/grub





# cat grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after



# making changes to this file

# NOTICE: You do not have a /boot partition. This means that

# all kernel and initrd paths are relative to /, eg.

# root (hd0,0)

# kernel /boot/vmlinuz-version ro root=/dev/hda1

# initrd /boot/initrd-version.img

#boot=/dev/hda

default=0

timeout=10

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title Red Hat Linux (2.4.7-10)

root (hd0,0)

kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda1

initrd /boot/initrd-2.4.7-10.img





# info grub

# grub


grub> help

grub> quit

# grub-install --help

# grub-md5-crypt --help

# grubby --help

# new-kernel-pkg --help





2) Edit /etc/grub.conf file to include the /boot/vmlinuz 2.4.7 10rev1 kernel. Install GRUB (replacing LILO) to the MBR using the grub install command. Reboot the system and select the /boot/vmlinuz 2.4.7 10rev1 kernel at the GRUB menu while rebooting.
# vi /etc/grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after



# making changes to this file

# NOTICE: You do not have a /boot partition. This means that

# all kernel and initrd paths are relative to /, eg.

# root (hd0,0)

# kernel /boot/vmlinuz-version ro root=/dev/hda1

# initrd /boot/initrd-version.img

#boot=/dev/hda

default=0

timeout=10

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title Red Hat Linux (2.4.7-10)

root (hd0,0)

kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda1

initrd /boot/initrd-2.4.7-10.img



title Red Hat Linux rev1 (2.4.7-10rev1)

root (hd0,0)

kernel /boot/vmlinuz-2.4.7-10rev1 ro root=/dev/hda1

initrd /boot/initrd-2.4.7-10rev1.img



# grub-install /dev/hda (or /dev/sda)

# reboot




3) Edit /etc/grub.conf file to include a GRUB boot loader password of “linux” using the grub md5 crypt command to allow for the password-protected editing of the configuration file at the boot loader menu. (No need to reinstall GRUB to the MBR using the grub install command because GRUB rereads the file during every boot which explains why its location is under /boot directory or separate file system.) Reboot the system and select the Red Hat Linux rev1 (2.4.7-10rev1) kernel entry and then press the p key at the GRUB menu typing the password “linux” when prompted. Edit the GRUB boot block entry by pressing the e key to add the word “single” to the end of the kernel line within the boot block and then press the b key to boot into single-user mode. (Notice the other single-key commands that are available: c key  to run grub, d key  to delete a line, o/O key  to open a new line below/above the current prompt line, ESC key  to return to the main menu.) Take the system to run level 5 using the init command at the single-user mode prompt.
# grub-md5-crypt

Password:linux

$1$7kN4H/$gmRo71ezjsMnYtnImNjke1
# vi /etc/grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after



# making changes to this file

# NOTICE: You do not have a /boot partition. This means that

# all kernel and initrd paths are relative to /, eg.

# root (hd0,0)

# kernel /boot/vmlinuz-version ro root=/dev/hda1

# initrd /boot/initrd-version.img

#boot=/dev/hda

default=0

timeout=10

splashimage=(hd0,0)/boot/grub/splash.xpm.gz



password --md5 $1$c1eHH/$nVm2vP8jxIC0RcKSQWIZJ.

title Red Hat Linux (2.4.7-10)

root (hd0,0)

kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda1

initrd /boot/initrd-2.4.7-10.img

title Red Hat Linux rev1 (2.4.7-10rev1)

root (hd0,0)

kernel /boot/vmlinuz-2.4.7-10rev1 ro root=/dev/hda1

initrd /boot/initrd-2.4.7-10rev1.img
# reboot
p KEY AND THEN THE e KEY AT THE GRUB MENU PROMPT>

Enter AND THE b KEY>




root (hd0,0)

kernel /boot/vmlinuz-2.4.7-10rev1 ro root=/dev/hda1 single

initrd /boot/initrd-2.4.7-10rev1.img
bash-2.05# init 5




4) Edit /etc/grub.conf file to include the /boot/vmlinuz 2.4.7 10rev1 kernel again (making it the default) by putting it between the original kernel and the single-user mode boot block that was just edited. Edit /etc/grub.conf file to include a GRUB boot loader password of “redhat” using the grub md5 crypt command to protect single-user mode access using the /boot/vmlinuz 2.4.7 10rev1 kernel. Reboot the system and test the password-protected access to single-user mode noticing the new default selection at the GRUB boot loader menu. Reboot the system again and observe GRUB booting the system without any human interaction.
# grub-md5-crypt >> /etc/grub.conf

redhat
(Don’t forget to delete the output-redirected “Password:” prompt at the bottom of the /etc/grub.conf file.)


# vi /etc/grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after



# making changes to this file

# NOTICE: You do not have a /boot partition. This means that

# all kernel and initrd paths are relative to /, eg.

# root (hd0,0)

# kernel /boot/vmlinuz-version ro root=/dev/hda1

# initrd /boot/initrd-version.img

#boot=/dev/hda

default=1

timeout=10

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

password --md5 $1$c1eHH/$nVm2vP8jxIC0RcKSQWIZJ.

title Red Hat Linux (2.4.7-10)

root (hd0,0)

kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda1

initrd /boot/initrd-2.4.7-10.img



title Red Hat Linux rev1 (2.4.7-10rev1)

root (hd0,0)

kernel /boot/vmlinuz-2.4.7-10rev1 ro root=/dev/hda1

initrd /boot/initrd-2.4.7-10rev1.img

title Red Hat Linux rev1 Single-User Mode (2.4.7-10rev1)

root (hd0,0)

kernel /boot/vmlinuz-2.4.7-10rev1 ro root=/dev/hda1 single



initrd /boot/initrd-2.4.7-10rev1.img

password --md5 $1$YheHH/$zbjPfzpco2D1VZUm.FzEz.
# reboot
bash-2.05# reboot



1-
U2794S A.00 http://education.hp.com

© 2002 Hewlett-Packard Company


База данных защищена авторским правом ©shkola.of.by 2016
звярнуцца да адміністрацыі

    Галоўная старонка