Special Installation Topics


Some things that you run into during installation merit whole discussions by themselves . Rather than bog down the procedures with details that not everyone needs, I have included instructions in this section to address issues such as setting up a dual-boot Linux and Windows system, disk partitioning, and boot loaders.

Setting Up to Dual-Boot Linux and Windows

It is possible to set up your computer so that you can have two (or more) complete operating systems installed on it. When you power up your computer, you can choose which operating system you want to boot. This setup is referred to as a dual-boot computer.

If a Microsoft Windows operating system was installed when you got your PC, it's likely that the entire hard disk is devoted to Windows. Fedora install classes retain existing Windows partitions by default, but they don't let you take space from existing disk partitions without destroying them. If you want to be able to run Linux on that machine, you need to do one of the following:

  • Erase the disk. If you never wanted Windows in the first place (or if Windows is badly broken or infected), you may decide to completely erase it from your hard disk. In this case, you won't have a dual-boot system, but you can jump right to the Fedora or RHEL install procedure and start installing (tell the install process to just erase the whole disk).

  • Add a second disk. This lets you maintain your Windows installation on the computer without having to do the potentially dangerous resizing of your Windows partitions. (Refer to Chapter 10 for information on adding a second disk, then go right to the Fedora installation section.)

  • Resize your Windows partition(s). Many people choose this route for dual-booting Windows and Linux. If done sucessfully, you don't have to add hardware and you can keep your whole Windows system.

The rest of this section is devoted to a discussion and procedure for resizing your Windows partitions to create a dual-boot computer with Windows and Linux.

Resizing Your Windows Partitions

By resizing your Windows partitions you can free up disk space that can be used for your Fedora or RHEL installation. Because there is some danger in resizing your disk partitions and changing how your computer boots, however, you should carefully read the Caution that follows .

Caution 

Setting up a dual-boot system is discouraged by Red Hat and by people who write Linux books (like me) because if something goes wrong you can lose all your data or make your computer unbootable (usually temporarily). New users often won't have a backup and will simply erase their hard disk if the computer won't boot after a procedure like the following. Then they complain a lot. So, I'm officially recommending against setting up a dual-boot system, and then telling you how to do it.

Red Hat, Inc. encourages you to use VFAT file systems for your Windows partitions if you plan to dual boot your computer with Linux. There is no support for NTFS file systems in Fedora or RHEL kernels (to use NTFS file systems, you must add support as I describe later). To read how Red Hat recommends you set up dual boots, refer to the Red Hat Linux Installation Guide, " Configuring a Dual-Boot System " section:

 www.redhat.com/docs/manuals/linux/RHL-9-Manual/install-guide/ch- x86-dualboot.html 

If, after resizing your Windows partitions and installing Fedora or RHEL, your computer becomes unbootable, refer to the "Troubleshooting Installation" section later in this chapter for advice on what to do.

Before you begin resizing your Windows system, boot Windows and do the following:

  • Back up your data! Of course, you should always have a current backup of your important data. However, now is a particularly good time to do a back up, just in case one of those disk catastrophes I warned you about actually happens.

  • Defragment your disk. Before you resize your hard disk, you should use a defragmenting utility in Windows to have all files stored contiguously on the disk. That way, when you reassign free space to Linux partitions, you have a continuous area of the disk to work with. To defragment a disk in Windows XP, click Start All Programs Accessories System Tools Disk Defragmenter. Then select Defragment from the Disk Defragmenter window. Defragmenting can take a while, depending on your processor speed and disk size .

While you have the Disk Defragmenter window displayed, note a few things about your hard disk that you will need to know later:

  • File System - The file system type will most likely be NTFS, although it may also be VFAT. If you have the option to install Windows from scratch, selecting VFAT as the file system type will work much better for Linux. NTFS is not officially supported by Fedora or RHEL (you need to add support, as I describe later). Support for writing to NTFS is not reliable, although reading from NTFS seems to work well. VFAT file systems, however, will work well for both Linux and Windows.

  • Free Space - If your entire hard disk is consumed by a single Windows partition, you can resize your existing partition to use some of the free space to assign to Linux partitions. Note the amount of free space you have here and compare it to the amounts you will need to install Linux (described earlier).

Despite the fact that I have successfully resized several NTFS partitions using the QTParted utility, I still recommend caution (and a good backup of your data) before proceeding. If you feel more comfortable using commercial products to resize your partitions, I have listed a few of those below. I have not tested the products so I name them here only because I have heard good reports of success from others:

  • Partition Magic - I've heard good reports from people using Partition Magic ( www.powerquest.com/partitionmagic ) to resize NTFS partitions. Partition Magic also helps you create new partitions and manage them. It supports Windows XP Professional/Home, Windows 95b-98SE, Windows Me, Windows 2000 Professional, and NT 4.0 workstation (SP6a). The cost is currently $69.95.

  • Acronis OS Selector - This is another well-regarded product for managing, creating, and resizing partitions, which is now included in the Acronis Disk Director Suite. It supports a variety of file system types, including FAT12, FAT16, FAT32, NTFS, and Linux partition types (ext2, ext3 and Linux ReiserFS). It also supports the same Windows platforms that Partition Magic does. The cost is currently $49.99 from www.acronis.com .

Note 

Earlier releases of Fedora Core included a FIPS utility for resizing FAT and VFAT file systems. FIPS is no longer included with Fedora Core or RHEL, so no description of FIPS is included here. A description of FIPS from an earlier edition of this book is included at the Wiley Web site: www.wiley.com/go/fedora6bible .

The open source tool I describe here for resizing your disk is called QTParted. It can be used to resize partitions that contain a variety of file system types. If your Windows system is backed up and your disk defragmented, you can begin the process of resizing your NTFS or VFAT disk partition with QTParted by obtaining a KNOPPIX live CD ( www.knopper.net/knoppix/index-en.html ). (Because Fedora Core doesn't include NTFS support, you can't use Fedora to resize NTFS partitions.) Here's how to resize your NTFS partitions using KNOPPIX:

  1. Insert the KNOPPIX CD and reboot your computer.

  2. At the boot prompt, press Enter.

  3. When KNOPPIX boots, to begin resizing your hard disk select System QTParted from the K menu. The QTParted graphical partitioning tool opens.

  4. Select the Disk containing the partition you want to resize (left column) and the partition itself (right column). The Driver Info box should say available on the Status line. (If it says busy you may need to unmount the partition or close any processes that are accessing the device.)

  5. Select Operations Resize to open a Resize Partition pop-up windows.

  6. Move the slider from the right to the left to select how much you want to resize your partition. The New Size box shows what you are resizing the partition to, and the Free Space After Box shows how much free space you will have after you are done. In my example, I resized /dev/hda1 to about 20GB, leaving me about 30GB of free space that I can use later to install Fedora. Figure 2-1 shows the QTParted window resizing about a 50GB partition to about 20GB.

  7. Click OK to begin resizing your partition. When it is done, you will see the resized partition and a new entry showing the free space. In the example shown previously, the new entries looked as follows:

      Number Partition Type Status Size Used space Start End   01 /UNIONFS/dev/hda1 ntfs Active 20.05 N/A 0.03MB 20.05GB  02 /UNIONFS/dev/hda-1 free 31.25 N/A 20.05GB 51.30GB 
    Caution 

    The next step is where the resize is committed. You can quit now without making any changes if you are nervous. In any case, make sure that the partition you are resizing is not mounted. (In this example, I'd type sudo umount /dev/hda1 before running the next step.

  8. If the new partition sizes look alright, click File Commit to commit the changes.

  9. At this point, you can close the QTParted window and begin the regular installation procedure for Fedora Core or RHEL, using the disk space that you just freed up.

image from book
Figure 2-1: Use QTParted to resize your Windows NTFS partitions.

After you have installed Fedora or RHEL, there are a few other useful things you might want to do so you can use files from your Windows partitions in Linux.

Note 

By default, Fedora and RHEL are configured to hide the GRUB boot screen that lets you select which operating system to boot. You will have to press Enter as the Fedora boot screen counts down 5 seconds to see the GRUB boot screen. You might consider editing the grub.conf file, as described later in this chapter. Personally, I removed the hiddenmenu line and increased the timeout from 5 to 10 seconds.

Using Windows Partitions from Linux

With some space available on your disk, when you go to install Linux, consider adding a small FAT16 or FAT 32 partition (maybe 2GB) on your disk. Every x86 operating system (Linux, Windows 95, NT, 2000, XP and DOS) supports those types. With that added, you won't have to worry about having NTFS support in Linux (which you will have to add and rebuild with every kernel upgrade). You will be able to freely exchange files between your Linux and Windows system on the FAT16 partition.

With FAT partitions, however, keep in mind that there are limitations. FAT is limited to between 2GB and 4GB file sizes. Also, FAT16 doesn't support long file names . Total partition size for FAT file systems is 32 GB.

After you have installed Linux in the space freed up by the previous procedure, you should be able to choose between Linux and Windows when the Fedora or RHEL boot screen appears during boot time. Press any key to go to the GRUB boot screen. Then move the arrow key to choose to boot Linux or Windows.

The first time you boot Windows, you might be asked to check your disk (because your Windows partition will be a different size than expected). After that, there should be no change in how you use your Windows system. Your disk space will just be smaller.

Now, when you boot up Linux, if you have a lot of documents, digital images, music, or other content on your Windows partition, you probably want to be able to use that content from Linux. To do that, you need to:

  • Determine which partition is your Windows partition.

  • Add support for the file system type of your Windows partition to Linux. Since VFAT is already built in, that means adding NTFS support if that is the file system type.

  • Mount the Windows partition on your Linux file system.

The following procedure describes how to do those things.

  1. Check partitions. To determine which partition contains your Windows file system, use the fdisk command as follows:

     #  fdisk -l   Disk /dev/hda: 60.0 GB, 60011642880 bytes   16 heads, 63 sectors/track, 116280 cylinders   Units = cylinders of 1008 * 512 = 516096 bytes   Device Boot Start End Blocks Id System   /dev/hda1 * 1 41725 21029053+ 7 HPFS/NTFS   /dev/hda2 106741 116280 4808160 12 Compaq diagnostics   /dev/hda3 41725 41932 104422+ 83 Linux   /dev/hda4 41932 106734 32660145 5 Extended   /dev/hda5 41932 106718 32652081 8e Linux LVM  

    In this example, the Windows partition is on device /dev/hda1 and is an NTFS file system. (The other common type of Windows file system is VFAT.)

  2. Get NTFS support. If you have a VFAT file system, you can skip this step. If you have an NTFS file system, you can install the necessary drivers to be able to mount and use your NTFS file system in Linux. The Linux-NTFS project is the best resource for NTFS file system support in Linux. If you choose to install NTFS support, you should read the release notes ( http://linux-ntfs. sourceforge .net/rpm/rel26.html ), taking careful note of all the warnings.

    You need to get the NTFS RPM that is appropriate for the kernel you are running for Fedora Core 4. To find out your current kernel, type the following:

     $  uname -r  2.6.11-1.1323_FC4 

    With that information in hand, go to the following download site for Linux NTFS RPMs, and then get and install the appropriate RPM:

    • http://linux-ntfs.org/content/view/128/64

    Be sure to read the instructions carefully and get only an RPM that matches your current Fedora kernel.

  3. Mount Windows file system. You can access your Windows file system from Linux using the mount command. Assuming your Windows partition is an NTFS file system on /dev/hda1 (as in the example above), you could type the following to create the Windows mount point and mount the file system there:

     #  mkdir /mnt/win  #  chmod 755 /mnt/win  #  mount -oro -t ntfs /dev/hda1 /mnt/win  #  chmod 755 /mnt/win  #  ls /mnt/win  

    The -oro option to mount will mount the file system read-only. Read/write support is not considered to be stable (so if you remove the -oro option to mount read/write, you do so at your own risk). Replace the ntfs with vfat if your Windows partition is a VFAT file system. The ls command is just to find out if you can see the contents of your Windows partition.

    You can have the mount occur permanently by adding an entry to the /etc/fstab file. Here's an example of the line you could add to /etc/fstab to have the partition mounted every time the system reboots:

     /dev/hda1 /mnt/win ntfs ro 0 0 

At this point, you can use the files from your Windows partition as you would any other files on your system. You can open a folder or change directories to the /mnt/win directory to see the contents. Then use any applications you choose to open your documents (OpenOffice.org), music (Rhythmbox), images (gimp), or any other content type you want to use from your Windows partition in Linux.

Partitioning Your Disks

The hard disk (or disks) on your computer provides the permanent storage area for your data files, applications programs, and the operating system (such as Fedora or RHEL). Partitioning is the act of dividing a disk into logical areas that can be worked with separately. There are several reasons you may want to do partitioning:

  • Multiple operating systems - If you install Fedora or RHEL on a PC that already has a Windows operating system, you may want to keep both operating systems on the computer. To run efficiently , they must exist on completely separate partitions. When your computer boots, you can choose which system to run. Note that you are limited in the number of partitions you can have (with IDE drives you can have 63 partitions; with SCSI devices, you are limited to 15 partitions per device).

  • Multiple partitions within an operating system - To protect from having their entire operating system run out of disk space, people often assign separate partitions to different areas of the Linux file system. For example, if /home and /var were assigned to separate partitions, then a gluttonous user who fills up the /home partition wouldn't prevent logging daemons from continuing to write to log files in the /var/log directory.

    Multiple partitions also make it easier to do certain kinds of backups (such as an image backup). For example, an image backup of /home would be much faster (and probably more useful) than an image backup of the root file system ( / ).

  • Different file system types - Different kinds of file systems have different structures. File systems of different types must be on their own partitions. In Fedora and RHEL, you need at least one file system type for / (typically ext3) and one for your swap area. File systems on CD-ROM use the iso9660 file system type.

Tip 

When you create partitions for Fedora or RHEL, you will often assign the file system type as Linux native (using the ext3 type). Reasons to use other types include needing a file system that allows particularly long filenames or many inodes (each file consumes an inode).

For example, if you set up a news server, it can use many inodes to store news articles. Another reason for using a different file system type is to copy an image backup tape from another operating system to your local disk (such as one from an OS/2 or Minix operating system).

If you have used only Windows operating systems before, you probably had your whole hard disk assigned to C: and never thought about partitions. With Fedora Core and RHEL, you can select to have Linux erase the whole disk, take it over, and partition it or have Linux keep separate partitions for Windows 9 x /2000/NT/XP and Linux. The Fedora and RHEL install processes also give you the opportunity to view and change the default partitioning for the different installation types.

During installation, Fedora and RHEL enable you to partition your hard disk using the Disk Druid utility (a graphical partitioning tool). The following sections describe how to use Disk Druid (during installation) or fdisk (when Fedora or RHEL is up and running or by switching virtual terminals while the install is running). See the section "Tips for creating partitions" for some ideas for creating disk partitions.

Partitioning with Disk Druid During Installation

During installation, you are given the opportunity to change how your hard disk is partitioned. Fedora recommends using the Disk Druid. The Disk Druid screen is divided into two sections. The top shows general information about each hard disk. The bottom shows details of each partition. Figure 2-2 shows an example of the Disk Druid window.

image from book
Figure 2-2: Partition your disk during installation from the Disk Setup window.

For each of the hard disk partitions, you can see:

  • Device - The device name is the name representing the hard disk partition in the /dev directory. Each disk partition device begins with two letters : hd for IDE disks, sd for SCSI disks, ed for ESDI disks, or xd for XT disks. After that is a single letter representing the number of the disk (disk 1 is a, disk 2 is b, disk 3 is c, and so on). The partition number for that disk (1, 2, 3, and so on) follows that.

  • Mount Point/Raid/Volume - The directory where the partition is connected into the Linux file system (if it is). You must assign the root partition ( / ) to a native Linux partition before you can proceed. If you are using RAID or LVM, the name of the RAID device or LVM volume appears here.

  • Type - The type of file system that is installed on the disk partition. In most cases, the file system will be Linux (ext3), Win VFAT (vfat), or Linux swap. However, you can also use the previous Linux file system (ext2), physical volume (LVM), or software RAID. In fact, LVM is used by default for your root file system when you install Fedora or RHEL. This will allow you to add more disk space later to that partition, if needed, without having to create a new partition.

  • Format - Indicates whether (checkmark) or not (no checkmark) the installation process should format the hard disk partition. Partitions marked with a check are erased! So, on a multiboot system, be sure your Windows partitions, as well as other partitions containing data are not checked!

  • Size (MB) - The amount of disk space allocated for the partition. If you selected to let the partition grow to fill the existing space, this number may be much larger than the requested amount.

  • Start / End - Represents the partition's starting and ending cylinders on the hard disk.

In the top section, you can see each of the hard disks that is connected to your computer. The drive name is shown first. The Geometry section (Geom) shows the numbers of cylinders, heads, and sectors, respectively, on the disk. That's followed by the model name of the disk. The total amount of disk space, the amount used, and the amount free are shown in megabytes.

Reasons for Partitioning

There are different opinions about how to divide up a hard disk. Here are some issues:

  • Do you want to install another operating system? If you want Windows on your computer along with Linux, you will need at least one Windows (Win95 FAT16, VFAT, or NTFS type), one Linux (Linux ext3), and one Linux swap partition.

  • Is it a multiuser system? If you are using the system yourself, you probably don't need many partitions. One reason for partitioning an operating system is to keep the entire system from running out of disk space at once. That also serves to put boundaries on what an individual can use up in his or her home directory (although disk quotas are good for that as well).

  • Do you have multiple hard disks? You need at least one partition per hard disk. If your system has two hard disks, you may assign one to / and one to /home (if you have lots of users) or /var (if the computer is a server sharing lots of data).

Deleting, Adding, and Editing Partitions

Before you can add a partition, there needs to be some free space available on your hard disk. If all space on your hard disk is currently assigned to one partition (as it often is in DOS or Windows), you must delete or resize that partition before you can claim space on another partition. The section "Resizing your Windows partitions" earlier in this chapter discusses how to take disk space from an existing Windows partition to use later for Linux partitions, without losing information in your existing single-partition system.

Caution 

Make sure that any data that you want to keep is backed up before you delete the partition. When you delete a partition, all its data is gone.

Disk Druid is less flexible, but more intuitive, than the fdisk utility. Disk Druid lets you delete, add, and edit partitions.

Tip 

If you create multiple partitions, make sure that there is enough room in the right places to complete the installation. For example, most of the Linux software is installed in the /usr directory (and subdirectories), whereas most user data are eventually added to the /tmp, /home or /var directories. It's a good idea to have separate partitions for every directory structure users can write to. Likewise, NFS shares also are often put on separate partitions.

To delete a partition in Disk Druid, do the following:

  1. Select a partition from the list of Current Disk Partitions on the main Disk Druid window (click it or use the arrow keys).

  2. To delete the partition, click Delete.

  3. When asked to confirm the deletion, click Delete.

  4. If you made a mistake, click Reset to return to the partitioning as it was when you started Disk Druid.

To add a partition in Disk Druid, follow these steps from the main Disk Druid window:

  1. Select New. A window appears, enabling you to create a new partition.

  2. Type the name of the Mount Point (the directory where this partition will connect to the Linux file system). You need at least a root ( / ) partition and a swap partition.

  3. Select the type of file system to be used on the partition. You can select from Linux native (ext2 or preferably ext3), software RAID, Linux swap (swap), physical volume (LVM), or Windows FAT (vfat).

    Tip 

    To create a different file system type than those shown, leave the space you want to use free for now. After installation is complete, use fdisk to create a partition of the type you want.

  4. Type the number of megabytes to be used for the partition (in the Size field). If you want this partition to grow to fill the rest of the hard disk, you can put any number in this field (1 will do fine).

  5. If you have more than one hard disk, select the disk on which you want to put the partition from the Allowable Drives box.

  6. Type the size of the partition (in megabytes) into the Size (MB) box.

  7. Select one of the following Additional Size Options:

    • Fixed size - Click here to use only the number of megabytes you entered into the Size text box when you create the partition.

    • Fill all space up to (MB) - If you want to use all remaining space up to a certain number of megabytes, click here and fill in the number. (You may want to do this if you are creating a VFAT partition up to the 2048MB limit that Disk Druid can create.)

    • Fill to maximum allowable size - If you want this partition to grow to fill the rest of the disk, click here.

  8. Optionally select Force to Be a Primary Partition if you want to be sure to be able to boot the partition or Check for Bad Blocks if you want to have the partition checked for errors.

  9. Select OK if everything is correct. (The changes don't take effect until several steps later when you are asked to begin installing the packages.)

To edit a partition in Disk Druid from the main Disk Druid window, follow these steps:

  1. Click the partition you want to edit.

  2. Click the Edit button. A window appears, ready to let you edit the partition definition.

  3. Change any of the attributes (as described in the add partition procedure). For a new install, you may need to add the mount point ( / ) for your primary Linux partition.

  4. Select OK. (The changes don't take effect until several steps later, when you are asked to begin installing the packages.)

Note 

If you want to create a RAID device, you need to first create at least two RAID partitions. Then click the RAID button to make the two partitions into a RAID device. For more information on RAID, refer to Chapter 10 or the Red Hat Linux Customization guide. The latter is available here: www.redhat.com/do cs/manuals/linux/RHL-9-Manual/custom-guide/ . To create an LVM volume group , you must create at least one partition of type "physical volume (LVM)."

Partitioning with fdisk

The fdisk utility does the same job as Disk Druid, but it's no longer offered as an option during Fedora or RHEL installations. (If you are old school, however, you could press Ctrl+Alt+F2 during the installation process and run fdisk from the shell to partition your disk.)

The following procedures are performed from the command line as root user.

Caution 

Remember that any partition commands can easily erase your disk or make it inaccessible. Back up critical data before using any tool to change partitions! Then be very careful about the changes you do make. Keeping an emergency boot disk handy is a good idea, too.

The fdisk command is one that is available on many different operating systems (although it looks and behaves differently on each). In Linux, fdisk is a menu-based command. To use fdisk to list all your partitions, type the following (as root user):

 #  fdisk -l  Disk /dev/hda: 40.0 GB, 40020664320 bytes 255 heads, 63 sectors/track, 4865 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 4833 38716650 83 Linux /dev/hda3 4834 4865 257040 82 Linux swap 

To see how each partition is being used on your current system, type the following:

 #  df -h  Filesystem Size Used Avail Use% Mounted on /dev/hda2 37G 5.4G 30G 16% / /dev/hda1 99M 8.6M 86M 10% /boot none 61M 0 61M 0% /dev/shm 

From the output of df , you can see that the root of your Linux system ( / ) is on the /dev/hda2 partition and that the /dev/hda1 partition is used for /boot .

Caution 

Before using fdisk to change your partitions, I strongly recommend running the df -h command to see how your partitions are currently being defined. This will help reduce the risk of changing or deleting the wrong partition.

To use fdisk to change your partitions, begin (as root user) by typing:

 #  fdisk  device   

where device is replaced by the name of the device you want to work with. For example, here are some of your choices:

/dev/hda

For the first IDE hard disk; hdb, hdc , and so on for other IDE disks.

/dev/sda

For the first SCSI hard disk; sdb, sdc , and so on for other SCSI disks.

/dev/md0

For a RAID device.

After you have started fdisk , type m to see the options. Here is what you can do with fdisk :

  • Delete a partition - Type d and you are asked to enter a partition number on the current hard disk. Type the partition number and press Enter. For example, /dev/sda2 would be partition number 2. (The deletion won't take effect until you write the change. Until then, it's not too late to back out.)

  • Create a partition - If you have free space, you can add a new partition. Type n and you are asked to enter l for a logical partition (5 or over) or p for a primary partition (1–4). Enter a partition number from the available range. Then choose the first cylinder number from those available. (The output from fdisk -l shown earlier will show you cylinders being used under the Start and End columns .)

    Next, enter the cylinder number the partition will end with (or type the specific number of megabytes or kilobytes you want: for example, +50M or +1024K ). You just created an ext3 Linux partition. Again, this change isn't permanent until you write the changes.

  • Change the partition type - Press t to choose the type of file system. Enter the partition number of the partition number you want to change. Type the number representing the file system type you want to use in hexadecimal code. (Type L at this point to see a list of file system types and codes.) For a Linux file system, use the number 83 ; use 82 for a Linux swap partition. For a Windows FAT32 file system, you can use the letter b .

  • Display the partition table - Throughout this process, feel free to type p to display (print on the screen) the partition table as it now stands.

  • Saving and quitting - If you don't like a change you make to your partitions, press q to exit without saving. Nothing will have changed on your partition table.

    Before you write your changes, display the partition table again and make sure that it is what you want it to be. To write your changes to the partition table, press w . You are warned about how dangerous it is to change partitions and asked to confirm the change.

An alternative to the fdisk command is sfdisk . The sfdisk command is command line-oriented. Type the full command line to list or change partitions. (See the sfdisk man page for details.)

Tips for Creating Partitions

Changing your disk partitions to handle multiple operating systems can be very tricky. Part of the reason is that each different operating system has its own ideas about how partitioning information should be handled, as well as different tools for doing it. Here are some tips to help you get it right.

  • If you are creating a dual-boot system, particularly for Windows ME or Windows XP, try to install the Windows operating system first. Otherwise, the Windows installation may make the Linux partitions inaccessible.

  • The fdisk man page recommends that you use partitioning tools that come with an operating system to create partitions for that operating system. For example, the DOS fdisk knows how to create partitions that DOS will like, and the Fedora or RHEL fdisk will happily make your Linux partitions. Once your hard disk is set up for dual boot, however, you should probably not go back to Windows-only partitioning tools. Use Linux fdisk or a product made for multiboot systems (such as Partition Magic).

  • You can have up to 63 partitions on an IDE hard disk. A SCSI hard disk can have up to 15 partitions. You probably won't need nearly that many partitions.

If you are using Fedora or RHEL as a desktop system, you probably don't need a lot of different partitions within your Linux system. There are, however, some very good reasons for having multiple partitions for Linux systems that are shared by a lot of users or are public Web servers or file servers. Multiple partitions within Fedora or RHEL offer these advantages:

  • Protection from attacks - Denial-of-service attacks sometimes take action that tries to fill up your hard disk. If public areas, such as /var , are on separate partitions, a successful attack can fill up a partition without shutting down the whole computer. Because /var is the default location for Web and FTP servers, and therefore might hold a lot of data, often entire hard disks are assigned to the /var file system alone.

  • Protection from corrupted file systems - If you have only one file system ( / ), corruption of that file system can cause the whole Fedora or RHEL system to be damaged. Corruption of a smaller partition can be easier to correct and can often allow the computer to stay in service while the corruption is fixed.

Here are some directories that you may want to consider making into separate file system partitions:

  • /boot - Sometimes the BIOS in older PCs can access only the first 1024 cylinders of your hard disk. To make sure that the information in your /boot directory is accessible to the BIOS, create a separate disk partition (of only about 100MB) for /boot and make sure that it exists below cylinder 1024. Then, the rest of your Linux system can exist outside of that 1024-cylinder boundary if you like. Even with several boot images, there is rarely a reason for /boot to be larger than 100MB. For newer hard disks, you can sometimes avoid this problem by selecting the Linear Mode check box during installation. Then the boot partition can be anywhere on the disk.

  • /usr - This directory structure contains most of the applications and utilities available to Fedora or RHEL users. Having /usr on a separate partition lets you mount that file system as read-only after the operating system has been installed. This prevents attackers from replacing or removing important system applications with their own versions that may cause security problems. A separate /usr partition is also useful if you have diskless workstations on your local network. Using NFS, you can share /usr over the network with those workstations.

  • /var - Your FTP ( /var/ftp ) and Web-server ( /var/www ) directories are, by default, stored under /var . Having a separate /var partition can prevent an attack on those facilities from corrupting or filling up your entire hard disk.

  • /home - Because your user account directories are located in this directory, having a separate /home account can prevent an indiscriminate user from filling up the entire hard disk. (Disk quotas, see Chapter 10, represent another way of controlling disk use.)

  • /tmp - Protecting /tmp from the rest of the hard disk by placing it on a separate partition can ensure that applications that need to write to temporary files in /tmp are able to complete their processing, even if the rest of the disk fills up.

Although people who use Fedora or RHEL casually rarely see a need for lots of partitions, those who maintain and have to recover large systems are thankful when the system they need to fix has several partitions. Multiple partitions can localize deliberate damage (such as denial-of-service attacks), problems from errant users, and accidental file system corruption.

Using GRUB or LILO Boot Loaders

A boot loader lets you choose when and how to boot the bootable operating systems installed on your computer's hard disks. GRUB is the only boot loader offered for you to configure during Fedora Core 6 installation. The LILO boot loader, as of Fedora Core 5, is not even contained in the Fedora distribution. However, Red Hat Enterprise Linux 4 still includes the LILO boot loader, if you want to configure LILO after RHEL is installed. The following sections describe both GRUB and LILO boot loaders.

Booting Your Computer with GRUB

With multiple operating systems installed and several partitions set up, how does your computer know which operating system to start? To select and manage which partition is booted and how it is booted , you need a boot loader. The boot loader that is installed by default with Fedora is called the GRand Unified Boot loader (GRUB).

GRUB is a GNU software package ( www.gnu.org/software/grub ) that replaced LILO as the only boot loader available in Fedora. GRUB offers the following features:

  • Support for multiple executable formats.

  • Support for multiboot operating systems (such as Fedora, FreeBSD, NetBSD, OpenBSD, and other Linux systems).

  • Support for non-multiboot operating systems (such as Windows 95, Windows 98, Windows NT, Windows ME, Windows XP, and OS/2) via a chain-loading function. Chain-loading is the act of loading another boot loader (presumably one that is specific to the proprietary operating system) from GRUB to start the selected operating system.

  • Support for multiple file system types.

  • Support for automatic decompression of boot images.

  • Support for downloading boot images from a network.

For more on how GRUB works, type man grub or info grub . The info command contains more details about GRUB. Or, see the GRUB Wiki: http://grub.enbug.org .

Booting with GRUB

When you install Fedora or RHEL, information needed to boot your computer (with one or more operating systems) is automatically set up and ready to go. Simply restart your computer. When you see the boot message, press the Enter key (quickly before it times out) and the GRUB boot screen appears (it says GRUB at the top and lists bootable partitions below it). Then you can do one of the following:

  • Default - If you do nothing, the default operating system will boot automatically after a few seconds.

  • Select an operating system - Use the up and down arrow keys to select any of the operating systems shown on the screen. Then press Enter to boot that operating system.

  • Edit the boot process - If you want to change any of the options used during the boot process, use the arrow keys to select the operating system you want and type e to select it. Follow the next procedure to change your boot options temporarily.

If you want to change your boot options so that they take effect every time you boot your computer, see the section on permanently changing boot options. Changing those options involves editing the /boot/grub/grub.conf file.

Temporarily Changing Boot Options

From the GRUB boot screen, you can select to change or add boot options for the current boot session. First, quickly before GRUB times out and boots the default system, press Enter. From the GRUB selection screen that appears, select the operating system you want (using the arrow keys) and type e (as described earlier). You will see a graphical screen that contains information like the following:

image from book
Figure 2-3: Edit the boot entry from your Fedora system from the GRUB menu.

There are three lines in the example of the GRUB editing screen that identify the boot process for the operating system you chose. The first line (beginning with root ) shows that the entry for the GRUB boot loader is on the first partition of the first hard disk ( hd0,0 ). GRUB represents the hard disk as hd , regardless of whether it is a SCSI, IDE, or other type of disk. You just count the drive number and partition number, starting from zero.

The second line of the example (beginning with kernel ) identifies the boot image ( /boot/vmlinuz-2.6.17-1.2647.fc6 ) and several options. The options identify the partition as initially being loaded ro (read-only) and the location of the root file system on a partition with the label LABEL=/ . The third line (starting with initrd ) identifies the location of the initial RAM disk, which contains the minimum files and directories needed during the boot process.

If you are going to change any of the lines related to the boot process, you would probably change only the second line to add or remove boot options. Here is how you do that:

  1. Position the cursor on the kernel line and type e .

  2. Either add or remove options after the name of the boot image. You can use a minimal set of bash shell command-line editing features to edit the line. You can even use command completion (type part of a filename and press Tab to complete it). Here are a few options you may want to add or delete:

    • Boot to a shell - If you forgot your root password or if your boot process hangs , you can boot directly to a shell by adding init=/bin/sh to the boot line. (The file system is mounted read-only, so you can copy files out. You need to remount the file system with read/write permission to be able to change files.)

    • Turn off a service - If your boot process is hanging on a particular service, you can often turn off that service from the boot prompt. For example, you could add the options noacpi (to turn off ACPI power management), nopcmcia (to turn off PCMCIA card slot support), or nodma (to turn of DMA, if you are getting disk errors). Add selinux=0 to temporarily turn off SELinux. Sometimes turning off a service at the boot prompt allows you to fix the problem after the system is up and running.

    • Select a run level - If you want to boot to a particular run level, you can add the word linux, followed by the number of the run level you want. For example, to have Fedora boot to run level 3 (multiuser plus networking mode), add linux 3 to the end of the boot line. You can also boot to single-user mode (1), multi-user mode (2), or X GUI mode (5). Level 3 is a good choice if your GUI is temporarily broken.

  3. Press Enter to return to the editing screen.

  4. Type b to boot the computer with the new options. The next time you boot your computer, the new options will not be saved. To add options so they are saved permanently, see the next section.

Permanently Changing Boot Options

You can change the options that take effect each time you boot your computer by changing the GRUB configuration file. In Fedora, GRUB configuration centers around the /boot/grub/grub.conf file.

The /boot/grub/grub.conf file is created when you install Fedora. Here is an example of a grub.conf file:

 # 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/hda6 # initrd /initrd-version.img #boot=/dev/hda default=0 timeout=5 splashimage=(hd0,1)/boot/grub/splash.xpm.gz hiddenmenu title Fedora Core (2.6.17-1.2647.fc6) root (hd0,1) kernel /vmlinuz-2.17-1.2647.fc6 ro root=LABEL=/1 initrd /initrd-2.6.17-1.2647.fc6.img title Windows XP rootnoverify (hd0,0) chainloader +1 

The default=0 line indicates that the first partition in this list (in this case Fedora Core) will be the one that is booted by default. The line timeout=5 causes GRUB to pause for 5 seconds before booting the default partition. (Because of the hiddenmenu option, you won't even see the GRUB boot screen if you don't press Enter before 5 seconds.)

Note 

GRUB indicates disk partitions using the following notation: ( hd0,0 ). The first number represents the disk, and the second is the partition on that disk. So, ( hd0,1 ) is the second partition (1) on the first disk (0). That would equate to /dev/hda2 in Linux.

The splashimage line looks in the second partition on the first disk ( hd0,1 ) for the boot partition (in this case /dev/hda2 , which is the /boot partition). GRUB loads splash.xpm.gz as the image on the splash screen ( /boot/grub/splash.xpm.gz ). The splash screen appears as the background of the boot screen.

Note 

You can replace the splash screen with any image you like, provided that it meets certain specifications. Using GIMP or other image editor, save the image to 640x480 pixels, 14 colors, and xpm format. Next, use gzip to compress the file. Then copy that file to the /boot/grub directory. The last step is to edit the grub.conf file to have the splashimage value point to the new file.

The two bootable partitions in this example are Fedora Core and Windows XP . The title lines for each of those partitions are followed by the name that appears on the boot screen to represent each partition.

For the Fedora Core system, the root line indicates the location of the boot partition as the second partition on the first disk. So, to find the bootable kernel ( vmlinuz-2.6.17-1.2647.fc6 ) and the initrd initial RAM disk boot image that is loaded ( initrd-2.6.17-1.2647.fc6.img ), GRUB looks in the root of hd0,1 (which is represented by /dev/hda2 and is eventually mounted as /boot ). Other options on the kernel line set the partition as read-only initially ( ro ) and set the root file system to LABEL=/1.

For the Windows XP partition, the rootnoverify line indicates that GRUB should not try to mount the partition. In this case, Windows XP is on the first partition of the first hard disk (hd0,0) or /dev/hda1 . Instead of mounting the partition and passing options to the new operating system, the chainloader +1 indicates to hand control the booting of the operating system to another boot loader. The +1 indicates that the first sector of the partition is used as the boot loader.

Note 

Microsoft operating systems require that you use the chainloader to boot them from GRUB.

If you make any changes to the /boot/grub/grub.conf file, you do not need to load those changes. Those changes are automatically picked up by GRUB when you reboot your computer. If you are accustomed to using the LILO boot loader, this may confuse you at first, as LILO requires you to rerun the lilo command for the changes to take effect.

Adding a new GRUB Boot Image

You may have different boot images for kernels that include different features. These days, as you get updated kernels for Fedora or RHEL, you simply load an RPM containing the new kernel and that new kernel is added to the grub.conf file as the default kernel to be booted. At boot time, you can choose which kernel you want to run.

Note 

To prevent you from having dozens of entries on your boot screen and lots of kernels hanging around, when you install new kernels on your Fedora system, all but the two most recent kernels are removed. Likewise, instead of getting lots of boot entries as you add new kernels, only the two most recent kernel entries are maintained in your grub.conf file.

If you build your own kernel, however, or get one to use from another source, you need to modify the grub.conf file yourself to tell Fedora or RHEL to boot that kernel. Here is the procedure for modifying the grub.conf file:

  1. Copy the new image from the directory in which it was created (such as /usr/src/kernels/linux-2.6.15-1/arch/i386/boot ) to the /boot directory. Name the file something that reflects its contents, such as bz-2.6.15-1 . For example:

     #  cp /usr/src/linux-2.6.15-1/arch/i386/boot/bzImage /boot/bz-2.6.11-5  
  2. Add several lines to the /boot/grub/grub.conf file so that the image can be started at boot time if it is selected. For example:

     title Fedora Core (My own IPV6 build) root (hd0,1) kernel /bz-2.6.17-1 ro root=/dev/hda2 initrd /initrd-2.6.17-1.img 
  3. Reboot your computer.

  4. Press Enter at the boot prompt. When the GRUB boot screen appears, move your cursor to the title representing the new kernel and press Enter.

The advantage to this approach, as opposed to copying the new boot image over the old one, is that if the kernel fails to boot, you can always go back and restart the old kernel. When you feel confident that the new kernel is working properly, you can use it to replace the old kernel or perhaps just make the new kernel the default boot definition.

Booting Your Computer with LILO

If you are used to using LILO as your boot loader for Fedora, I'm afraid you are out of luck at the moment. It was dropped as of the Fedora Core 5 distribution and, though this may change, there are no plans to make it available for Fedora in Fedora Extras. However, if you use Red Hat Enterprise Linux 4, LILO is still available. For that reason, I have included the description of LILO in this section.

LILO stands for LInux LOader. Like other boot loaders, LILO is a program that can stand outside the operating systems installed on the computer so you can choose which system to boot. It also lets you give special options that modify how the operating system is booted.

If LILO is being used on your computer, it is installed in either the master boot record or the first sector of the root partition. The master boot record is read directly by the computer's BIOS. In general, if LILO is the only loader on your computer, install it in the master boot record. If there is another boot loader already in the master boot record, put LILO in the root partition.

Using LILO

When your computer boots with the RHEL version of LILO installed in the master boot record, a graphical RHEL screen appears, displaying the bootable partitions on the computer. Use the up and down arrow keys on your keyboard to select the one you want and press Enter. Otherwise, the default partition that you set at installation will boot after a few seconds.

If you want to add any special options when you boot, press Ctrl+X. You will see a text-based boot prompt that appears as follows:

 boot: 

LILO pauses for a few seconds and then automatically boots the first image from the default bootable partition. To see the bootable partitions again, quickly press Tab. You may see something similar to the following:

 LILO boot: linux linux-up dos boot: 

This example shows that three bootable partitions are on your computer, called linux , linux-up , and dos . The first two refer to two different boot images that can boot the Linux partition. The third refers to a bootable DOS partition (presumably containing a Windows operating system). The first bootable partition is loaded if you don't type anything after a few seconds. Or you could type the name of the other partition to have that boot instead.

If you have multiple boot images, press Shift, and LILO will ask you which image you want to boot. Available boot images and other options are defined in the /etc/lilo.conf file.

Setting Up the /etc/lilo.conf File

The /etc/lilo.conf file is where LILO gets the information it needs to find and start bootable partitions and images. By adding options to the /etc/lilo.conf file, you can change the behavior of the boot process. The following is an example of some of the contents of the /etc/lilo.conf file:

Note 

Because LILO is not used by default, there is no /etc/lilo.conf file. However, the RHEL installation program creates an /etc/lilo.conf.anaconda file to suit your installation. If you change from GRUB to LILO, you can copy that file to /etc/lilo.conf .

 prompt timeout=50 default=linux boot=/dev/hda map=/boot/map install=/boot/boot.b message=/boot/message linear image=/boot/vmlinuz-2.6.8-1.541 label=linux initrd=/boot/initrd-2.6.8-1.541.img read-only root=/dev/hda6 append="root=LABEL=/" other=/dev/hda1 optional label=dos 

With prompt on, the boot prompt appears when the system is booted without requiring that any keys are pressed. The timeout value, in this case 50 tenths of a second (5 seconds), defines how long to wait for keyboard input before booting the default boot image. The boot line indicates that the bootable partition is on the hard disk represented by /dev/hda (the first IDE hard disk).

The map line indicates the location of the map file ( /boot/map , by default). The map file contains the name and locations of bootable kernel images. The install line indicates that the /boot/boot.b file is used as the new boot sector. The message line tells LILO to display the contents of the /boot/message file when booting (that contains the graphical RHEL boot screen that appears). The linear line causes linear sector addresses to be generated (instead of sector/head/cylinder addresses).

In the sample file, there are two bootable partitions. The first ( image=/boot/vmlinuz-2.6.8-1.541 ) shows an image labeled linux . The root file system ( / ) for that image is on partition /dev/hda6 . Read-only indicates that the file system is first mounted read-only, although it is probably mounted as read/write after a file system check. The initrd line indicates the location of the initial RAM disk image used to start the system.

The second bootable partition, which is indicated by the word other in this example, is on the /dev/hda1 partition. Because it is a Windows XP system, it is labeled a DOS file system. The table line indicates the device that contains the partition.

Other bootable images are listed in this file, and you can add another boot image yourself (like one you create from reconfiguring your kernel as discussed in the next section) by installing the new image and changing lilo.conf .

After you change lilo.conf , you then must run the lilo command for the changes to take effect. You may have different boot images for kernels that include different features. Here is the procedure for modifying the lilo.conf file:

  1. Copy the new kernel image from the directory in which it was created (such as /usr/src/linux-2.6/arch/i386/boot ) to the /boot directory. Name the file something that reflects its contents, such as zImage-2.6.8-1 .

  2. Add several lines to the /etc/lilo.conf file so that the image can be started at boot time if it is selected. For example:

     image=/boot/zImage-2.6.8-1 label=new 
  3. Type the lilo -t command (as root user) to test that the changes were okay.

  4. Type the lilo command (with no options) for the changes to be installed.

To boot from this new image, either select new from the graphical boot screen or type new and press Enter at the LILO boot prompt. If 5 seconds is too quick, increase the timeout value (such as 100 for 10 seconds).

Options that you can use in the /etc/lilo.conf file are divided into global options, per-image options, and kernel options. A lot of documentation is available for LILO. For more details on any of the options described here or for other options, you can see the lilo.conf manual page (type man lilo.conf ) or any of the documents in /usr/share/doc/lilo*/doc .

A few examples follow of global options that you can add to /etc/lilo.conf . Global options apply to LILO as a whole, instead of just to a particular boot image.

You can use the default=label option, where label is replaced by an image's label name, to indicate that a particular image be used as the default boot image. If that option is excluded, the first image listed in the /etc/lilo.conf file is used as the default. For example, to start the image labeled new by default, add the following line to lilo.conf :

 default=new 

Change the delay from 5 seconds to something greater if you want LILO to wait longer before starting the default image. This gives you more time to boot a different image. To change the value from 5 seconds (50) to 15 seconds (150), add the following line:

 delay=150 

You can change the message that appears before the LILO prompt by adding that message to a file and changing the message line. For example, you could create a /boot/boot.message file and add the following words to that file: Choose linux, new, or dos . To have that message appear before the boot prompt, add the following line to /etc/lilo.conf :

 message=/boot/boot.message 

All per-image options begin with either an image= line (indicating a Linux kernel) or other= (indicating some other kind of operating system, such as Windows XP). The per-image options apply to particular boot images rather than to all images (as global options do). Along with the image or other line is a label= line, which gives a name to that image. The name is what you would select at boot time to boot that image. Here are some of the options that you can add to each of those image definitions:

  • lock - This enables automatic recording of boot command lines as the defaults for different boot options.

  • alias= name - You can replace name with any name. That name becomes an alias for the image name defined in the label option.

  • password= password - You can password-protect the image by adding a password option line and replacing password with your own password. The password would have to be entered to boot the image.

  • restricted - This option is used with the password option. It indicates that a password should be used only if command-line options are given when trying to boot the image.

For Linux kernel images, there are specific options that you can use. These options let you deal with hardware issues that can't be autodetected, or provide information such as how the root file system is mounted. Here are some of kernel image-specific options:

  • append - Add a string of letters and numbers to this option that need to be passed to the kernel. In particular, these can be parameters that need to be passed to better define the hard disk when some aspect of that disk can't be autodetected.

  • ramdisk - Add the size of the RAM disk that you want to use so as to override the size of the RAM disk built into the kernel.

  • read-only - Indicates to mount the root file system read-only. It is typically remounted read-write after the disk is checked.

  • read-write - Indicates to mount the root file system read/write.

Changing Your Boot Loader

If you don't want to use the GRUB boot loader, or if you tried out LILO and want to switch back to GRUB, it's not hard to change to a different boot loader. To switch your boot loader from GRUB to LILO, do the following:

  1. Configure the /etc/lilo.conf file as described in the "Booting your computer with LILO" section. (Use the contents of /etc/lilo.conf.anaconda to start.)

  2. As root user from a Terminal window, type the following:

     #  lilo  
  3. The new Master Boot Record is written, including the entries in /etc/lilo.conf .

  4. Reboot your computer. You should see the LILO boot screen.

To change your boot loader from LILO to GRUB, do the following:

  1. Configure the /boot/grub/grub.conf file as described in the "Booting your computer with GRUB" section.

  2. You need to know the device on which you want to install GRUB. For example, to install GRUB on the master boot record of the first disk, type the following as root user from a Terminal window:

     #  grub-install /dev/hda  

    The new Master Boot Record is written to boot with the GRUB boot loader.

  3. Reboot your computer. You should see the GRUB boot screen.




Fedora 6 and Red Hat Enterprise Linux Bible
Fedora 6 and Red Hat Enterprise Linux Bible
ISBN: 047008278X
EAN: 2147483647
Year: 2007
Pages: 279

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