Allocating a Windows Disk Partition to RHEL 5

From Techotopia
Revision as of 19:57, 17 June 2019 by Neil (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
PreviousTable of ContentsNext
Installing RHEL 5 with Windows in Dual Boot EnvironmentLogging into the RHEL 5 GNOME Desktop


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


In the previous chapter we looked at how to install Red Hat Enterprise Linux on the same disk as Windows. This so called "dual boot" configuration allows the user to have both operating systems installed on a single disk drive with the option to boot one or the other when the system is powered on. Performing this type of installation was covered in Installing RHEL 5 with Windows in Dual Boot Environment.

This chapter is intended for users who have decided they like RHEL enough to delete Windows entirely from the disk, and use the resulting space for Linux. In the following sections we will work through this process step by step.


Contents


Deleting the Windows Partition from the Disk

The first step in freeing up the Windows partition for use by RHEL is to delete that partition. Before doing so, however, it is imperative that any data you need to keep is backed up from both the Windows and RHEL partitions. Having done that, it is safe to proceed with this chapter.

In order to remove the Windows partition we first need to identify it using the fdisk tool:

# fdisk -l

Disk /dev/sda: 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/sda1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2              13        1719    13699072    7  HPFS/NTFS
/dev/sda3            1720        1731       96390   83  Linux
/dev/sda4            1732        2610     7060567+   5  Extended
/dev/sda5            1732        2610     7060536   8e  Linux LVM

In the above example output the system contains one physical disk drive referenced by device name /dev/sda. On that disk drive are three partitions accessed via the device names /dev/sda1 through /dev/sda5 respectively. Based on the values in the System column, there are two NTFS partitions. The first is very small and marked as bootable so clearly contains the boot record. The second, much larger, NTFS partition is the one containing the Windows operating system and user data that we plan to remove. Note that a FAT partition also indicates the presence of a Windows installation. Make a note of the Start and End addresses as these will be needed when we recreate a new Linux partition in the freed space.

To remove the partition, start the fdisk tool using the device name of the disk containing the partition (/dev/sda in this instance):

# fdisk /dev/sda

The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

At the command prompt, delete the Windows partition (which is partition 2 on our example system):

Command (m for help): d
Partition number (1-5): 2

Command (m for help):

Now that we have deleted the Windows partition we now need to create the new RHEL partition in the vacated disk space. The partition number must match the number of the partition removed (in this case 2) and is going to be a primary partition. It will also be necessary to enter the Start and End values of the partition exactly as they were reported for the old partition:

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
p
Selected partition 2
First cylinder (13-2610, default 13): 13
Last cylinder or +size or +sizeM or +sizeK (13-1719, default 1719):
Using default value 1719

Command (m for help):

Having made these changes the next step is to check that the settings are correct:

Command (m for help): p

Disk /dev/sda: 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/sda1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2              13        1719    13704443+  83  Linux
/dev/sda3            1720        1731       96390   83  Linux
/dev/sda4            1732        2610     7060567+   5  Extended
/dev/sda5            1732        2610     7060536   8e  Linux LVM

To commit the changes we now need to write the new partition information to disk and quit from the fdisk tool:

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

If you see a warning similar to the one indicated in the above output you will need to reboot your RHEL system to be sure the new partition table information is picked up by the system kernel before proceeding.

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

Formatting the Unallocated Disk Partition

In order to make the new partition suitable for use by RHEL, it needs to have a file system created on it. The default file system type for the current releases of RHEL 5 is ext3. Creation of the file system performed using the mkfs command as follows:

# mkfs -t ext3 /dev/sda2
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1713600 inodes, 3426110 blocks
171305 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3510632448
105 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Editing the Boot Menu

The next step is to modify the boot menu. Since this was originally a dual boot system, the menu is configured to provide the option of booting either Windows or RHEL. Now that the Windows partition is gone, we need to remove this boot option. This is achieved by editing the menu.lst as follows:

su - 
gedit /boot/grub/menu.lst

Towards the bottom of the grub.conf file you will see a section similar to:

title Windows
        rootnoverify (hd0,0)
        chainloader +1

Delete this section from the file. Also check to see the default= value to make sure the default is not set to the partition which was just deleted. Save the file once the changes have been made.

Mounting the New Partition

Finally, we need to mount the new partition. In this example we will mount it in a directory named /data. You are free, however, to mount the new partition using any valid mount point you desire or to use it as part of a logical volume. First we need to create the directory to act as the mount point:

su - 
mkdir /data

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

Secondly, we need to edit the mount table so that the partition is automatically mounted each time system starts:

gedit /etc/fstab

At the bottom of the /etc/fstab file, add the following line to mount the new partition (modifying the /dev/sda2 device to match your environment):

/dev/sda2 /data ext3 defaults 0 0

Finally, we can manually mount the new partition (note that on subsequent reboots this will not be necessary as the partition will automount as a result of the setting we added to the /etc/fstab file above). mount /data

To check the partition, try running the following command to display the available space:

df -h /data

You should see output similar to:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              13G  161M   13G   2% /data


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
Installing RHEL 5 with Windows in Dual Boot EnvironmentLogging into the RHEL 5 GNOME Desktop