Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

39.2.2. Your computer dual-boots Red Hat Enterprise Linux and a different Linux distribution

Because of the differences between the many different Linux distributions, these instructions are a general guide only. Specific details vary according to the configuration of your particular system and the Linux distribution that dual-boots with Red Hat Enterprise Linux.
  1. Remove Red Hat Enterprise Linux partitions

    1. Boot your Red Hat Enterprise Linux installation.
    2. As root or with sudo, run mount. Note the partitions that are mounted. In particular, note the partition that is mounted as the root of the filesystem. The output of mount on a system where the root of the filesystem is on a standard partition such as /dev/sda2 might resemble:
      /dev/sda2 on / type ext4 (rw)
      proc on /proc type proc (rw)
      sysfs on /sys type sysfs (rw)
      devpts on /dev/pts type devpts (rw,gid=5,mode=620)
      tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
      /dev/sda1 on /boot type ext4 (rw)
      none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
      sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
      The output of mount on a system where the root of the filesystem is on a logical volume might resemble:
      /dev/mapper/VolGroup00-LogVol00 on / type ext4 (rw)
      proc on /proc type proc (rw)
      sysfs on /sys type sysfs (rw)
      devpts on /dev/pts type devpts (rw,gid=5,mode=620)
      tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
      /dev/sda1 on /boot type ext4 (rw)
      none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
      sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
    3. Ensure that any data on this system that you still require is backed up to another system or storage location.
    4. Shut down the system and boot the Linux distribution that you want to keep on the system.
    5. As root or with sudo, run mount. If any of the partitions that you previously noted as used for Red Hat Enterprise Linux are mounted, review the contents of these partitions. If you no longer require the contents of these partitions, unmount them with the umount command.
    6. Remove any unwanted and unnecessary partitions, for example, with fdisk for standard partitions, or lvremove and vgremove to remove logical volumes and volume groups.
  2. Remove Red Hat Enterprise Linux entries from your bootloader

    Important

    These instructions assume that your system uses the GRUB bootloader. If you use a different bootloader (such as LILO) consult the documentation for that software to identify and remove Red Hat Enterprise Linux entries from its list of boot targets and to ensure that your default operating system is correctly specified.
    1. At the command line, type su - and press Enter. When the system prompts you for the root password, type the password and press Enter.
    2. Type gedit /boot/grub/grub.conf and press Enter. This opens the grub.conf file in the gedit text editor.
    3. A typical Red Hat Enterprise Linux entry in the grub.conf file consists of four lines:

      Example 39.1. Example Red Hat Enterprise Linux entry in grub.conf

      title Red Hat Enterprise Linux (2.6.32.130.el6.i686)
      root (hd0,1)
      kernel /vmlinuz-2.6.32.130.el6.i686 ro root=UUID=04a07c13-e6bf-6d5a-b207-002689545705 rhgb quiet
      initrd /initrd-2.6.32.130.el6.i686.img
      Depending on the configuration of your system, there may be multiple Red Hat Enterprise Linux entries in grub.conf, each corresponding to a different version of the Linux kernel. Delete each of the Red Hat Enterprise Linux entries from the file.
    4. Grub.conf contains a line that specifies the default operating system to boot, in the format default=N where N is a number equal to or greater than 0. If N is set to 0, GRUB will boot the first operating system in the list. If N is set to 1, it will boot the second operating system, and so forth.
      Identify the entry for the operating system that you want GRUB to boot by default and note its place in the order within the list.
      Make sure that the default= line contains the number one below the number of your chosen default operating system in the list.
      Save the updated grub.conf file and close gedit
  3. Make space available to your operating system

    Note

    This step is not required to remove Red Hat Enterprise Linux from your computer. However, if you skip this step, you will leave part of your hard drive's storage capacity unusable by your other Linux operating system. Depending on your configuration, this might be a significant portion of the storage capacity of the drive.

    Note

    To carry out this step, you require live media for a Linux distribution, for example, the Fedora Live CD or the Knoppix DVD.
    The method to make the space freed by removing the Red Hat Enterprise Linux partitions available to your other Linux operating system differs, depending on whether your chosen operating system is installed on disk partitions configured to use Logical Volume Management (LVM) or not.
    • If you do not use LVM

      1. Boot your computer from Linux live media, and install parted if it is not already present.
      2. As root or with sudo, run parted disk, where disk is the device name of the disk that contains a partition that you want to resize, for example, /dev/sda.
      3. At the (parted) prompt, enter print. The parted tool displays information about the partitions on your system, including their partition numbers, their sizes, and their positions on the disk.
      4. At the (parted) prompt, enter resize number start end, where number is the partition number, start is the location on the disk at which the partition begins, and end is the location on the disk at which you want the partition to end. Use the start position that you previously obtained with the print command, and refer to the parted documentation for different ways to specify the end parameter.
      5. When parted finishes resizing the partition, enter quit at the (parted) prompt.
      6. Run e2fsck partition, where partition is the partition that you just resized. For example, if you just resized /dev/sda3, enter e2fsck /dev/sda3.
        Linux now checks the file system of the newly-resized partition.
      7. When the file system check finishes, type resize2fs partition at a command line and press Enter, where partition is the partition that you just resized. For example, if you just resized /dev/sda3, type resize2fs /dev/sda3.
        Linux now resizes your file system to fill the newly-resized partition.
      8. Restart your computer. The extra space is now available to your Linux installation.
    • If you use LVM

      1. Boot your computer from Linux live media and install fdisk and lvm2 if they are not already present.
      2. Create a new partition in the free space on the disk

        1. As root or with sudo, run fdisk disk, where disk is the device name of the disk where you want to create new space, for example, /dev/sda.
        2. At the prompt Command (m for help):, enter n to create a new partition. Refer to the fdisk documentation for options.
      3. Change the partition type identifier

        1. At the prompt Command (m for help):, enter t to change a partition type.
        2. At the prompt Partition number (1-4):, type the number of the partition that you just created. For example, if you just created partition /dev/sda3, type the number 3 and press Enter. This identifies the partition whose type fdisk will change.
        3. At the prompt Hex code (type L to list codes):, enter 8e to create a Linux LVM partition.
        4. At the prompt Command (m for help):, enter w to write the changes to disk and exit fdisk.
      4. Expand the volume group

        1. At the command prompt, type lvm and press Enter to start the lvm2 tool.
        2. At the lvm> prompt, type pvcreate partition and press Enter, where partition is the partition that you recently created. For example, pvcreate /dev/sda3. This creates /dev/sda3 as a physical volume in LVM.
        3. At the lvm> prompt, type vgextend VolumeGroup partition and press Enter, where VolumeGroup is the LVM volume group on which Linux is installed and partition is the partition that you recently created. For example, if Linux is installed on /dev/VolumeGroup00, you would type vgextend /dev/VolumeGroup00 /dev/sda3 to extend that volume group to include the physical volume at /dev/sda3.
        4. At the lvm> prompt, type lvextend -l +100%FREE LogVol and press Enter, where LogVol is the logical volume that contains your Linux filesystem. For example, to extend LogVol00 to fill the newly-available space in its volume group, VolGroup00, type lvextend -l +100%FREE /dev/VolGroup00/LogVol00.
        5. At the lvm> prompt, type exit and press Enter to exit lvm2
      5. Type e2fsck LogVol at the command line and press Enter, where LogVol is the logical volume that you just resized. For example, if you just resized /dev/VolumeGroup00/LogVol00, you would type e2fsck /dev/VolumeGroup00/LogVol00.
        Linux now checks the file system of the newly-resized logical volume.
      6. When the file system check finishes, type resize2fs LogVol at a command line and press Enter, where LogVol is the partition that you just resized. For example, if you just resized /dev/VolumeGroup00/LogVol00, you would type resize2fs /dev/VolumeGroup00/LogVol00.
        Linux now resizes your file system to fill the newly-resized logical volume.
      7. Restart your computer. The extra space is now available to your Linux installation.