39.2.2. Your computer dual-boots Red Hat Enterprise Linux and a different Linux distribution
Remove Red Hat Enterprise Linux partitions
- Boot your Red Hat Enterprise Linux installation.
- 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 ofmount
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)
- Ensure that any data on this system that you still require is backed up to another system or storage location.
- Shut down the system and boot the Linux distribution that you want to keep on the system.
- 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. - Remove any unwanted and unnecessary partitions, for example, with fdisk for standard partitions, or lvremove and vgremove to remove logical volumes and volume groups.
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.- At the command line, type
su -
and press Enter. When the system prompts you for the root password, type the password and press Enter. - Type
gedit /boot/grub/grub.conf
and press Enter. This opens thegrub.conf
file in the gedit text editor. - A typical Red Hat Enterprise Linux entry in the
grub.conf
file consists of four lines:Depending on the configuration of your system, there may be multiple Red Hat Enterprise Linux entries inExample 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 quietinitrd /initrd-2.6.32.130.el6.i686.imggrub.conf
, each corresponding to a different version of the Linux kernel. Delete each of the Red Hat Enterprise Linux entries from the file. Grub.conf
contains a line that specifies the default operating system to boot, in the formatdefault=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 thedefault=
line contains the number one below the number of your chosen default operating system in the list.Save the updatedgrub.conf
file and close gedit
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
- Boot your computer from Linux live media, and install parted if it is not already present.
- 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
. - At the
(parted)
prompt, enterprint
. The parted tool displays information about the partitions on your system, including their partition numbers, their sizes, and their positions on the disk. - At the
(parted)
prompt, enterresize 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 theprint
command, and refer to the parted documentation for different ways to specify the end parameter. - When parted finishes resizing the partition, enter
quit
at the(parted)
prompt. - Run
e2fsck partition
, where partition is the partition that you just resized. For example, if you just resized/dev/sda3
, entere2fsck /dev/sda3
.Linux now checks the file system of the newly-resized partition. - 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
, typeresize2fs /dev/sda3
.Linux now resizes your file system to fill the newly-resized partition. - Restart your computer. The extra space is now available to your Linux installation.
If you use LVM
- Boot your computer from Linux live media and install fdisk and lvm2 if they are not already present.
Create a new partition in the free space on the disk
- 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
. - At the prompt
Command (m for help):
, entern
to create a new partition. Refer to the fdisk documentation for options.
Change the partition type identifier
- At the prompt
Command (m for help):
, entert
to change a partition type. - 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 number3
and press Enter. This identifies the partition whose type fdisk will change. - At the prompt
Hex code (type L to list codes):
, enter8e
to create a Linux LVM partition. - At the prompt
Command (m for help):
, enterw
to write the changes to disk and exit fdisk.
Expand the volume group
- At the command prompt, type
lvm
and press Enter to start the lvm2 tool. - At the
lvm>
prompt, typepvcreate 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. - At the
lvm>
prompt, typevgextend 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 typevgextend /dev/VolumeGroup00 /dev/sda3
to extend that volume group to include the physical volume at/dev/sda3
. - At the
lvm>
prompt, typelvextend -l +100%FREE LogVol
and press Enter, where LogVol is the logical volume that contains your Linux filesystem. For example, to extendLogVol00
to fill the newly-available space in its volume group,VolGroup00
, typelvextend -l +100%FREE /dev/VolGroup00/LogVol00
. - At the
lvm>
prompt, typeexit
and press Enter to exit lvm2
- 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 typee2fsck /dev/VolumeGroup00/LogVol00
.Linux now checks the file system of the newly-resized logical volume. - 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 typeresize2fs /dev/VolumeGroup00/LogVol00
.Linux now resizes your file system to fill the newly-resized logical volume. - Restart your computer. The extra space is now available to your Linux installation.