Difference between revisions of "Allocating a Windows Disk Partition to CentOS"

From Techotopia
Jump to: navigation, search
m (Text replacement - "<hr> <table border=" to "<htmlet>ezoicbottom</htmlet> <hr> <table border=")
m (Text replacement - "<table border="0" cellspacing="0">" to "<table border="0" cellspacing="0" width="100%">")
 
Line 1: Line 1:
<table border="0" cellspacing="0">
+
<table border="0" cellspacing="0" width="100%">
 
<tr>
 
<tr>
 
<td width="20%">[[Installing CentOS with Windows in Dual Boot Environment|Previous]]<td align="center">[[CentOS Essentials|Table of Contents]]<td width="20%" align="right">[[Logging into the CentOS GNOME Desktop|Next]]</td>
 
<td width="20%">[[Installing CentOS with Windows in Dual Boot Environment|Previous]]<td align="center">[[CentOS Essentials|Table of Contents]]<td width="20%" align="right">[[Logging into the CentOS GNOME Desktop|Next]]</td>
Line 217: Line 217:
 
<htmlet>ezoicbottom</htmlet>
 
<htmlet>ezoicbottom</htmlet>
 
<hr>
 
<hr>
<table border="0" cellspacing="0">
+
<table border="0" cellspacing="0" width="100%">
 
<tr>
 
<tr>
 
<td width="20%">[[Installing CentOS with Windows in Dual Boot Environment|Previous]]<td align="center">[[CentOS Essentials|Table of Contents]]<td width="20%" align="right">[[Logging into the CentOS GNOME Desktop|Next]]</td>
 
<td width="20%">[[Installing CentOS with Windows in Dual Boot Environment|Previous]]<td align="center">[[CentOS Essentials|Table of Contents]]<td width="20%" align="right">[[Logging into the CentOS GNOME Desktop|Next]]</td>

Latest revision as of 19:55, 27 October 2016

PreviousTable of ContentsNext
Installing CentOS with Windows in Dual Boot EnvironmentLogging into the CentOS GNOME Desktop


You are reading a sample chapter from the CentOS 5 Essentials Essentials book.

Purchase a copy of the fully updated CentOS 8 edition in eBook ($24.99) or Print ($36.99) format

CentOS 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 260 pages. Learn more...

Buy Print Preview Book


In the previous chapter we looked at how to install CentOS 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 CentOS with Windows in Dual Boot Environment.

This chapter is intended for users who have decided they like CentOS 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 Linux 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 CentOS 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:

[root@centos-2 ~]# 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         730     5863693+   7  HPFS/NTFS
/dev/hda2             731         743      104422+  83  Linux
/dev/hda3             744        2610    14996677+  8e  Linux LVM

In the above example output the system contains one physical disk drive referenced by device name /dev/hda. On that disk drive are three partitions accessed via the device names /dev/hda1, /dev/hda2 and /dev/hda3 respectively. Based on the values in the System column, there is one NTFS disk and two Linux disks. Clearly the NTFS disk is the one containing the Windows partition 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/hda in this instance):

[root@centos-2 ~]# fdisk /dev/hda

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 1 on our example system):

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

Command (m for help):

Now that we have deleted the Windows partition we now need to create the new Linux partition in the vacated disk space. The partition number must match the number of the partition removed (in this case 1) 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
   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-730, default 730): 730

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

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+  83  Linux
/dev/hda2             731         743      104422+  83  Linux
/dev/hda3             744        2610    14996677+  8e  Linux LVM

If the primary Linux partition (partition 2 in the above example) is not currently listed as being bootable, change this setting and verify it by entering the following commands:

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

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+  83  Linux
/dev/hda2   *         731         743      104422+  83  Linux
/dev/hda3             744        2610    14996677+  8e  Linux LVM

As illustrated by the fdisk output, partition 1 is now a Linux partition. 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 CentOS system to be sure the new partition table information is picked up by the system kernel before proceeding.

Formatting the Unallocated Disk Partition

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

[root@centos-2 ~]# mkfs -t ext3 /dev/hda1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
734400 inodes, 1465923 blocks
73296 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1501560832
45 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

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

This filesystem will be automatically checked every 38 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 Linux. 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. Once the changes have been made to the file save it.

Mounting the New Partition

Finally, we need to mount the new partition. In this example we will mount it in a directory called vol1. 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 /vol1

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/sda1 device to match your environment):

/dev/hda1 /vol1 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 /vol1

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

df -h /vol1

You should see output similar to:

Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1             3.4G  71M  3.2G   3% /vol1


You are reading a sample chapter from the CentOS 5 Essentials Essentials book.

Purchase a copy of the fully updated CentOS 8 edition in eBook ($24.99) or Print ($36.99) format

CentOS 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 260 pages. Learn more...

Buy Print Preview Book



PreviousTable of ContentsNext
Installing CentOS with Windows in Dual Boot EnvironmentLogging into the CentOS GNOME Desktop