Allocating a Windows Partition to Ubuntu Linux

From Techotopia
Jump to: navigation, search

One of the most common configurations for a new Ubuntu Linux installation involves reducing the size of the pre-existing Windows partition on the disk drive and using the resulting space to install Ubuntu Linux. This so called "dual boot" configuration allows the user to have both operating systems installed on the 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 the Installing Ubuntu Linux on a Windows System (Dual booting) chapter of this book.

This chapter is intended for users who have decided they like Ubnuntu Linux enough to delete Windows entirely from the disk, and use the resulting space for Linux. In this chapter 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 it. Ubuntu Linux ships with a tool called GParted which is a graphical disk partitioning tool. To invoke GParted, open a terminal window (Applications->System Tools->Konsole) and enter the following command:

sudo gparted

Enter your password when prompted to do so and wait for the GParted application to load:

Ubuntu linux gparted main.jpg

The Windows partition can be identified by the filesystem type. In this case the filesystem is of type NTFS (which corresponds to hda1). A FAT filesystem also indicates a Windows partition. The ext3 partition is our current Linux partition. We are now going to delete the Windows partition, but first need to unmount the partition. To do so, right click on the partition, either in the list or in the graphical representation of the partitions and select unmount. Enter your password if prompted to do so. The partition will be unmounted and a mount point will no longer be shown next to the partition in the list.

The next step is to delete the partition. Once again, right click on the partition in the list and select Delete. The delete task will be listed as Pending. To commit the change click on Apply in the GParted toolbar.

Once the deletion is complete the former Windows Partition will be listed as unallocated. This is now ready for us to use as a Linux partition.

Formatting the Unallocated Disk Partition

The next step is to format the partition so that it can be used by Linux. By default Ubuntu Linux using the ext3 filesystem format. This is a powerful filesystem format which supports features such as disk journaling which is useful for restoring damaged data.

To format the unallocated partition select it by clicking on it in the list and click on the New toolbar button. The following Create a new partition dialog will appear:

Ubuntu linux gparted create new partition.jpg

Unless you wish to create multiple partitions, want to leave some unallocated space or need a filesystem format other than ext3, leave the settings as they are. This will use the entire space for the partition. Click on Add and the action will be listed as Pending. Click on the Apply toolbar button to commit the change and the new ext3 partiton will be created.


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 as follows:

sudo gedit /boot/grub/menu.lst

Towards the bottom of the boot.lst file you will see a section similar to:

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/hda1
title           Microsoft Windows XP Home Edition
root            (hd0,0)
savedefault
makeactive
chainloader     +1

Delete this section from the file and 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. First we need to create the directory to act as the mount point:

sudo mkdir /vol1

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

sudo gedit /etc/fstab

At the bottom of the /etc/fstab file, add the following line to mount the new partition:

/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).

sudo 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             7.9G  147M  7.4G   2% /vol1