Installing RHEL 5 with Windows in Dual Boot Environment

From Techotopia
Revision as of 14:31, 5 May 2016 by Neil (Talk | contribs) (Text replacement - "<table border="0" cellspacing="0" width="100%">" to "<table border="0" cellspacing="0">")

Jump to: navigation, search
PreviousTable of ContentsNext
Performing an RHEL 5 Network InstallationAllocating a Windows Disk Partition to RHEL 5


You are reading a sample chapter from the RHEL 5 Edition book.

Purchase the fully updated Red Hat Enterprise Linux 8 (RHEL 8) Edition of this publication in eBook ($9.99) or Print ($36.99) format

Red Hat Enterprise Linux 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 250 pages

Buy Print Preview Book


Red Hat Enterprise Linux 5, just like most Linux distributions, will happily co-exist on a hard disk drive with just about any version of Windows up to and including Windows 7. This is a concept known as dual-booting. Essentially, when you power up your PC you will be presented with a menu providing the option to boot either your RHEL installation or Windows. Obviously you can only run one operating system at a time, but it is worth noting that the files on the Windows partition of your disk drive will be available to you from RHEL regardless of whether your Windows partition was formatted using NTFS, FAT16 or FAT32.

This installation method involves shrinking the size of the existing Windows partition to accommodate the installation of RHEL. How you go about doing this will depend on the version of Windows currently installed on the disk.


Contents


Partition Resizing

In order to accommodate RHEL on a disk drive that already contains a Windows installation the first step involves shrinking the Windows partition to make some room. If you are running Windows Vista, Windows 7 or Windows Server 2008 the recommended course of action is to use the Windows Disk Management interface to reduce the size of the partition before attempting to install RHEL 5. You can generally access this by right clicking on the Computer icon and selecting Manage from the popup menu. Within the Computer Management interface, select Disk Management to display a graphical representation of the disk drives in your system:


The Windows Disk Management Tool


Right click on the partition you wish to reduce and select Shrink Volume. The tool will calculate the maximum amount by which the volume can be shrunk without data loss (a process that can take several minutes depending on the overall size of the partition).

Once this analysis is complete, a dialog similar to the one in the following figure will appear:

Shrinking a Windows NTFS partition


Enter into the Total size after shrink in MB field the new target size for the partition and click on Shrink to proceed. Once the resizing operation is complete, reboot using the RHEL 5 installation media (as outlined in Installing RHEL on a Clean Disk Drive) and proceed with the installation. When prompted to decide on where RHEL is to be installed be sure to select the Use free space on selected drives and create default layout option.

Shrinking a Windows XP Partition

Whilst it is possible to shrink existing Windows partitions using the Windows Disk Management tool on recent versions of Windows, this is not possible from within Windows XP. If you need to shrink a Windows XP partition in order to install RHEL, one option is to use one of the commercially available partitioning tools such as PartitionMagic. If you would prefer not to buy a partitioning tool, the repartitioning may also be performed from within a Linux Live CD distribution using the fdisk and ntfsresize utilities. A Linux Live CD is a CDROM from which a Linux distribution can be booted and run without the necessity to install the operating system on a disk drive. Whilst Red Hat Enterprise Linux 5 is not available as a Live CD, many other Linux distributions are. Perhaps the best option under these circumstances is to use the CentOS Live CD. CentOS is built from the Red hat Enterprise Linux source code (with the Red Hat branding removed) so establishes a high level of compatibility.

Before attempting this resizing technique it is vital that you back up all essential data from your Windows XP system. In this section we will be performing some low level disk partitioning activities using command line tools. Whilst following these steps is an invaluable method for learning about the structure of disk partitions, it is important that you understand that errors in performing the following the steps may result in loss of data. With that warning out of the way we can proceed. The CentOS Live CD image can be downloaded from the mirror sites listed on the CentOS web site at:

http://mirror.centos.org/centos/5/isos/

Once you have loaded this page into your browser, select either the i386 or x86_64 link depending on whether the target system is a 32-bit or 64-bit platform. Within the next screen select a mirror from the list and look for a link to download the Live CD image. This will typically be named as follows:

CentOS-<version>-<architecture>-LiveCD.iso

Once you have downloaded the image, burn it to a CD, then make sure your BIOS is configured to boot from the CDROM/DVD drive before the hard disk and then boot from the CD. The system will boot CentOS and you will have a fully functional CentOS environment to use during the repartitioning process.

Once CentOS has loaded, log in and open a terminal window (right click anywhere on the desktop and select Open Terminal). In the terminal window, gain root privileges by executing the following command:

su –

The fdisk tool is installed by default but the ntfsresize tool is not part of the standard CentOS distribution or installation repositories. Instead, we need to install from a different source. To enable access to the required repository, one of the following commands must be run depending on whether you are running a 32-bit or 64-bit version of CentOS:

For 32-bit systems:

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

For 64-bit systems:

rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

Next, we need to install the package that contains the ntfsresize utility:

yum install ntfsprogs

Now that we have installed the tools we need, the next step is to identify the disk drive on which the Windows XP partition resides. This is achieved by running the fdisk command as follows:

[root@livecd ~]# fdisk –l

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        2609    20956761    7  HPFS/NTFS

As we can see, in the case of the above example we have a single disk drive (/dev/hda) that contains a single partition (/dev/hda1) that is formatted as NTFS (a sure sign that is a Windows partition). Since the Boot column contains an asterisk we also know this is a bootable partition. Clearly the partition we want to shrink is /dev/hda1. Depending on your system configuration you may see different results (for example if you have multiple disk drives).

Having identified the disk and partition we now need to find out how much unused space is available within the partition for us to free up. To obtain this information we use the ntfsresize tool as follows:

root@livecd ~]# ntfsresize -i /dev/hda1
ntfsresize v1.13.1 (libntfs 9:0:0)
Device name        : /dev/hda1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 21459722752 bytes (21460 MB)
Current device size: 21459723264 bytes (21460 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 2047 MB (9.5%)
Collecting resizing constraints ...
You might resize at 3232108544 bytes or 3233 MB (freeing 18227 MB).
Please make a test run using both the -n and -s options before real resizing!

The output from ntfsresize for our example tells us that we can safely free up 18277MB of disk space by shrinking the Windows partition. In practice you will want to leave space on your Windows system for storing future data, so it is recommended that you do not shrink the partition to the full extent available. For the purposes of this example we will shrink the partition to 6000MB. Before performing the live resize, it is best to run through a simulation in order to identify any problems before permanent changes are made. To do this, run ntfsresize with the –no-action option:

[root@livecd ~]# ntfsresize --no-action -b --size 6000M /dev/hda1
ntfsresize v1.13.1 (libntfs 9:0:0)
Device name        : /dev/hda1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 21459722752 bytes (21460 MB)
Current device size: 21459723264 bytes (21460 MB)
New volume size    : 5999993344 bytes (6000 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 2047 MB (9.5%)
Collecting resizing constraints ...
Needed relocations : 21547 (89 MB)
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Relocating needed data ...
100.00 percent completed
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
The read-only test run ended successfully.

Assuming the read-only test runs successfully, the actual resize can be performed by running the same command, but this time without the –no-action option:

[root@livecd ~]# ntfsresize -b --size 6000M /dev/hda1
ntfsresize v1.13.1 (libntfs 9:0:0)
Device name        : /dev/hda1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 21459722752 bytes (21460 MB)
Current device size: 21459723264 bytes (21460 MB)
New volume size    : 5999993344 bytes (6000 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 2047 MB (9.5%)
Collecting resizing constraints ...
Needed relocations : 21547 (89 MB)
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])? y
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Relocating needed data ...
100.00 percent completed
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device '/dev/hda1'.
You can go on to shrink the device for example with Linux fdisk.
IMPORTANT: When recreating the partition, make sure that you
  1)  create it at the same disk sector (use sector as the unit!)
  2)  create it with the same partition type (usually 7, HPFS/NTFS)
  3)  do not make it smaller than the new NTFS filesystem size
  4)  set the bootable flag for the partition if it existed before
Otherwise you won't be able to access NTFS or can't boot from the disk!
If you make a mistake and don't have a partition table backup then you
can recover the partition table by TestDisk or Parted's rescue mode.

At this point we have reduced the size of the NTFS partition but the partition does not yet know we have done so. If, for example, we use fdisk to tell us about the partition the partition table information still indicates the original size:

[root@livecd ~]# fdisk -l

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        2609    20956761    7  HPFS/NTFS

In order to address this we will have to delete the partition information and then recreate it with the new size information. Before doing so, make a note of the Start and Id values for the partition provided by the above fdisk command (yours will possibly differ from the example and we will need these when we recreate the partition). Begin by starting fdisk with the name of the disk drive on which we are going to modify the partition table information:

[root@livecd ~]# fdisk /dev/hda

At the command prompt, delete the partition (for the example this is partition 1 but may be different on your system):

Command (m for help): d
Selected partition 1

Next, we need to recreate the partition with the new size information (keeping in mind that we reduced the partition to 6000MB):

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +6000M

Next, the Id of the partition needs to set to the original value as indicated by the fdisk –l command (in this case 7 to indicate the partition uses the Windows NTFS format):

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 7
Changed system type of partition 1 to 7 (HPFS/NTFS)

Finally, we need to make sure the partition is still bootable:

Command (m for help): p

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1         730     5863693+   7  HPFS/NTFS

If the Boot column does not contain an asterisk (*) then we need to make the partition bootable before we write the new configuration disk:

Command (m for help): a
Partition number (1-4): 1

Once again, it is prudent to check the settings before proceeding:

Command (m for help): p

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         730     5863693+   7  HPFS/NTFS

If all is well, write the new partition information to disk:

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

The resize is now complete and you can reboot the system. If you check the disk volumes in the Windows XP disk manager (right click on My Computer, select Manage and choose Disk Management from the Computer Management tool). The newly freed space will be displayed as Unallocated.

Having resized the partition, reboot using the RHEL installation media (as outlined in Installing RHEL on a Clean Disk Drive) and proceed with the installation. When prompted to decide on where RHEL is to be installed be sure to select the Use free space on selected drives and create default layout option.


Choosing an Operating System at Boot Time

Once the installation completes, the system will display the standard boot countdown screen. Pressing any key on the keyboard at this point will display the boot menu screen as illustrated in the following figure:


The RHEL boot menu with Red Hat Enterprise Linux and Windows boot options


This menu provides the option of booting either "Red Hat Enterprise Linux Server" or "Other". In this instance, selecting "Other" will boot your original Windows installation. In the next section we will cover the steps to modify this menu to change the boot default and rename the "Other" menu option to something more descriptive.

Editing the RHEL Boot Menu

Once you have logged into the system and the desktop is visible the next step is to configure the boot menu so that it lists the alternate operating system as Windows instead of Other. The boot menu configuration settings are stored in the /boot/grub/menu.lst file. This file may be edited in a terminal window as follows:

su -
gedit /boot/grub/menu.lst

When prompted by the su command to enter a password be sure to enter the root password created during the installation process, not the password you created for your user account during the setup agent configuration steps.

The contents of a typical menu.lst file is listed below:

# 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,2)
#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,2)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-194.el5)
        root (hd0,2)
        kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.18-194.el5.img
title Other
        rootnoverify (hd0,0)
        chainloader +1

The above menu.lst file contains options to boot from two operating systems. The RHEL section of the configuration typically reads as follows:

 
# 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,2)
#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,2)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-194.el5)
        root (hd0,2)
        kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.18-194.el5.img
title Other
        rootnoverify (hd0,0)
        chainloader +1

The Windows section of the configuration is likely to be similar to the following:

title Other
        rootnoverify (hd0,0)
        chainloader +1

The default=0 line indicates that the first entry in the file is to be default operating systems (in other words, the operating system that will boot by default if the user does not intervene during the boot phase). The timeout=5 directive specifies the number of seconds the boot screen is displayed before the default operating system is automatically booted.

To configure the system to boot Windows by default simply change this line so that it reads as follows:

default=1

To increase or decrease the timeout before the default operating system boots, change the timeout value (in this case to 20 seconds):

timeout=20

The final task in our dual boot configuration process is to rename the Windows boot option to something more descriptive than "Other". To achieve this, simply change the "Other" line as follows:

title Windows

Note that the title value can be anything you choose.

The next time the system is rebooted, the boot screen will wait 20 seconds before auto-booting. If no keys are pressed the system will now boot Windows by default, instead of RHEL. If the user does intervene and display the boot menu, the Windows option is now titled "Windows" and not "Other".

Accessing the Windows Partition from RHEL

When running RHEL in a dual boot configuration it is still possible to access files located on the Windows partition. This can be achieved by manually mounting the partition from the command-line. Before doing so, however, some additional packages need to be installed on the system. To do so, run the following commands inside a terminal window:

su -
yum install fuse

Next, we need to set up access to the Dag RPMForge repositories:

For 32-bit systems:

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

For 64-bit systems:

rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

Next, install the NTFS driver:

yum install fuse-ntfs-3g

Once the requisite packages are installed, the next step is to create a directory to use as the mount point for our Windows partition. In this example we will create a directory called /windows:

mkdir /windows

When prompted for a password by the su command, enter the root password specified during the RHEL installation process. Next, we need to run the mount command (still with root privileges and assuming the Windows partition is /dev/sda2 and NTFS format - this may be different on your system):

mount –t ntfs-3g /dev/sda2 /windows

Under some circumstances you may get a message that the Windows partition needs to be checked. If so, either reboot into Windows again and manually run chkdsk (if it does not run automatically during the boot process), or force the mount with the –o option:

mount /dev/sda2 /windows -o force

To automate the mount each time the system is booted, simply add the mount line to the /etc/fstab file:

/dev/sda2 /windows ntfs defaults 0 0

To unmount the Windows file system at any time:

umount /windows


You are reading a sample chapter from the RHEL 5 Edition book.

Purchase the fully updated Red Hat Enterprise Linux 8 (RHEL 8) Edition of this publication in eBook ($9.99) or Print ($36.99) format

Red Hat Enterprise Linux 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 250 pages

Buy Print Preview Book



PreviousTable of ContentsNext
Performing an RHEL 5 Network InstallationAllocating a Windows Disk Partition to RHEL 5