52890.fb2
There are thousands of different computer configurations, and thousands of different ways in which computers are used. The Fedora installer, Anaconda, is up to the challenge: although the default installation procedure is straightforward, Anaconda can also perform automated installations, set up complex storage layouts involving RAID and LVM, handle different types of installation media and network installation servers, and provide a rescue mode for the recovery of disabled systems.
This chapter deals with these advanced installation features. It also looks at GParted, a partition resizing tool, and GRUB, the bootloader used by Fedora that can be extensively customized.
Many computers are sold with some version of Microsoft Windows preinstalled, claiming the entire disk. In order to install Fedora in a dual-boot configuration, it is necessary to reduce the size of the Windows partition to free up some space.
Fedora does not provide a good tool for resizing Windows partitions. Fortunately, there is a very good open source tool available, GParted.
Always back up your data before adjusting partitions.
Download the 26 MB GParted LiveCD from http://gparted.sourceforge.net/livecd.php and burn it onto a CD or DVD. Insert the disc into the system to be resized, and then start (or restart) the system; the screen shown in Figure 10-1 will appear.
Figure 10-1. GParted LiveCD boot screen
You may need to adjust the BIOS boot options to force the system to boot from the disc.
Press Enter. The system will ask you to select your language, as shown in Figure 10-2 , and then to select the keyboard type, as shown in Figure 10-3 .
Figure 10-2. Language selection screen
Figure 10-3. Keyboard selection screen
The software will then prompt you for your display resolution, as shown in Figure 10-4 ; select the default unless you're using an old monitor.
Do not select 640x480 resolution; the GParted window will not fit on the screen.
Figure 10-4. Display resolution selection screen
You should also select the default for the display color depth, as shown in Figure 10-5 , unless you find that the default does not work with your system.
Figure 10-5. Display color-depth selection screen
The GParted screen in Figure 10-6 will now appear, displaying a list of all of the partitions on the first hard disk drive. If you wish to edit the partitions on another drive, click on the drive menu in the upper-right corner of the screen and select that drive.
Figure 10-6. GParted main window
Click on the partition that you wish to resize, and then click on the Resize/Move button at the top of the window. In the resizing dialog shown in Figure 10-7 , select the new size for the partition by dragging the end of the partition, by entering the new partition size, or by entering the amount of free space that you wish to have after repartitioning. Click Next.
Figure 10-7. Entering a new partition size
The resize option will appear in a list of queued tasks at the bottom of the main window. Click the Apply button at the top of the window, and then click Apply on the confirmation dialog shown in Figure 10-8 .
Figure 10-8. Pending-operations confirmation dialog
A progress display will appear while the partition is resized; click Close when the resize has finished.
Close the GParted window; then right-click on the display background and select Reboot.
The GParted LiveCD is a combination of open source software from several separate projects: the libparted partition-manipulation libraries from the GNU parted partition editor, filesystem-manipulation utilities from various filesystem projects, the GParted GNOME graphical parted interface, and a Live CD version of Slackware Linux.
The GParted LiveCD boots using a process very similar to the Fedora Core installation disc. Once the kernel and initrd (ramdisk) are loaded, startup scripts request the language, keyboard, resolution, and color-depth information, and then start Xvesa, a version of the X Window server that communicates with the graphics card through lowest-common-denominator standards set by the Video Electronics Standards Association (VESA). This enables the use of almost any modern video card in a low-performance mode (perfectly acceptable for this application) without requiring card-specific drivers.
The only application started is the GParted graphical interface, which communicates with other tools as necessary to perform requested tasks. Windows uses two different filesystem types: FAT32, a simple filesystem based on the original DOS 2.0 filesystem, and NTFS, an advanced filesystem with a database-like structure. Filesystem manipulation is handled by tools from the dosfstools and linux-ntfs packages. Then partition resizing is accomplished using the linux-ntfs tools or libparted libraries (depending on the partition type).
Those partitions are for system diagnostic software and for returning your system to a factory-fresh state, and are especially common on notebook computers. It is best to leave those partitions alone.
The GParted web site: http://gparted.sourceforge.net/
The parted web site: http://www.gnu.org/software/parted/
The linux-ntfs project: http://www.linux-ntfs.org/
The dosfstools distribution site: ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/
Fedora Core's default storage layout works well for many systems, but one approach doesn't suit all situations. The Anaconda installer lets you configure complex storage layouts incorporating RAID and LVM to suit advanced needs.
Back up any important data on your disk drive(s) before installing Fedora Core!
Be sure to read Chapter 6 before reading this lab.
Start a normal installation as described in Chapter 1 . When you get to the disk and partition strategy screen shown in Figure 10-9 , choose "Create custom layout" and select the checkbox for each of the disk drives that you wish to use.
Figure 10-9. Selecting a custom layout as the partitioning strategy
Click Next to proceed to the Disk Druid screen shown in Figure 10-10 , which gives an overview of the drive partitions in the top portion of the screen; the details of drive partitions, RAID devices, and LVM configuration in the lower portion of the screen; and action buttons in the center.
Figure 10-10. Disk Druid screen
Start by scrolling through the partition list in the lower half of the window. Delete any existing partition that you no longer want by clicking on the partition to select it and then clicking the Delete button; confirm the deletion in the warning dialog that appears.
The GRUB bootloader used by Fedora can boot only from simple disk partitions, not Logical Volumes or RAID stripes. However, when a RAID 1 (mirroring) array contains a filesystem, each partition that is an element of that array contains a full copy of the filesystem, and GRUB can boot from that.
Therefore, if you're using RAID levels other than RAID 1, or if you're using LVM, you must create a separate boot filesystem. The mount point for this filesystem is /boot , and the recommended size is 100 MB.
If you are not using RAID, create a small partition to hold the boot filesystem. In Disk Druid click the New button, which will bring up the Add Partition dialog shown in Figure 10-11 . Enter a mount point of /boot , deselect the checkboxes for all of the drives except the first one, and then click Next. This will create a 100 MB ext3 partition on the first disk drive.
Figure 10-11. Add Partition window
If you are using RAID, follow the steps in the next section to create a boot partition.
Table 10-1 shows RAID level recommendations for various numbers of disk drives. ( Table 6-3 describes the RAID levels supported by Fedora.)
Table 10-1. RAID recommendations based on the number of same-sized disk drives
# of disk drives | Possible RAID levels | Recoverable failure | Notes |
---|---|---|---|
1 | Cannot use RAID | None | |
2 | RAID 0 | None | Improves performance but also increases the risk of data loss. It provides storage capacity equal to two drives. |
RAID 1 | 1 drive | Provides storage capacity equal to one drive. This is the only RAID level that can be used for the /boot filesystem. | |
3 | RAID 5 | 1 drive | Provides storage capacity equal to two drives. |
4 or more | RAID 5 with no hot spares | 1 drive | Provides storage capacity equal to the number of drives minus one. |
RAID 5 with hot spare(s) | 1 drive at a time to a sequential maximum failure of 1 + the number of hot spares | Provides storage capacity equal to the number of drives minus the number of hot spares minus one. | |
RAID 6 with no hot spares | 2 drives | Provides storage capacity equal to the number of drives minus two. | |
5 or more | RAID 6 with hot spare(s) | 2 drives at a time to a maximum of 2 + the number of hot spares | Provides storage capacity equal to the number of drives minus the number of hot spares minus two. |
To create a RAID array (device), you must first create the partitions that will make up the elements of the array. Start by creating a RAID 1 boot partition of about 100 MB on each drive. Although it's tempting to create a giant RAID partition to use the rest of the space, I recommend that you divide the space on each drive into five partitions of roughly equal size. For example, if you are using 120 GB disk drives, create five partitions of 24 GB; if you are using 10 GB drives, create five partitions of 2 GB. Combine these partitions into five RAID arrays, each incorporating one partition from each drive, and then combine those five RAID arrays into a single volume group. The advantage to this approach is that it enables you to migrate to a different RAID level as long as a minimum of 20 percent of the VG space is free (see Lab 6.1, "Using Logical Volume Management ").
To create a partition to serve as a RAID array element, click the New button in Disk Druid's main window. The Add Partition dialog will appear, as in Figure 10-12 .
Figure 10-12. Adding a RAID partition
Another way to create a RAID partition is by clicking on the RAID button; the dialog in Figure 10-13 will appear, asking what you want to do next. Select the option "Create a software RAID partition" and click OK.
For the File System Type, select "software RAID." Deselect all of the Allowable Drives checkboxes except one to indicate the drive on which you wish to create the partition. Enter the Size in megabytes, and select "Fixed size." Click OK to proceed.
Repeat this process to create partitions for the other elements of the RAID array on other drives. For example, when creating a 2 GB RAID 1 array that spans two drives, create a 2 GB software RAID partition on each of the two drives.
Once you have created all of the partitions for the array, click the RAID button to view the RAID Options window, as shown in Figure 10-13 .
Figure 10-13. RAID Options window
Select the option to "Create a RAID device" and click OK. The Make RAID Device window will appear, as shown in Figure 10-14 .
Figure 10-14. Make RAID Device window
To use this RAID array as a boot filesystem, enter the mount point /boot , set the File System Type to ext3, set the RAID Level to RAID 1, and then select the checkboxes of the RAID partitions that will serve as elements of the array. Click OK to create the filesystem.
When creating a RAID array, use partitions that are exactly or almost exactly the same size because the size of the smallest element defines the amount of space that will be used in each of the elements; any differences between the size of the smallest element and the sizes of each of the other elements is wasted space.
To create a RAID array that will serve as a Physical Volume in an LVM Volume Group, set the File System Type to "Physical volume (LVM)," select the RAID Level, and select the checkboxes of the RAID partitions that will serve as elements of this array. Click OK to create the array.
Whether you're using RAID or not, LVM is the best way to set up partitioning: the overhead is minuscule, and the flexibility that it buys is valuable.
In order to configure LVM during installation, you need to create one or more partitions that will serve as physical volumes. There are two ways to do this:
Use RAID arrays as physical volumes, following the instructions in the previous section.
Use disk partitions as physical volumes. Click New in the Disk Druid main screen to access the Add Partition window ( Figure 10-11 ). Select "Physical volume (LVM)" for the File System Type, enter the partition size, and then click OK to create the partition.
It usually doesn't make sense to combine RAID and disk partition PVs in the same volume group because you will lose the data protection provided by the RAID array.
Once you have created the physical volumes, click the LVM button. The window shown in Figure 10-15 will be displayed.
Figure 10-15. Make LVM Volume Group window
Enter a descriptive volume group name, such as main for your primary volume group. The default physical extent size is 32 MB, which is a reasonable choice for most applications. If you have a good reason to use a different extent size, set it now because it cannot be easily changed after installation.
Reducing the physical extent size increases the size of the LVM data structures but gives a finer granularity for assigning storage to logical volumes. Increasing the physical extent size slightly reduces the LVM overhead, increasing performance.
Select the checkbox of all of the physical volumes you wish to use in this volume group.
The next step is to create a logical volume to hold each filesystem you wish to create. Table 10-2 contains a list of recommended filesystems.
Table 10-2. Recommended filesystems for Fedora Core
Mount point | Recommended size | Notes |
---|---|---|
/ | 10 GB | Required |
/home | 10 GB or more, depending on how much data your users will be personally storing | Strongly recommended for any system where users will be logging in on the console or via remote SSH access (e.g., desktop systems, servers with personal user accounts), and systems that are acting as file servers for personal files such as a Samba server (see Lab 7.1, "Configuring Samba to Share Files with Windows Systems"). By separating the users' home directories onto a separate filesystem, you can reinstall the operating system in the future without affecting users' files. |
/var | 2 GB to 1 TB depending on the applications in use | The /var filesystem holds data that is variable but that is not stored in the users' home directories for example, databases, email, web pages, and queued print requests. Creating a separate filesystem segregates it for backup and makes it easier to reinstall the operating system without affecting this data. |
To create each logical volume and filesystem, click the Add button at the bottom of the screen to access the Make Logical Volume window shown in Figure 10-16 .
Figure 10-16. Make Logical Volume window
Enter the chosen Mount Point and a descriptive logical volume name; then enter the desired size (leaving the File System Type set to the default, "ext3"). Click OK to return to the Make LVM Volume Group window; note that the LV size you entered is rounded to a multiple of the physical extent size in the Logical Volumes display.
Repeat this process for the other logical volumes.
It is best to leave some space within the VG unassigned so that you can use LVM snapshots and so that you can add space to a crowded filesystem without having to unmount another filesystem to reduce its size.
Finally, create a swap LV by clicking on the Add button in the Make LVM Volume Group window; when the Make Logical Volume window appears ( Figure 10-16 ), set the File System Type to "swap," and enter the desired swap size. Although traditional wisdom dictates a swap size twice as large as the system memory, it's reasonable to give a system with more memory less swapspace, and a system with less memory more swapspace. If in doubt, use the traditional figure as a starting point, since it can be changed later. The swapspace should be at least as large as the installed RAM (Disk Druid will warn you if it is not).
Once you have configured all of the logical volumes, click OK in the Make LVM Volume Group window, and then click Next in the main Disk Druid window. Proceed with the installation as outlined in Chapter 1 .
Like most of the Fedora system administration tools, Disk Druid (and Anaconda) are largely written in Python and interface with other open source tools such as parted , libparted , and lvm .
The purpose of Disk Druid is to improve the installation experience by taking care of many of the partitioning, RAID configuration, and LVM setup details automatically.
While other partitioning tools such as fdisk and parted require the user to keep track of partition numbers and starting and ending locations, and to use cylinders as a unit of measure, Disk Druid handles partition numbering automatically (even including drive selection, where appropriate).
On a PC, the first sector of each disk drive stores a Master Boot Record (MBR). The last 64 bytes of the MBR contain a partition table , which can hold a maximum of four entries; each entry contains a starting and ending cylinder number, boot flag, and partition type code. If more than four partitions are required, one of the MBR entries is configured to point to an extended partition , which contains its own extended partition table . The extended partition table can contain a maximum of one partition entry and one additional extended partition entry, both of which must be located within the extended partition. In this way, any number of partitions may be created.
There are many different types of disklabels , or disk partition table types, used on different types of systems. Of particular note for Fedora users is the fact that Mac systems use a different, more capable disk partition table. parted is able to display, create, and manipulate nine different types of disklabels, including those for IBM AIX Unix systems, Macs, PCs (called msdos in the parted documentation), Sun systems, and many others.
The manpages for parted , fdisk , lvm , and mdadm
The Anaconda project page: http://fedora.redhat.com/projects/anaconda-installer/
The Anaconda Wiki page: http://fedoraproject.org/wiki/Anaconda
The Fedora Core installation process is usually booted from CD or DVD, but it may also be booted from a USB flash disk or hard disk drive, or from a PXE boot server.
In addition, Fedora Core permits the use of an FTP or HTTP server as the package source during installation.
These alternate installation media must be specially prepared before use.
Before preparing alternate boot media, check that the target system can boot from the media you wish to use. Examine the BIOS of the system on which Fedora will be installed to see if it supports booting from a USB flash drive or a PXE server; if not, select a different installation medium.
To configure a USB drive for booting, download the USB boot image by selecting a mirror site from the web page http://fedora.redhat.com/Download/mirrors.html and going to that mirror with a web browser. Select the directory for the desired Fedora Core version number (e.g., 6 ), then the directory for your machine architecture ( i386 , PPC , or x86_64 ), then select the os directory, and then select the images subdirectory. Download the file named diskboot.img (you can also find this in the /images directory of the Fedora Core DVD or the first disc of the CD set).
The directory layout varies slightly among the mirror sites.
Once you have obtained the diskboot.img file, transfer it to your USB flash drive using a Linux system. First, insert the drive into the system; you should see an icon appear on the desktop.
This procedure will wipe out everything on your USB flash drive! Back up the drive contents before proceeding.
Use the df command to determine the drive's device name:
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/main-root
30G 14G 15G 48% /
/dev/md0 251M 41M 197M 18% /boot
/dev/shm 506M 0 506M 0% /dev/shm
/dev/mapper/main-home
14G 6.6G 7.0G 49% /home
/dev/mapper/main-var 65G 56G 8.0G 88% /var
/dev/hdb1 99M 24M 71M 26% /mnt/oldboot
/dev/hdb3 109G 75G 29G 73% /mnt/oldroot
/dev/hda6 14G 4.1G 8.5G 33% /mnt/x-root
/dev/sdb1 8.0M 6.4M 1.7M 80% /media/usbdisk1
In this case, the device name is /dev/sdb1 . Unmount that device:
# umount /dev/sdb1
(Notice that there is only one n in umount .)
Now copy the boot image to the USB flash drive:
# dd if=diskboot.img of= /dev/sdb1
16384+0 records in
16384+0 records out
Flush the system disk buffers to ensure that the data is written out to the drive before you unplug it:
# sync
The USB flash drive is now ready for booting. Insert the drive into the target system, turn it on, and use the BIOS options to specify that the system is to be booted from the USB drive; the rest of the process will be identical to booting from a CD or DVD.
When you're done using the drive to install Fedora Core, you'll find that it looks like an 8 MB drive, regardless of its actual drive capacity. To restore its full capacity, format it with a FAT32 filesystem:
# mkdosfs /dev/sdb1
mkdosfs 2.10 (22 Sep 2003)
You can use any FTP, HTTP, or NIS server for network installation, but of these three, HTTP is the easiest to set up and has the least overhead.
You'll need the full set of installation files. You can copy the entire contents of the DVD (or each of the five CDs) to a directory shared by your web server:
# mkdir /var/www/fedora
# cp -R /media/discname /var/www/fedora
Replace /media/diskname with the disc mount point (see the output of df ).
Instead of copying the files, you could leave the DVD in your drive (this won't work with CDs, since you need several of them) and create a symbolic link from your web server's document root to the DVD mount point:
# ln -s /media/ disk /var/www/html/fedora
Since the DVD's filesystem does not support file attributesnecessary to assign an SELinux contextyou will have to disable SELinux enforcement for HTTPD before using it to serve files from a DVD.
Alternatively, you can download the files directory to your web server directory. Go to the web page http://fedora.redhat.com/Download/mirrors.html , select an rsync , HTTP, or FTP mirror site for download, and download the entire distribution (all of the files and subdirectories in the os directory for your platform).
The directory layout varies from mirror to mirror. Use a browser to connect to your selected mirror site to confirm the directory names for the following commands.
On an existing Fedora Core system, you can do this by first creating a directory that is web-accessible:
# mkdir /var/www/fedora
Then fetch all of the files into that directory:
# cd /var/www/fedora
# wget -nH --cut-dirs= 4 -r http://less.cogeco.net/pub/fedora/linux/core/6/
Note that the URL here is taken from the mirror list, but has the Fedora Core release number ( 6 ) added to the end (replace this URL with that of a mirror close to you). The --cut-dirs= 4 option removes four leading directory names ( pub/fedora/linux/core ) from the retrieved files before saving them.
The downloaded tree will include the ISO files. If you'd rather not download them, use the -X option when you run wget :
# cd /var/www/fedora
# wget -nH -X '/*/*/*/*/*/*/iso' --cut-dirs= 4 -r \ http://less.cogeco.net/pub/fedora/linux/core/6/
(The \ indicates that the command continues on the next line; you can leave it out and type everything on one line.)
The downloaded directory indexes will be saved as files starting with index.html ; these can be deleted using the find command:
# find /var/www/fedora -name 'index.html*' -print -exec rm {} \;
The wget command can also be used with FTP sites:
# cd /var/www/fedora
# wget -X '/*/*/*/*/*/*/iso' -nH -X index.html --cut-dirs= 4 -r \ ftp://ftp.muug.mb.ca/pub/fedora/linux/core/5/
To fetch files from an rsync mirror, use the rsync command:
# cd /var/www/fedora
# rsync -v --recursive rsync://fedora.cat.pdx.edu/fedora-linux-core/4 .
Don't miss the . at the end of the line!
Ensure that the httpd service is started (see Lab 7.5, "Using the Apache Web Server "), and then start the installation on the target system using your choice of boot media (disc, PXE boot, or USB drive).
To configure a PXE boot server, you will need the tftp-server , xinetd , system-config-netboot , and dhcp packages. You will also need a working network installation server, as described in the previous section.
Before configuring a PXE Boot Server, confirm that the installation target machines use the PXE protocol for network booting.
To configure the PXE server, select the menu option System→Administration→Server Settings→Network Booting Service. The window shown in Figure 10-17 will be displayed.
Figure 10-17. Network boot-type selection
Click on the Network Install button, and the Network Installation Dialog in Figure 10-18 will appear.
Figure 10-18. Network Installation Dialog
Enter fc6 as the operating system identifier, type an easily readable description of the OS to be installed, select the protocol for installation, and then enter the IP address and the server directory in which the software is installed. Leave the Kickstart field blank (even if you're using a Kickstart file). Click OK to proceed.
You will now see the main window of the netboot configuration tool, shown in Figure 10-19 . This window is used to associate the operating system identifier of the configuration you just created ( fc6 ) with a particular range of IP addresses.
Figure 10-19. Main netboot configuration window
Click New to add a new IP entry in the dialog shown in Figure 10-20 . To configure one specific computer, enter that computer's hostname or IP address; to configure an entire subnet, enter the subnet.
Figure 10-20. Entering the netboot configuration for a new IP address or subnet
The format for entering the subnet is a bit unusual; you must enter just the network part of the address. For example, the IP address 172.16.97.32 with a netmask of 255.255.255.0 yields a network number of 172.16.97 and a host number of 32, so you would enter 172.16.97 into the IP Address Subnet field.
If you have created more than one network installation profile, select the correct value for the Operating System field. Enter the Kickstart URL, if any, into the Kickstart File field, and then click OK.
The main system-config-netboot window will show the new entry; you can now close the window.
The next step is to configure a DHCP server using the file /etc/dhcpd.conf . In addition to the regular configuration options, you will need to add one additional statement. If you don't otherwise need DHCP, use this minimal configuration file:
# /etc/dhcpd.conf file for PXE booting
ddns-update-style none;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.16 192.168.1.250 ;
filename "linux-install/pxelinux.0";
}
The additional statement (highlighted in bold) identifies the name of the file to be loaded via TFTP. linux-install/pxelinux.0 is the Linux bootloader; the path is relative to /tftpboot on the server.
You can run the DHCP and TFTP servers on different machines if you add a next-server line to the DHCP configuration:
next-server 192.168.1.3;
This configures the next phase of the boot process to use the TFTP server at the IP address 192.168.1.3.
Do not run more than one DHCP server on your LAN. If you have a DHCP server on a router or gateway device, disable it while using the PXE boot server.
Finally, configure the tftp Xinetd service and start the xinetd and dhcpd services (see Lab 7.2, "Configuring a DHCP Server ").
To use the PXE boot server, start the target system and select Network Boot using the BIOS options. A boot display similar to that shown in Figure 10-21 should appear.
Figure 10-21. PXE boot process
The system will then proceed with the normal Fedora Core installation process.
All Fedora Core boot media use one of the bootloaders from the isolinux / syslinux / pxelinux family. These programs have been specifically tailored for booting from optical disk, removable disk drives, and PXE boot servers. Each of them uses text files to configure the available boot options.
The USB boot image diskboot.img is a complete image of a bootable 8 MB VFAT (MS-DOS FAT with long filenames) filesystem. This filesystem contains the isolinux bootloader, the kernel, the initrd ramdisk image, and configuration files.
The Intel Preboot Execution Environment (PXE) specification is used for network booting of Fedora systems. The PXE boot process uses the pxelinux bootloader, which is retrieved from /tftpboot/linux-install/pxelinux.0 on the TFTP server. Once it is running, pxelinux searches for an appropriate configuration file in /tftpboot/linux-install/pxelinux.cfg , first trying for a file named with the hardware MAC address of the target system's Ethernet adapter, then a series of filenames generated from the target's IP address written in hexadecimal, and then finally the file default .
The system-config-netboot tool is executed when you select the menu option System→Administration→Server Settings→Network Booting Service. It creates a file in /tftpboot/linux-install/pxelinux.cfg named according to the network address specified in the GUI. For example, if the user specifies a certain configuration for the IP network 192.168.1, the configuration is stored in the file /tftpboot/linux-install/pxelinux.cfg/C0A801 because 192.168.1 in decimal corresponds to C0A801 in hexadecimal.
system-config-netboot obtains the pxelinux bootloader, Linux kernel, and initrd files from the specified network installation server (the pxelinux bootloader is found in the /images directory on the network installation server).
A network installation server is not intended to provide boot files for the installation, so its only purpose is to provide the package files and other information needed to install Fedora Core after the installation environment has loaded. While FTP, NFS, and HTTP are all available, NFS and FTP use multiple ports (NFS actually relies on multiple server programs), whereas HTTP uses a single server on a single port.
It is possible to install directly from a public Fedora Core HTTP or FTP mirror; simply enter the mirror URL as the server for the HTTP or FTP installation methods. However, doing so generates a lot of Internet traffic, resulting in a long installation time, and the likelihood of a network error aborting the entire installation partway through is higher than it would be on a local LAN. If you are going to install more than once, it's a better idea to download the files onto a local machine for speed.
The normal Fedora Core CD 1 is too large to fit on a mini-CD, but the boot image in /images/boot.iso on that CD (or the Fedora Core mirror servers) is under 8 MB in size and will easily fit on an 8 cm mini-CD or a "business card" CD.
Unfortunately, the Fedora Core installation boot files are now too large to fit on a 1.44 MB floppy disk. However, you may be able to use the 8 MB USB disk image file ( diskboot.img ) with a larger removable disk, such as a Zip or LS-120 disk.
Although system-config-netboot is recommended for PXE configuration, you can also use the pxeos and pxeboot commands to configure PXE from the command line.
To configure a version of Fedora Core for PXE booting:
# pxeos -a -i " Fedora Core 6 " -p HTTP -D 0 -s 192.168.1.2 -L /fedora fc6
These are the arguments used:
-a
Add to the existing configuration
-i " Fedora Core 6 "
The descriptive identification for this entry
-p HTTP
Installation protocol (can be HTTP , FTP , or NFS )
-D 0
Sets this up as an installation instead of a diskless boot
-s 192.168.1.2
The HTTP, FTP, or NFS server address
-L /fedora
The pathname on the server; in this example, the -p , -s , and -L options combine to be equivalent to http://192.168.1.2/fedora
fc6
The operating system identifier
To configure specific hosts to use the fc6 boot image:
# pxeboot -a -O fc6 192.168.1
This will configure all hosts that have an IP address beginning with 192.168.1 to use the fc6 configuration. To configure the use of a Kickstart file (see the next lab), add the option -K followed by the Kickstart URL.
The manpages for dd , httpd , mkdosfs , rsync , wget , system-config-netboot , dhcpd , dhcpd.conf , tftpd , pxeos , and pxeboot
The HTML documentation for system-config-netboot : file:///usr/share/doc/system-config-netboot-0.1.38/index.html
The syslinux home page (which includes the isolinux and pxelinux bootloaders): http://syslinux.zytor.com/
The Intel PXE specification: http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf
In a normal Fedora Core installation, Anaconda asks a number of questions before beginning the actual installation procedure, which then runs without any user intervention (except for changing CDs, if that is the chosen installation method).
Kickstart is a Fedora installation option that uses a text file to supply basic configuration information so that Anaconda can skip all of the questions normally asked during installation.
To use Kickstart, you must create a Kickstart file using any regular text editor. A Kickstart file contains a number of options, one per line, with arguments.
These options are required:
auth or authconfig
Configures the authentication system. For normal password authentication, use the arguments --enableshadow --enablemd5 .
bootloader
The GRUB installation location and password. For an upgrade, use --upgrade ; for a new installation, use --location=mbr --md5pass= encryptedpassword (I cover how to generate encrypted passwords shortly).
lang
Selects the language to be used during installation. Possible values are listed in /usr/share/system-config-language/locale-list ; for U.S. English, use the argument en_US .
keyboard
The keyboard type to be used. Specify us for a standard North American English keyboard, or use one of the codes found in /usr/lib/python2.4/site-packages/rhpl/keyboard_models.py (such as cf for Canadian French).
rootpw
The root password. Use the arguments --iscrypted encryptedpassword .
timezone
The time zone for the system. The third column of /usr/share/zoneinfo/zone.tab lists possible values, such as America/Toronto or Asia/Shanghai . Add the argument --utc if the system clock is in UTC (recommended except when the system is dual-boot and you are in a time zone that has daylight savings time).
To encrypt a password for the bootloader and root access, use the openssl command:
$ openssl passwd -1 -salt " RaNDoMjuNk " " MySecretPassword "
$1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1
Replace RaNDoMjuNK with any garbage characters you want to use, and MySecretPassword with the desired password. Cut and paste the result into the Kickstart file as the encrypted password.
Here is a basic configuration using these options:
auth --enableshadow --enablemd5
bootloader --location=mbr --md5pass=$1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1
lang en_US
keyboard us
rootpw --iscrypted $1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1
timezone America/Toronto
Next, specify the installation source and networking:
cdrom
Installation from the first optical disk drive on the system (CD or DVD).
url
HTTP or FTP installation. Use the argument --url http: // host/directory or --url ftp:// host/directory to specify the location of the installation files.
nfs
NFS installation. Use --server= ip_address and --dir= directory to specify the server host and directory that contain the installation files.
harddrive
Installation from a VFAT or ext2/ext3 partition on a local hard drive. Use the arguments --partition= partitionId and --dir= /directory to specify the location of the installation files. The partitionId must be one of the hard drive device names from Table 1-4 , with the partition number appended without the /dev/ directory (for example, hda2 for partition 2 on the IDE/ATA primary slave drive).
network
Configures IP networking for the installed system. If the system already has networking enabled (for example, because it booted from a PXE server), then that configuration is used for the rest of the installation, but if no network configuration has been set up for the installation and one is required, this configuration is used.
The argument --bootproto= method sets the network configuration method: dhcp , bootp , or static . If you specify static , use the options --ip= ip_address --netmask= subnetmask --gateway= router_ip --nameserver= nameserver_ip to configure the network interface. If you have more than one network interface, use the --device= devicename option; to configure the interface to be inactive at boot, use --onboot=off .
Note that the directory specified for the url or nfs options must contain the fedora directory of the installation tree; in other words, it must be equivalent to the root directory of the Fedora Core CD or DVD.
To specify HTTP as the installation method on a system with two network interfacesone configured with DHCP and one with a static IPuse a configuration like this:
url --url=http://192.168.1.2/fc6/
network --bootproto=dhcp --device eth0
network --bootproto=static --device eth1 \
--ip 10.2.97.33 --netmask=255.255.255.0
If a Kickstartoption line ends with \, it is continued on the next line.
If you are using Kickstart to perform an upgrade instead of an installation, use the upgrade option. Otherwise, use these options to lay out the storage:
zerombr
Clears any invalid partition tables. Use this option with just one argument: yes .
autopart
Sets up the default partition structure, which includes a /boot filesystem and a volume group with logical volumes for swap and the root filesystem. If part options are also present, they will selectively override the default setup for the same mount point.
clearpart
Clears existing partition table entries. Use the argument --all to clear all partitions, --linux to clear all Linux partitions, --drives= drive1,drive2 to specify the drive or drives to be cleared, and --initlabel to enable the creation of disk labels (partition tables) on empty drives.
part or partition
Creates a disk partition. Provide an option identifying the mount point (such as /boot ) or one of the keywords swap , raid. NN , or pv. NN , where NN is a RAID or physical volume number (0199). Then use the arguments --size= size and --maxsize= maxsize to set the minimum and maximum partition sizes in megabytes, and --grow to indicate that the filesystem can be expanded to fill the maximum size if it is specified (or all of the remaining free space if a maximum is not specified). --ondrive= drive can be used to force the use of a particular drive; use drive names from Table 1-4 . Use --fstype= filesystem to configure the filesystem type ( ext2 , ext3 , or vfat ).
raid
Creates a RAID device from partitions defined with the part option. Use the argument --level= raidlevel to set the RAID level to 0 , 1 , 5 , or 6 , and the argument --device= devicename to set the RAID device name (such as md0 or md12 ). If the array will have hot spares, specify the number of hot spares with the argument --spares= S . Set the filesystem type with --fstype= filesystem , and then list the mount point (or swap for a swap device, or pv. NN for physical volume number NN ). Finally, list the partition names ( raid. NN ) that will make up the elements of this array.
volgroup
Creates a volume group. Supply the volume group name (such as main ) and a list of physical volumes ( pv. NN ) as arguments.
logvol
Creates a logical volume. Use the --vgname= volumegroup argument to select the volume group, --size= size to set the LV size in megabytes, and --name= lvname to set the name. Specify the mount point (or swap for a swap partition) as a separate argument.
For example, if you had a system with two 200 GB disks (as the master IDE/ATA drives on the primary and secondary disk controllers) with RAID 1 and LVM (see Lab 6.2, "Managing RAID "), the storage layout options would look like this:
# General partitioning options
clearpart --all --initlabel --drives=hda,hdc
zerombr yes
# Partitions
# Two IDE disk drives, hda and hdc
part raid.01 --size 100 --ondrive=hda
part raid.02 --size 40000 --ondrive=hda
part raid.03 --size 40000 --ondrive=hda
part raid.04 --size 40000 --ondrive=hda
part raid.05 --size 40000 --ondrive=hda
part raid.06 --size 1 --ondrive=hda --grow
part raid.07 --size 100 --ondrive=hdc
part raid.08 --size 40000 --ondrive=hdc
part raid.09 --size 40000 --ondrive=hdc
part raid.10 --size 40000 --ondrive=hdc
part raid.11 --size 40000 --ondrive=hdc
part raid.12 --size 1 --ondrive=hdc --grow
# RAID arrays
# Six RAID arrays, all RAID 1:
# - one is 100 MB /boot array
# - five are 40GB PV arrays
# (4 * 40000 MB, remaining space in last array)
raid /boot --device md0 --level=RAID1 raid.01 raid.07 --fstype ext3
raid pv.01 --device md1 --level=RAID1 raid.02 raid.08
raid pv.02 --device md2 --level=RAID1 raid.03 raid.09
raid pv.03 --device md3 --level=RAID1 raid.04 raid.10
raid pv.04 --device md4 --level=RAID1 raid.05 raid.11
raid pv.05 --device md5 --level=RAID1 raid.06 raid.12
# Volume Group 'main'
volgroup main pv.01 pv.02 pv.03 pv.04 pv.05
# LVs for root (10GB), /home (35GB), /var (35GB), and swap (1GB),
# leaving about 20 GB available for snapshots and future expansion
# of the LVs
logvol swap --vgname=main --size=1024 --name=swap
logvol / --vgname=main --size=10000 --name=root --fstype=ext3
logvol /home --vgname=main --size=35000 --name=home --fstype=ext3
logvol /var --vgname=main --size=35000 --name=var --fstype=ext3
You can now specify the user interface mode during installation:
text
Install in full-screen text mode.
cmdline
Install in text mode without the full-screen display.
interactive
Present the normal interactive prompts at the start of the installation process, but use the values from the Kickstart file as the defaults. The user can then override the values.
autostep
Run through the interactive prompts automatically, like a slideshow; this may be helpful for debugging.
You can also include instructions on how the final user interface is to be configured:
skipx
Don't configure the X Window System.
xconfig
Although you can specify many arguments for the X Window configuration, in most cases it's best to let Anaconda discover your hardware configuration by probing. Set the screen resolution with --resolution= WxH , and set the maximum color depth with --depth=24 . To configure the system to start in runlevel 5 instead of runlevel 3 (see Lab 4.5, "Using Runlevels "), use the argument --startxonboot .
Putting these options together for a text based, hands-off installation configured so that the installed system will start up with a graphical login prompt (1024x768 resolution, 16-million-color display), use:
text
xconfig --startxonboot --depth=24 --resolution=1024x768
Next comes security:
firewall
Configures the network firewall. Use --enabled to turn the firewall on or --disabled to turn it off. If you have multiple network interfaces and don't want to firewall some of them, use a --trust= ethN argument for each unprotected interface. To permit connections on particular ports, use the argument --port= port:proto,port:proto , or select a combination of the abbreviations --http , --smtp , --ftp , --telnet , and --ssh .
selinux
Disables SELinux if used with the --disabled argument, or produces warning messages but does not enforce security policy if --permissive is specified.
This is a typical configuration:
firewall --enabled --port=5900:tcp --ssh --http --smtp
TCP port 5900 is the port used for VNC.
You can now specify what should happen after the installation is complete:
firstboot
Enables the interactive post-installation configuration during the first boot of the new system. Normally, this is not performed after a Kickstart installation. Use the --enable option to enable a normal first-boot session or --reconfig to enable additional settings to be changed (including the keyboard, language, and network settings).
poweroff
Turns the system off after installation (if the system can be turned off by the kernel).
halt
Halts the system after installation but doesn't turn the power off.
reboot
Restarts the computer after installation. If the installation media is still present or you used PXE booting to start the installation process, this may lead to an endless cycle of installations.
To shut the system down and allow for reconfiguration when the system is first turned on, use:
firstboot --reconfig
poweroff
At the very end of the Kickstart file, place the option %packages , followed by a list of packages to be installed, one per line. To see the available package names, look in the Fedora directory of the installation tree (e.g., the installation DVD or network installation server). Instead of selecting packages individually, you can choose groups of packages as shown in Table 10-3 .
Table 10-3. Package groups available in Fedora Core 6
Category | Available package groups |
---|---|
Desktop environments | @gnome-desktop @kde-desktop |
Applications | @authoring-and-publishing @editors @engineering-and-scientific @games @graphical-internet @graphics @office @sound-and-video @text-internet |
Development | @development-libs @development-tools @eclipse @gnome-software-development @java-development @kde-software-development @legacy-software-development @ruby @x-software-development |
Servers | @dns-server @ftp-server @legacy-network-server @mail-server @mysql @network-server @news-server @printing @server-cfg @smb-server@ sql-server @web-server |
Base system | @admin-tools @base @base-x @dialup @dns-server @java @legacy-software-support @system-tools |
Languages | @arabic-support @assamese-support @bengali-support @bulgarian-support @chinese-support @croatian-support @czech-support @estonian-support @gujarati-support @hebrew-support @hindi-support @hungarian-support @japanese-support @korean-support @polish-support @punjabi-support @romanian-support @russian-support @serbian-support @slovak-support @slovenian-support @tamil-support @thai-support @ukrainian-support |
Use * to select all available packages (dependencies and conflicts permitting). On the other extreme, use the special package group @core to install a very minimal, text-based system (almost too small to be usable but a good starting point for very compact systems) or @base to install a small text-based system with enough basic software to be useful.
To exclude a package, prepend a minus sign:
-hdparm
For example, if you wanted GNOME, office applications, Samba, printing capability, support for Russian, the GIMP graphics editor, and the Tomboy note program, place these lines at the end of the Kickstart file:
%packages
@gnome-desktop
@office
@smb-server
@printing
@russian-support
gimp
tomboy
Putting this all together, we get this Kickstart file:
auth --enableshadow --enablemd5
bootloader --location=mbr --md5pass=$1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1
lang en_US
keyboard us
rootpw --iscrypted $1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1
timezone America/Torontourl --url=http://192.168.1.2/fc6/
url --url=http://192.168.1.2/fc6/
network --bootproto=dhcp --device eth0
network --bootproto=static --device eth1 \
--ip 10.2.97.33 --netmask=255.255.255.0
# General partitioning options
clearpart --all --initlabel
zerombr yes
# Partitions
# Two IDE disk drives, hda and hdc
part raid.01 --size 100 --ondrive=hda
part raid.02 --size 40000 --ondrive=hda
part raid.03 --size 40000 --ondrive=hda
part raid.04 --size 40000 --ondrive=hda
part raid.05 --size 40000 --ondrive=hda
part raid.06 --size 1 --ondrive=hda --grow
part raid.07 --size 100 --ondrive=hdc
part raid.08 --size 40000 --ondrive=hdc
part raid.09 --size 40000 --ondrive=hdc
part raid.10 --size 40000 --ondrive=hdc
part raid.11 --size 40000 --ondrive=hdc
part raid.12 --size 1 --ondrive=hdc --grow
# RAID arrays
# Six RAID arrays, all RAID 1:
# - one is 100 MB /boot array
# - five are 40GB PV arrays
# (4 * 4000 MB, remaining space in last array)
raid /boot --device md0 --level=RAID1 raid.01 raid.07 --fstype ext3
raid pv.01 --device md1 --level=RAID1 raid.02 raid.08
raid pv.02 --device md2 --level=RAID1 raid.03 raid.09
raid pv.03 --device md3 --level=RAID1 raid.04 raid.10
raid pv.04 --device md4 --level=RAID1 raid.05 raid.11
raid pv.05 --device md5 --level=RAID1 raid.06 raid.12
# Volume Group 'main'
volgroup main pv.01 pv.02 pv.03 pv.04 pv.05
# LVs for root (10GB), /home (35GB), /var (35GB), and swap (1GB),
# leaving about 20 GB available for snapshots and future expansion
# of the LVs
logvol swap --vgname=main --size=1024 --name=swap
logvol / --vgname=main --size=10000 --name=root --fstype=ext3
logvol /home --vgname=main --size=35000 --name=home --fstype=ext3
logvol /var --vgname=main --size=35000 --name=var --fstype=ext3
text
xconfig --startxonboot --depth=24 --resolution=1024x768
firewall --enabled --port=5900:tcp --ssh --http --smtp
firstboot --reconfig
poweroff
%packages
@gnome-desktop
@office
@smb-server
@printing
@russian-support
gimp
tomboy
To use a Kickstart file, make it accessible to the installation target system by placing it on an HTTP, FTP, or NFS server, or put it on a floppy disk.
To use a Kickstart file on floppy disk, add ks=floppy to the boot string encountered when booting from a USB key or optical disc:
: linux ks=floppy
It is assumed that the Kickstart file is named ks.cfg , that it is in the root directory of the floppy disk, and that the floppy disk is formatted with an MS-DOS ( VFAT) or ext2 filesystem.
To make the Kickstart file available through the web server on a Fedora Core system, use these commands (assuming that the file is named ks.cfg and is in the current directory):
# mkdir -p /var/www/ kickstart
# cp ks.cfg /var/www/ kickstart
You can then access the Kickstart file by URL at the installation boot prompt:
: linux ks=http:// 192.168.1.2 /kickstart/ks.cfg
(Replace 192.168.1.2 with the actual address of your server.) However, when booting from a PXE boot server, no boot prompt is provided. Instead, you must configure the Kickstart file by entering the URL into the system-config-netboot window for a particular IP address or range ( Figure 10-20 ) or using the -K argument to the pxeboot command:
# pxeboot -a -O fc6 192.168.1 -K http://192.168.1.2/kickstart/ks.cfg
Fedora's Anaconda installer is written in Python and uses a library called the Red Hat Python Library, or rhpl . Before commencing the installation process, Anaconda must load the data structures that control the installation. These data structures can be filled with data from user input or from the Kickstart file.
Fedora Core provides the system-config-kickstart utility for graphically editing a Kickstart file. Unfortunately, the version of system-config-kickstart shipped with Fedora Core 6 has some show-stopping bugs that cause it to create defective Kickstart files, and it is not able to configure LVM systems. However, you can use it to create a rough Kickstart file to use as a starting point for further customization.
Kickstart files can include a script that is run before installation, and the output of that script can be included into the Kickstart configuration.
For example, to configure swapspace to be double the memory size, you can add this script to the Kickstart file:
%pre
# Calculate twice the size of the installed memory, in MB
MEM=$(cat /proc/meminfo|sed -n "s/MemTotal: *\([0-9]\+\) kB/\1/p")
SIZE=$(( $MEM * 2 / 1024 ))
# Create the file /tmp/swap.cfg
echo "logvol swap --vgname=main --size=$SIZE --name=swap" >/tmp/swap.cfg
The %pre option identifies this part of the file as a preinstallation script. Place this script at the end of the Kickstart file; it will produce the file /tmp/swap.cfg containing the appropriate logvol line for the swap partition.
You can then replace the swap partition line in the Kickstart file with an option that refers to the /tmp/swap.cfg file using %include :
# LVs for root (10GB), /home (35GB), /var (35GB), and swap (RAM * 2),
# leaving about 20 GB available for snapshots and future expansion
# of the LVs.
%include /tmp/swap.cfg
logvol / --vgname=main --size=10000 --name=root --fstype=ext3
logvol /home --vgname=main --size=35000 --name=home --fstype=ext3
logvol /var --vgname=main --size=35000 --name=var --fstype=ext3
Preinstallation scripts cannot change the installation source.
The Kickstart file can also include a script that is run after installation, using the %post option. Here is an example:
% post
# Add aliases to /etc/bashrc:
echo "alias l='ls -l'" >>/etc/bashrc
echo "alias cls='clear'" >>/etc/bashrc
# Change the login welcome message for text consoles
echo "Welcome to Fedora Core!" >/etc/issue
# Place a copy of acceptable-use-policy.txt
# in /etc/skel so that it will be copied to each
# new user's home diretory.
cd /etc/skel
wget http://192.168.1.2/text/acceptable-use-policy.txt
# Configure httpd to start automatically on boot
/sbin/chkconfig httpd on
Post-installation scripts cannot reliably use hostnames; any IP addresses must be specified numerically.
Whenever you install a system, the configuration used for that system is written into the file /root/anaconda-ks.cfg . This is a standard Kickstart file with the disk layout commented out (every line has a # prepended). If you uncomment the disk layout and then use this as the Kickstart file for another system, it will produce an identical configuration (note that the hardware must be sufficiently similar for this to work).
The RHEL 4 System Administration Guide (see Chapter 1; RHEL uses a version of Anaconda similar to that used by Fedora): http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/sysadmin-guide/
"Hands-Off Fedora Installs with Kickstart," by Ethan McCallum: http://www.linuxdevcenter.com/pub/a/linux/2004/08/19/kickstart.html
The Fedora Wiki page with information on Kickstart: http://fedoraproject.org/wiki/AnacondaKickstartIntegration
GRUB is a powerful bootloader that can be used to boot Linux, Windows, DOS, and other operating systems as well as the Xen virtualization system. By mastering its configuration file and command-line options, you can configure GRUB to boot exactly the way you want.
GRUB is configured through the file /boot/grub/grub.conf ; typical contents of this file look like this:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/main/root
# initrd /initrd-version.img
#boot=/dev/hda
default= 0
timeout= 5
splashimage= (hd0,1)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.31-1.3420_fc6)
root (hd0,1)
kernel /vmlinuz-2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
initrd /initrd-2.6.31-1.3420_fc6.img
title Other
rootnoverify (hd0,0)
chainloader +1
This configuration file specifies two menu options, identified by the title keywords: Fedora Core and Windows (which Anaconda labels Other by default). Lines that start with a pound sign are comments. The first lines after the initial comments set up the appearance of the bootloader at startup time:
default= 0
Configures the first title enTRy as the default entry (they are numbered starting at 0 )in this case, Fedora Core.
timeout= 5
Sets the delay in seconds before the default entry is booted.
splashimage=( hd0,1)/grub/splash.xpm.gz
Loads a graphical background for the boot display.
hiddenmenu
Does not display the boot menu unless the user presses a key during the timeout period, in which case all of the available operating system entries are shown.
The filename given in the splashimage line is in a special, GRUB-specific form: (hd0,1) specifies the first hard disk, second partition ( /dev/hda2 in Linux terminology), and /grub/splash.xpm.gz identifies the pathname on that drive. Because /dev/hda1 is normally mounted on /boot , the full pathname within the Fedora system is /boot/grub/splash.xpm.gz .
GRUB numbers partitions starting at 0, while Linux numbers them starting at 1.
The remainder of this file configures the two menu options. The first one consists of these four lines:
title Fedora Core (2.6.31-1.3420_fc6 )
root (hd0,1)
kernel /vmlinuz-2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
initrd /initrd-2.6.31-1.3420_fc6.img
Each line provides specific information:
title Fedora Core (2.6.31-1.3420_fc6)
The title displayed on the menu. The number in parentheses is the kernel version number; since it's standard practice to keep the second-most-recent kernel installed when the kernel is updated, just in case the new kernel does not boot properly, this information enables you to identify which kernel is newer.
root (hd0,1)
The root filesystem for the boot process, written using GRUB notation. Note that this may not be the root directory of the Fedora Core installation; it's usually the filesystem mounted at /boot when the system is running.
kernel /vmlinuz-2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
The kernel location within the root filesystem, plus boot options. These boot options specify that the root filesystem for Linux is /dev/main/root (logical volume root in volume group main ), and the root filesystem will be mounted read-only ( ro ), that the Red Hat Graphical Boot ( rhgb ) display is enabled, and that noncritical kernel boot messages will be suppressed ( quiet ).
initrd /initrd-2.6.31-1.3420_fc6.img
The location of the initrd ramdisk file. This file contains a compressed filesystem image that contains all of the files other than the kernel necessary for the initial phases of the Fedora system startup, including device drivers, programs, and scripts.
The other title entry is simpler:
title Other
rootnoverify (hd0,0)
chainloader +1
The lines in this entry invoke the Windows Stage 2 bootloader, found at the start of the Windows partition:
rootnoverify (hd0,0)
Similar to the root option in the Fedora Core entry, except that this partition will not be mounted, and therefore files cannot be accessed within the partition by GRUB.
chainloader +1
Specifies that the boot process should be turned over to the bootloader found in sector 1 of the partition.
You can directly edit the GRUB configuration file to change the appearance of the boot process.
To eliminate the boot menu entirely and directly boot the default entry, set the timeout value to zero:
timeout=0
This is a useful setting for end-user, single-boot systems with a stable kernel. On the other hand, if you have several operating systems installed, it may be convenient to remove the hiddenmenu line and use a longer timeout:
timeout=20
To turn the timeout off and wait indefinitely for the user to select the operating system, remove the timeout line from the file.
You can also customize or replace the boot image to include your company logo or a personalized message.
Use the GIMP graphics editor to create a 640x480 image. Reduce the number of colors by using the GIMP menu option Image→Mode→Indexed and selecting 14 colors.
When converting an existing image to 14 colors, the result may look better if you select the No Dithering option, especially if the original image contains large areas of solid color. If you are creating a new image, select the indexed mode before you start drawing.
Save the image in the /boot/grub directory, using the file extension .xpm.gz .
Another way to generate a splash image is to convert an existing landscape-oriented digital photo or a desktop wallpaper file using the ImageMagick convert program:
# convert -resize 640x480 -colors 14 photo.jpg /boot/grub/new_splash.xpm.gz
Finally, edit the splashimage line to point to your new creation:
splashimage=(hd0,1)/grub/new_splash.xpm.gz
An example of a modified splash image is shown in Figure 10-22 .
Figure 10-22. Modified splash image
Creating additional boot entries is simply a matter of entering additional lines with the options that you want.
For example, you could create two separate entries for Fedora Coreone for runlevel 5 (GUI) and one for runlevel 3 (text mode):
title Fedora Core
- Graphical Login ( 2.6.31-1.3420_fc6 )
root (hd0,1)
kernel /vmlinuz- 2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
initrd /initrd- 2.6.31-1.3420_fc6 .img
title Fedora Core - Text Login ( 2.6.31-1.3420_fc6 )
root (hd0,1)
kernel /vmlinuz- 2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet 3
initrd /initrd- 2.6.31-1.3420_fc6 .img
These two options are identical except for the descriptions on the title lines and the addition of the number 3 to the end of the kernel line for text-mode entry.
Installing a new kernel RPM will add an additional boot option and make it the default. If you are using yum to perform updating, a maximum of two versions of the kernel will be installed at once (configurable in /etc/yum/pluginconf.d/installonlyn.conf), so old kernel versions and their corresponding GRUB entries may be removed from the menu by yum when updating.
Anaconda normally installs the GRUB boot record on the first disk drive automatically.
There are two situations where it may be necessary to manually install GRUB on an existing system:
When you're using a RAID 1 /boot partition, Anaconda will install the Grub boot record only on the first disk drive. Having a mirrored copy of /boot won't help if the first disk drive fails and you can't boot from the second drivea situation easily remedied by installing the GRUB boot record on the second drive as well.
When your boot record is corrupted or overwritten by another program, such as an installer for another operating system, you may need to manually install the GRUB boot record again.
The easiest way to install GRUB is to use the grub-install script:
# grub-install --root-directory= /boot /dev/hda
Installation finished. No error reported.
This is the contents of the device map /boot/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script \Qgrub-install'.
(fd0) /dev/fd0
(hd0) /dev/hda
(hd1) /dev/hdb
(hd2) /dev/hdc
(hd3) /dev/sdb
The --root-directory argument specifies the root directory for the boot files and should be used only if /boot is a mount point for a separate boot partition. The drive argument at the end of the line ( /dev/hda ) specifies the hard drive that GRUB will be installed on.
grub-install uses Linux disk names, such as /dev/hdc, instead of Grub disk names such as (hd2).
Sometimes the GRUB boot record gets damaged, making it impossible to boot the system normally. It may be necessary to boot from a GRUB DVD or floppy disk to fix this type of problem.
To create a GRUB DVD on a Fedora system (obviously not the one that won't boot!), enter these commands:
# cd /usr/share/grub/
# growisofs -Z /dev/cdrom -R -b stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table i386-redhat
Type the entire growisofs command on one continuous line.
To create a bootable floppy instead of a DVD:
# cd /usr/share/grub/i386-redhat
# cat stage1 stage2 >/dev/fd0
It's worthwhile keeping a GRUB DVD or floppy with your system manuals just in case you ever find that you can't boot your system due to bootloader problems.
Boot your system with this disc or floppy. A GRUB command prompt will appear, as shown in Figure 10-23 .
Figure 10-23. GRUB command prompt from a CD/DVD boot
At this prompt, search for your stage1 file:
grub> find /boot/grub/stage1
Error 15: File not found
grub> find /grub/stage1
(hd0,0)
If your boot files are in your root filesystem, GRUB will find /boot/grub/stage1 , but if you have a separate /boot partition, GRUB will find /grub/stage1 . In the previous example, the partition (hd0,0) contains the stage1 file.
Make this partition your root partition:
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
Now instruct GRUB to set up the boot record on that drive:
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub
.conf"... succeeded.
Done
Note that the setup command was given the drive (hd0) instead of the partition (hd0,0) to install the boot record at the start of the drive instead of the start of the boot partition.
You can now remove the GRUB disc/floppy and boot directly from the hard drive.
To temporarily override a GRUB menu option, select a menu option on the boot menu using the up/down arrow keys, and then press E (for edit). The screen shown in Figure 10-24 will be displayed.
If you have a bootloader password configured, you will be prompted for it at this point.
Figure 10-24. Selecting a menu-entry line to edit
Use the arrow keys to select the line you wish to edit, and then press E again. You can now move across the line using the arrow keys, as shown in Figure 10-25 . Type new text to insert it into the line, or use the Backspace/Delete keys to remove text. Press Enter when done.
Figure 10-25. Edit a line in a menu entry
Press Enter to accept your changes or Esc to undo them. In either case you will return to the menu-entry display shown in Figure 10-24 ; press B to boot, or press Esc to return to the boot menu.
As a shortcut, if you are adding boot options only to an existing menu entry, select the entry using the up/down arrow keys, then press A (for append). You can then type the additional option(s), such as a runlevel. Press Enter to proceed with booting or Esc to cancel and return to the boot menu.
To protect against the unauthorized use of runlevel S or other boot options, it's a good idea to add a password entry to the boot menu. If you didn't do this during the installation, you can add the password at any time by following these steps:
Generate an encrypted password with the grub-md5-crypt command:
$ grub-md5-crypt
Password:
bigsecret
Retype password:
bigsecret
$1$f1z061$j/UEYyBn0e0996w0gjq4k/
The line in bold at the bottom of the listing is the encrypted (scrambled) version of the password.
Next, edit the /boot/grub/grub.conf file and add this line at the top, substituting the password you just generated:
password --md5 $1$f1z061$j/UEYyBn0e0996w0gjq4k/
When you boot the system, you will still be able to select a boot menu entry, but to perform any advanced operations (such as appending runlevel information to a boot entry), you will need to enter the password.
GRUB actually consists of four pieces of software, plus some utilities:
stage 1
The boot record. This tiny piece of code is less than 512 bytes long.
stage 1.5
Additional drivers for filesystems, such as ext2, to enable GRUB to find the stage 2 files.
stage 2
The standalone GRUB command shell and menu program.
/sbin/grub
A version of the GRUB command shell that can be executed inside a running Fedora system.
During boot, the system BIOS loads stage 1 as the boot record and executes it, which then loads stage 1.5 (if necessary) and finds stage 2 . stage 2 then seeks out the GRUB configuration file menu.lst (a symbolic link to grub.conf , which the Fedora developers apparently consider to be a better name).
The GRUB command shell supports over three dozen commands; most of these are never used except by experts and developers. Instead, most users interact with the GRUB menu.
The grub.conf file permits a set of boot options to be presented to the user as a menu entry, removing most of the complexity from the user's view.
A typical Linux entry in grub.conf sets the root filesystem, which is mounted by GRUB to enable access to the kernel and other boot drives. The entry also specifies the name of the kernel and initrd ramdisk to be loaded into memory, and also indicates any configuration options that are to be passed to the kernel.
The author of the splash-image code maintains a small gallery of tested splash images at http://ruslug.rutgers.edu/~mcgrof/grub-images/images/ and an archive at http://ruslug.rutgers.edu/~mcgrof/grub-images/images/working-splashimages/ .
This works well. Simply add the entries for the other Linux distributions to the active /boot/grub/grub.conf (or /boot/grub/menu.lst ) file. This can be done by specifying that the second Linux distribution install GRUB at the start of that distribution's root filesystem partition instead of placing it in the master boot record for the drive. Then copy the /boot/grub/grub.conf entries from the second Linux distribution to the first one.
The Grub manual: http://www.gnu.org/software/grub/manual/ (also installed as an info document in Fedora Core)
The Grub web site: http://www.gnu.org/software/grub/
The sample configuration file /usr/share/doc/grub-0.95/menu.lst
The manpage for convert
The Fedora Core installation DVDor disc 1 of the CD setcan be used to boot into a rescue mode , which lets you access a Fedora system installed on a hard disk without booting from that hard disk. This can be used to recover from many types of system failure or badly misconfigured startup scripts.
Inset your Fedora installation disc (DVD or CD 1) into the system and boot from it. At the boot prompt, enter:
boot: linux rescue
You will be presented with the standard language and keyboard menus (see Figures 1-5 and 1-6 in Chapter 1), and then the question shown in Figure 10-26 will be displayed.
Figure 10-26. Network interface question
If you want to be able to transfer files to and from the system (for example, to back up critical data), answer Yes; otherwise, answer No. If you answer Yes, the standard network configuration dialog will appear, enabling you to select DHCP network configuration or manually enter the network details.
Figure 10-27 shows the next screen, which offers to mount your hard disk directories for you. If you need to access files on your hard disk, select Continue; if you need to access files on your hard disk but want to avoid the possibility of damaging any files, select Read-Only; and if you do not want to mount the hard disk filesystems (for example, because you want to work on the filesystems first, resizing or repairing them), select Skip.
Figure 10-27. Hard disk mounting dialog
Figure 10-28 shows the final dialog that will be displayed before a root shell is opened, which informs you whether the hard disk filesystems were mounted. Select OK to proceed to a root shell.
Figure 10-28. Final dialog before the rescue-mode shell
A minimal environment is available in the rescue-mode shell, providing access to the most important system administration commands.
If you requested that the hard disk filesystems be mounted, the mount point will be /mnt/sysimage , and the mounts will be cascaded properly. Therefore, if you have separate /boot and /home filesystems, they will be mounted under /mnt/sysimage/boot and /mnt/sysimage/home .
If you selected a read/write mount, you can temporarily make the root directory of the hard disk your root directory using the chroot command:
sh-3.1# chroot /mnt/sysimage
You can now access directories in their usual locations ( /etc , /home , and so forth), and you'll have access to all of the software installed on the hard disk.
When you issue the chroot command, you will no longer be accessing the software on the installation disc. Therefore, if the commands installed on the hard disk filesystems are corrupted or damaged, you will be using the corrupted or damaged versions. Likewise, if the software on your hard disk is newer than the software on the installation disc, you will be using the newer versions.
Press Ctrl-D (for done) to exit from the chroot shell and return to the normal rescue shell.
If you chose not to mount your hard disk filesystems, any LVM volume groups on your hard disks will be inaccessible. To access the VGs, issue these commands:
sh-3.1# lvm vgscan
Reading all physical volumes. This may take a while...
Found volume group "main" using metadata type lvm2
sh-3.1# lvm vgchange -ay
2 logical volumes in volume group "main" now active
You can then access the logical volumes as /dev/<pv>/<lv> (for example, /dev/main/root ).
When you are finished with the shell, press Ctrl-D. The system will automatically reboot.
Rescue mode uses the same Linux kernel, initrd ramdisk, and device probing that are used during the installation process to create a minimal work environment using only software loaded from the installation disc. The same code that is used to detect and mount existing Fedora partitions for an upgrade installation is used to mount the partitions during rescue mode.
The chroot command changes the definition of the root directory for one processin this case, a shelland any processes started by that shell. Changing the root directory effectively changes the PATH so that the software installed in the chroot environment (software on the hard disk) is used while the chroot is active. When you exit from the chroot shell, the root directory reverts to the root directory of the installation session, which is a ramdisk.
The scp command is available in rescue mode and can be used to copy files to or from another Fedora system (or other Linux host). You must enable the network interfaces in order for this to work.
To copy a file from an FTP or HTTP server, use wget :
sh-3.1# wget http://192.168.1.2/help.txt
Unfortunately, there's not enough of the supporting infrastructure in place in rescue mode to support the use of a GUI.
Set your path to include directories on the mounted hard disk filesystems:
sh-3.1# PATH=$PATH:/mnt/sysimage/bin:/mnt/sysimage/usr/bin: /mnt/sysimage/sbin:/mnt/sysimage/usr/sbin:/mnt/sysimage/usr/local/bin
Type this command on one line.
The Fedora Core Installation Manual: http://fedora.redhat.com/docs/fedora-install-guide-en/fc6/
The manpages for chroot , wget , scp , and lvm
Xen is a technology that permits one physical computer to act as two or more virtual machines (or domains ). Each domain is isolated from other domains, so administration privilege can be safely delegated; you can designate a system administrator for one domain and give him the root password for total control of that system, confident that he will not be able to touch the configuration of other domains.
Virtualization technology is also very helpful when testing multiple software versions or configurations, and since virtual machines can be migrated between physical systems, it provides a lot of flexibility for server deployment and management.
To use Xen, you must install a special kernel and utilities on your existing Fedora system, which then becomes your primary domain ( Domain-0 ). You can then install Fedora on as many additional domains as you want.
To set up for Xen, install the kernel-xen and xen packages using Pirut or this command :
#
yum -y install kernel-xen xen
Reboot your system. When the GRUB boot screen appears, press the spacebar to display the boot menu. Select the new xen kernel using the cursor keys, and then press Enter to boot.
To make your system boot the Xen kernel by default, edit /boot/grub/grub.conf (see Lab 10.5, "Configuring the GRUB Bootloader")
You can confirm that you are running the Xen kernel by using the uname command:
# uname -r
2.6.17-1.2564.fc6xen
The xend service should also be running, which you can confirm using the service command:
# service xend status
service xend is running
The Fedora installation that you are using is Domain-0 , the master domain. Additional virtual machines, called guest domains , must be installed from a network installation server. If you do not have one, you can quickly set up one within Domain-0 by inserting a Fedora Core DVD and typing:
# yum -y install httpd
...(Lines snipped)...
# setenforce 0
# ln -s /media/ disk /var/www/html/fedora
# service httpd start
Starting httpd: [ OK ]
The setenforce command just shown disables SELinux protection for your system, which presents a security risk. Re-enable SELinux as soon as you are finished using the network installation server:
#
setenforce 1
To start the guest domain installation:
# xenguest-install
What is the name of your virtual machine? fedora
How much RAM should be allocated (in megabytes)? 256
What would you like to use as the disk (path)? /var/xen/fedora
How large would you like the disk to be (in gigabytes)? 2
Would you like to enable graphics support (yes or no) no
What is the install location? http://192.168.2.48/fedora
The name of the virtual machine can be any value that meets the requirements for a filename. The disk path and size requested are used to set up a file that will act as the hard disk for the guest domain. The install location is the URL of the network installation server; if you're using an HTTP server on Domain-0 , use the full IP address of that system instead of the loopback address 127.0.0.1 (since, inside a guest domain, the loopback destination is the guest domain itself, not Domain-0 ).
A regular Fedora installation will now start in text mode within the guest domain. After prompting you for the language and keyboard, the installer will give you the option of continuing with a text mode installation or using VNC for a graphical installation, as shown in Figure 10-29 .
Figure 10-29. Text mode and VNC installation options
This message indicates that the installer was unable to start X. This is normal, since the guest domain does not have a video card.
Choose one of the two options:
To continue in text mode, press Enter.
To use VNC, press Tab, and then press Enter. The installer will prompt you to create a VNC password and will then start a VNC server. This message will be displayed on the screen:
Starting VNC...
The VNC server is now running.
Please connect to 192.168.2.112:1 to begin the install...
Starting graphical installation...
Press <enter> for a shell
Use the vncviewer program to connect to the indicated address and port:
$ vncviewer 192.168.2.112:1
A window will appear showing the normal Fedora graphical installation display.
You can then proceed with a regular Fedora installation into the guest domain. When the installation is finished, you can start your guest domain with this command:
# xm create fedora
Using config file "/etc/xen/fedora".
Going to boot Fedora Core (2.6.17-1.2517.fc6xen)
kernel: /vmlinuz-2.6.17-1.2517.fc6xen
initrd: /initrd-2.6.17-1.2517.fc6xen
Started domain fedora
This will boot the guest domain. You can view the current domains using xm list :
# xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 510 2 r----- 247.8
fedora 5 256 1 -b---- 9.5
This display shows that the domains Domain-0 and fedora are both running, and displays the domain ID number, memory, virtual CPUs, and CPU usage in seconds for each domain.
So what's going on in the guest domain? Good question! You can see the guest console by using xm console :
# xm console fedora
The first time your guest domain boots, you will see a text version of the firstboot configuration.
To start a guest domain and connect to its console immediately, use xm create with the -c (console) option:
#
xm create -c fedora
After the first boot, you may find it just as easy to use SSH to connect to the guest domain as though it were a remote server:
$ ssh -X 192.168.2.112
The -XC option enables the remote display of X clients, so that you can use graphical administration tools such as system-config-printer within the guest domain and display the window on your Domain-0 screen.
To shut down a guest domain, either initiate a shutdown within the domain (for example, by executing the shutdown command), or use the xm shutdown command in Domain-0 :
# xm shutdown fedora
The shutdown will take up to a few minutes, just like the shutdown of a physical system. If a guest domain is stuck in an unrecoverable state, you can forcefully stop it (although this is the equivalent of turning off the power on the virtual machine, so it may result in data loss):
# xm destroy fedora
Xen boots a small program called a hypervisor before booting Domain-0 . The hypervisor masks the underlying hardware and presents a modified virtual environment to each domain. Domain-0 has direct access to certain hardware, such as network interface cards and other peripherals, and the standard device drivers are used to access those devices.
Inside Domain-0 , a service daemon named xend provides monitoring and control functions for the guest domains and communication between the guest domains and certain types of hardware (such as network interfaces).
The Xen environment is different from the normal PC environment, and the operating system must be modified to run in this special environment; this is called paravirtualization because it requires some cooperation on the part of the guest operating system. The advantage to this approach is higher performance and the ability to control the guest operating system in certain ways (such as sending the guest OS a shutdown message when xm shutdown is used).
Xen is developed as an open source project; XenSource is a company formed by the original Xen researchers to offer an enhanced, commercially supported version of Xen.
The Fedora Xen guest installation tool, xenguest-install , is a Python script that interfaces with Fedora's Anaconda system and python libraries. The configuration files generated by xenguest-install are stored in /etc/xen.
Xen configuration files created with xenguest-install are installed in /etc/xen , and the filenames match the guest domain names. If these files are symlinked to the /etc/xen/auto directory, they will be started automatically at boot time by the xendomains service.
For example, to start the fedora guest domain automatically at each boot, link its configuration file using ln -s :
# ln -s /etc/xen/ fedora /etc/xen/auto
CPU makers are starting to build support for virtualization into their CPUs. AMD's technology is named Pacifica, while Intel's is named VT-X. Xen can take advantage of either technology to boost performance and to provide full virtualization to unmodified operating systems.
Xen is very configurable, but the Fedora Xen guest installation script handles only a small subset of the possibilities. To use alternate configurations it is necessary to manually edit the configuration files in /etc/xen (see the Xen documentation and the sample configuration files in /etc/xen for details).
It is possible to install other Linux distributions and (soon) other operating systems into guest domains, but they must be installed manually; Fedora's Xen installer only works with Fedora Core at this point. For information on installing other Xen guests, see the XenSource web site ( http://www.xensource.com ) and the documentation for the Xen guest you wish to install.
Microsoft Windows and other unmodified operating systems can be used as Xen guests only with hardware virtualization support.
Xen provides the xentop tool for domain monitoring, shown in Figure 10-30 . As the name implies, it provides a top -like display of domain activity, updated every three seconds.
Figure 10-30. Xentop display
Fedora Core also includes the Virtual Machine Manager ( virt-manager ) application, but the version released with Fedora Core 6 is at a very early stage of development. It is designed to provide an effective way of managing virtual machines through a graphical user interface; you can follow development on the fedora-xen list (see Lab 9.1, "Participating in the Fedora Mailing Lists ").
The Fedora Virtualization Project: http://fedora.redhat.com/projects/virtualization/
The XenSource web site: http://www.xensource.com/
The Xen Wiki: http://wiki.xensource.com/xenwiki/